]> code.delx.au - gnu-emacs/blob - lisp/cedet/semantic/wisent/python-wy.el
Update copyright notices for 2013.
[gnu-emacs] / lisp / cedet / semantic / wisent / python-wy.el
1 ;;; semantic/wisent/python-wy.el --- Generated parser support file
2
3 ;; Copyright (C) 2002-2013 Free Software Foundation, Inc.
4 ;; Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
5 ;; 2009, 2010 Python Software Foundation; All Rights Reserved
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22 ;;; Commentary:
23 ;;
24 ;; This file was generated from admin/grammars/python.wy.
25 ;; It is derived in part from the Python grammar, used under the
26 ;; following license:
27 ;;
28 ;; PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
29 ;; --------------------------------------------
30 ;; 1. This LICENSE AGREEMENT is between the Python Software Foundation
31 ;; ("PSF"), and the Individual or Organization ("Licensee") accessing
32 ;; and otherwise using this software ("Python") in source or binary
33 ;; form and its associated documentation.
34 ;;
35 ;; 2. Subject to the terms and conditions of this License Agreement,
36 ;; PSF hereby grants Licensee a nonexclusive, royalty-free, world-wide
37 ;; license to reproduce, analyze, test, perform and/or display
38 ;; publicly, prepare derivative works, distribute, and otherwise use
39 ;; Python alone or in any derivative version, provided, however, that
40 ;; PSF's License Agreement and PSF's notice of copyright, i.e.,
41 ;; "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
42 ;; 2009, 2010 Python Software Foundation; All Rights Reserved" are
43 ;; retained in Python alone or in any derivative version prepared by
44 ;; Licensee.
45 ;;
46 ;; 3. In the event Licensee prepares a derivative work that is based
47 ;; on or incorporates Python or any part thereof, and wants to make
48 ;; the derivative work available to others as provided herein, then
49 ;; Licensee hereby agrees to include in any such work a brief summary
50 ;; of the changes made to Python.
51 ;;
52 ;; 4. PSF is making Python available to Licensee on an "AS IS"
53 ;; basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
54 ;; IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
55 ;; DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
56 ;; FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
57 ;; INFRINGE ANY THIRD PARTY RIGHTS.
58 ;;
59 ;; 5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
60 ;; FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A
61 ;; RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, OR
62 ;; ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
63 ;;
64 ;; 6. This License Agreement will automatically terminate upon a
65 ;; material breach of its terms and conditions.
66 ;;
67 ;; 7. Nothing in this License Agreement shall be deemed to create any
68 ;; relationship of agency, partnership, or joint venture between PSF
69 ;; and Licensee. This License Agreement does not grant permission to
70 ;; use PSF trademarks or trade name in a trademark sense to endorse or
71 ;; promote products or services of Licensee, or any third party.
72 ;;
73 ;; 8. By copying, installing or otherwise using Python, Licensee
74 ;; agrees to be bound by the terms and conditions of this License
75 ;; Agreement.
76
77 ;;; Code:
78
79 (require 'semantic/lex)
80 (eval-when-compile (require 'semantic/bovine))
81 \f
82 ;;; Prologue
83 ;;
84 (declare-function wisent-python-reconstitute-function-tag "semantic/wisent/python")
85 (declare-function wisent-python-reconstitute-class-tag "semantic/wisent/python")
86 \f
87 ;;; Declarations
88 ;;
89 (defconst wisent-python-wy--keyword-table
90 (semantic-lex-make-keyword-table
91 '(("and" . AND)
92 ("as" . AS)
93 ("assert" . ASSERT)
94 ("break" . BREAK)
95 ("class" . CLASS)
96 ("continue" . CONTINUE)
97 ("def" . DEF)
98 ("del" . DEL)
99 ("elif" . ELIF)
100 ("else" . ELSE)
101 ("except" . EXCEPT)
102 ("exec" . EXEC)
103 ("finally" . FINALLY)
104 ("for" . FOR)
105 ("from" . FROM)
106 ("global" . GLOBAL)
107 ("if" . IF)
108 ("import" . IMPORT)
109 ("in" . IN)
110 ("is" . IS)
111 ("lambda" . LAMBDA)
112 ("not" . NOT)
113 ("or" . OR)
114 ("pass" . PASS)
115 ("print" . PRINT)
116 ("raise" . RAISE)
117 ("return" . RETURN)
118 ("try" . TRY)
119 ("while" . WHILE)
120 ("with" . WITH)
121 ("yield" . YIELD))
122 '(("yield" summary "Create a generator function")
123 ("with" summary "Start statement with an associated context object")
124 ("while" summary "Start a 'while' loop")
125 ("try" summary "Start of statements protected by exception handlers")
126 ("return" summary "Return from a function")
127 ("raise" summary "Raise an exception")
128 ("print" summary "Print each argument to standard output")
129 ("pass" summary "Statement that does nothing")
130 ("or" summary "Binary logical 'or' operator")
131 ("not" summary "Unary boolean negation operator")
132 ("lambda" summary "Create anonymous function")
133 ("is" summary "Binary operator that tests for object equality")
134 ("in" summary "Part of 'for' statement ")
135 ("import" summary "Load specified modules")
136 ("if" summary "Start 'if' conditional statement")
137 ("global" summary "Declare one or more symbols as global symbols")
138 ("from" summary "Modify behavior of 'import' statement")
139 ("for" summary "Start a 'for' loop")
140 ("finally" summary "Specify code to be executed after 'try' statements whether or not an exception occurred")
141 ("exec" summary "Dynamically execute Python code")
142 ("except" summary "Specify exception handlers along with 'try' keyword")
143 ("else" summary "Start the 'else' clause following an 'if' statement")
144 ("elif" summary "Shorthand for 'else if' following an 'if' statement")
145 ("del" summary "Delete specified objects, i.e., undo what assignment did")
146 ("def" summary "Define a new function")
147 ("continue" summary "Skip to the next iteration of enclosing 'for' or 'while' loop")
148 ("class" summary "Define a new class")
149 ("break" summary "Terminate 'for' or 'while' loop")
150 ("assert" summary "Raise AssertionError exception if <expr> is false")
151 ("as" summary "EXPR as NAME makes value of EXPR available as variable NAME")
152 ("and" summary "Logical AND binary operator ... ")))
153 "Table of language keywords.")
154
155 (defconst wisent-python-wy--token-table
156 (semantic-lex-make-type-table
157 '(("symbol"
158 (NAME))
159 ("number"
160 (NUMBER_LITERAL))
161 ("string"
162 (STRING_LITERAL))
163 ("punctuation"
164 (AT . "@")
165 (BACKQUOTE . "`")
166 (ASSIGN . "=")
167 (COMMA . ",")
168 (SEMICOLON . ";")
169 (COLON . ":")
170 (BAR . "|")
171 (TILDE . "~")
172 (PERIOD . ".")
173 (MINUS . "-")
174 (PLUS . "+")
175 (MOD . "%")
176 (DIV . "/")
177 (MULT . "*")
178 (AMP . "&")
179 (GT . ">")
180 (LT . "<")
181 (HAT . "^")
182 (NE . "!=")
183 (LTGT . "<>")
184 (HATEQ . "^=")
185 (OREQ . "|=")
186 (AMPEQ . "&=")
187 (MODEQ . "%=")
188 (DIVEQ . "/=")
189 (MULTEQ . "*=")
190 (MINUSEQ . "-=")
191 (PLUSEQ . "+=")
192 (LE . "<=")
193 (GE . ">=")
194 (EQ . "==")
195 (EXPONENT . "**")
196 (GTGT . ">>")
197 (LTLT . "<<")
198 (DIVDIV . "//")
199 (DIVDIVEQ . "//=")
200 (EXPEQ . "**=")
201 (GTGTEQ . ">>=")
202 (LTLTEQ . "<<="))
203 ("close-paren"
204 (RBRACK . "]")
205 (RBRACE . "}")
206 (RPAREN . ")"))
207 ("open-paren"
208 (LBRACK . "[")
209 (LBRACE . "{")
210 (LPAREN . "("))
211 ("block"
212 (BRACK_BLOCK . "(LBRACK RBRACK)")
213 (BRACE_BLOCK . "(LBRACE RBRACE)")
214 (PAREN_BLOCK . "(LPAREN RPAREN)"))
215 ("indentation"
216 (INDENT_BLOCK . "(INDENT DEDENT)")
217 (DEDENT . "[^:INDENT:]")
218 (INDENT . "^\\s-+"))
219 ("newline"
220 (NEWLINE . "\n"))
221 ("charquote"
222 (BACKSLASH . "\\")))
223 '(("keyword" :declared t)
224 ("symbol" :declared t)
225 ("number" :declared t)
226 ("punctuation" :declared t)
227 ("block" :declared t)))
228 "Table of lexical tokens.")
229
230 (defconst wisent-python-wy--parse-table
231 (progn
232 (eval-when-compile
233 (require 'semantic/wisent/comp))
234 (wisent-compile-grammar
235 '((BACKSLASH NEWLINE INDENT DEDENT INDENT_BLOCK PAREN_BLOCK BRACE_BLOCK BRACK_BLOCK LPAREN RPAREN LBRACE RBRACE LBRACK RBRACK LTLTEQ GTGTEQ EXPEQ DIVDIVEQ DIVDIV LTLT GTGT EXPONENT EQ GE LE PLUSEQ MINUSEQ MULTEQ DIVEQ MODEQ AMPEQ OREQ HATEQ LTGT NE HAT LT GT AMP MULT DIV MOD PLUS MINUS PERIOD TILDE BAR COLON SEMICOLON COMMA ASSIGN BACKQUOTE AT STRING_LITERAL NUMBER_LITERAL NAME AND AS ASSERT BREAK CLASS CONTINUE DEF DEL ELIF ELSE EXCEPT EXEC FINALLY FOR FROM GLOBAL IF IMPORT IN IS LAMBDA NOT OR PASS PRINT RAISE RETURN TRY WHILE WITH YIELD)
236 nil
237 (goal
238 ((NEWLINE))
239 ((simple_stmt))
240 ((compound_stmt)))
241 (simple_stmt
242 ((small_stmt_list semicolon_opt NEWLINE)))
243 (small_stmt_list
244 ((small_stmt))
245 ((small_stmt_list SEMICOLON small_stmt)))
246 (small_stmt
247 ((expr_stmt))
248 ((print_stmt))
249 ((del_stmt))
250 ((pass_stmt))
251 ((flow_stmt))
252 ((import_stmt))
253 ((global_stmt))
254 ((exec_stmt))
255 ((assert_stmt)))
256 (print_stmt
257 ((PRINT print_stmt_trailer)
258 (wisent-raw-tag
259 (semantic-tag-new-code $1 nil))))
260 (print_stmt_trailer
261 ((test_list_opt)
262 nil)
263 ((GTGT test trailing_test_list_with_opt_comma_opt)
264 nil))
265 (trailing_test_list_with_opt_comma_opt
266 (nil)
267 ((trailing_test_list comma_opt)
268 nil))
269 (trailing_test_list
270 ((COMMA test)
271 nil)
272 ((trailing_test_list COMMA test)
273 nil))
274 (expr_stmt
275 ((testlist expr_stmt_trailer)
276 (if
277 (and $2
278 (stringp $1)
279 (string-match "^\\(\\sw\\|\\s_\\)+$" $1))
280 (wisent-raw-tag
281 (semantic-tag-new-variable $1 nil nil))
282 (wisent-raw-tag
283 (semantic-tag-new-code $1 nil)))))
284 (expr_stmt_trailer
285 ((augassign testlist))
286 ((eq_testlist_zom)))
287 (eq_testlist_zom
288 (nil)
289 ((eq_testlist_zom ASSIGN testlist)
290 (identity $3)))
291 (augassign
292 ((PLUSEQ))
293 ((MINUSEQ))
294 ((MULTEQ))
295 ((DIVEQ))
296 ((MODEQ))
297 ((AMPEQ))
298 ((OREQ))
299 ((HATEQ))
300 ((LTLTEQ))
301 ((GTGTEQ))
302 ((EXPEQ))
303 ((DIVDIVEQ)))
304 (del_stmt
305 ((DEL exprlist)
306 (wisent-raw-tag
307 (semantic-tag-new-code $1 nil))))
308 (exprlist
309 ((expr_list comma_opt)
310 nil))
311 (expr_list
312 ((expr)
313 nil)
314 ((expr_list COMMA expr)
315 nil))
316 (pass_stmt
317 ((PASS)
318 (wisent-raw-tag
319 (semantic-tag-new-code $1 nil))))
320 (flow_stmt
321 ((break_stmt))
322 ((continue_stmt))
323 ((return_stmt))
324 ((raise_stmt))
325 ((yield_stmt)))
326 (break_stmt
327 ((BREAK)
328 (wisent-raw-tag
329 (semantic-tag-new-code $1 nil))))
330 (continue_stmt
331 ((CONTINUE)
332 (wisent-raw-tag
333 (semantic-tag-new-code $1 nil))))
334 (return_stmt
335 ((RETURN testlist_opt)
336 (wisent-raw-tag
337 (semantic-tag-new-code $1 nil))))
338 (testlist_opt
339 (nil)
340 ((testlist)
341 nil))
342 (yield_stmt
343 ((YIELD)
344 (wisent-raw-tag
345 (semantic-tag-new-code $1 nil)))
346 ((YIELD testlist)
347 (wisent-raw-tag
348 (semantic-tag-new-code $1 nil))))
349 (raise_stmt
350 ((RAISE zero_one_two_or_three_tests)
351 (wisent-raw-tag
352 (semantic-tag-new-code $1 nil))))
353 (zero_one_two_or_three_tests
354 (nil)
355 ((test zero_one_or_two_tests)
356 nil))
357 (zero_one_or_two_tests
358 (nil)
359 ((COMMA test zero_or_one_comma_test)
360 nil))
361 (zero_or_one_comma_test
362 (nil)
363 ((COMMA test)
364 nil))
365 (import_stmt
366 ((IMPORT dotted_as_name_list)
367 (wisent-raw-tag
368 (semantic-tag-new-include $2 nil)))
369 ((FROM dotted_name IMPORT star_or_import_as_name_list)
370 (wisent-raw-tag
371 (semantic-tag-new-include $2 nil))))
372 (dotted_as_name_list
373 ((dotted_as_name_list COMMA dotted_as_name)
374 (cons $3 $1))
375 ((dotted_as_name)
376 (list $1)))
377 (star_or_import_as_name_list
378 ((MULT)
379 nil)
380 ((import_as_name_list)
381 nil))
382 (import_as_name_list
383 ((import_as_name)
384 nil)
385 ((import_as_name_list COMMA import_as_name)
386 nil))
387 (import_as_name
388 ((NAME as_name_opt)
389 nil))
390 (dotted_as_name
391 ((dotted_name as_name_opt)))
392 (as_name_opt
393 (nil)
394 ((AS NAME)
395 (identity $2)))
396 (dotted_name
397 ((NAME))
398 ((dotted_name PERIOD NAME)
399 (format "%s.%s" $1 $3)))
400 (global_stmt
401 ((GLOBAL comma_sep_name_list)
402 (wisent-raw-tag
403 (semantic-tag-new-code $1 nil))))
404 (comma_sep_name_list
405 ((NAME))
406 ((comma_sep_name_list COMMA NAME)))
407 (exec_stmt
408 ((EXEC expr exec_trailer)
409 (wisent-raw-tag
410 (semantic-tag-new-code $1 nil))))
411 (exec_trailer
412 (nil)
413 ((IN test comma_test_opt)
414 nil))
415 (comma_test_opt
416 (nil)
417 ((COMMA test)
418 nil))
419 (assert_stmt
420 ((ASSERT test comma_test_opt)
421 (wisent-raw-tag
422 (semantic-tag-new-code $1 nil))))
423 (compound_stmt
424 ((if_stmt))
425 ((while_stmt))
426 ((for_stmt))
427 ((try_stmt))
428 ((with_stmt))
429 ((funcdef))
430 ((class_declaration)))
431 (if_stmt
432 ((IF test COLON suite elif_suite_pair_list else_suite_pair_opt)
433 (wisent-raw-tag
434 (semantic-tag-new-code $1 nil))))
435 (elif_suite_pair_list
436 (nil)
437 ((elif_suite_pair_list ELIF test COLON suite)
438 nil))
439 (else_suite_pair_opt
440 (nil)
441 ((ELSE COLON suite)
442 nil))
443 (suite
444 ((simple_stmt)
445 (list $1))
446 ((NEWLINE indented_block)
447 (progn $2)))
448 (indented_block
449 ((INDENT_BLOCK)
450 (semantic-parse-region
451 (car $region1)
452 (cdr $region1)
453 'indented_block_body 1)))
454 (indented_block_body
455 ((INDENT)
456 nil)
457 ((DEDENT)
458 nil)
459 ((simple_stmt))
460 ((compound_stmt)))
461 (while_stmt
462 ((WHILE test COLON suite else_suite_pair_opt)
463 (wisent-raw-tag
464 (semantic-tag-new-code $1 nil))))
465 (for_stmt
466 ((FOR exprlist IN testlist COLON suite else_suite_pair_opt)
467 (wisent-raw-tag
468 (semantic-tag-new-code $1 nil))))
469 (try_stmt
470 ((TRY COLON suite except_clause_suite_pair_list else_suite_pair_opt)
471 (wisent-raw-tag
472 (semantic-tag-new-code $1 nil)))
473 ((TRY COLON suite FINALLY COLON suite)
474 (wisent-raw-tag
475 (semantic-tag-new-code $1 nil))))
476 (except_clause_suite_pair_list
477 ((except_clause COLON suite)
478 nil)
479 ((except_clause_suite_pair_list except_clause COLON suite)
480 nil))
481 (except_clause
482 ((EXCEPT zero_one_or_two_test)
483 nil))
484 (zero_one_or_two_test
485 (nil)
486 ((test zero_or_one_comma_test)
487 nil))
488 (with_stmt
489 ((WITH test COLON suite)
490 (wisent-raw-tag
491 (semantic-tag-new-code $1 nil)))
492 ((WITH test with_var COLON suite)
493 (wisent-raw-tag
494 (semantic-tag-new-code $1 nil))))
495 (with_var
496 ((AS expr)
497 nil))
498 (decorator
499 ((AT dotted_name varargslist_opt NEWLINE)
500 (wisent-raw-tag
501 (semantic-tag-new-function $2 "decorator" $3))))
502 (decorators
503 ((decorator)
504 (list $1))
505 ((decorator decorators)
506 (cons $1 $2)))
507 (funcdef
508 ((DEF NAME function_parameter_list COLON suite)
509 (wisent-python-reconstitute-function-tag
510 (wisent-raw-tag
511 (semantic-tag-new-function $2 nil $3))
512 $5))
513 ((decorators DEF NAME function_parameter_list COLON suite)
514 (wisent-python-reconstitute-function-tag
515 (wisent-raw-tag
516 (semantic-tag-new-function $3 nil $4 :decorators $1))
517 $6)))
518 (function_parameter_list
519 ((PAREN_BLOCK)
520 (let
521 ((wisent-python-EXPANDING-block t))
522 (semantic-parse-region
523 (car $region1)
524 (cdr $region1)
525 'function_parameters 1))))
526 (function_parameters
527 ((LPAREN)
528 nil)
529 ((RPAREN)
530 nil)
531 ((function_parameter COMMA))
532 ((function_parameter RPAREN)))
533 (function_parameter
534 ((fpdef_opt_test))
535 ((MULT NAME)
536 (wisent-raw-tag
537 (semantic-tag-new-variable $2 nil nil)))
538 ((EXPONENT NAME)
539 (wisent-raw-tag
540 (semantic-tag-new-variable $2 nil nil))))
541 (class_declaration
542 ((CLASS NAME paren_class_list_opt COLON suite)
543 (wisent-python-reconstitute-class-tag
544 (wisent-raw-tag
545 (semantic-tag-new-type $2 $1 $5
546 (cons $3 nil))))))
547 (paren_class_list_opt
548 (nil)
549 ((paren_class_list)))
550 (paren_class_list
551 ((PAREN_BLOCK)
552 (let
553 ((wisent-python-EXPANDING-block t))
554 (mapcar 'semantic-tag-name
555 (semantic-parse-region
556 (car $region1)
557 (cdr $region1)
558 'paren_classes 1)))))
559 (paren_classes
560 ((LPAREN)
561 nil)
562 ((RPAREN)
563 nil)
564 ((paren_class COMMA)
565 (wisent-raw-tag
566 (semantic-tag-new-variable $1 nil nil)))
567 ((paren_class RPAREN)
568 (wisent-raw-tag
569 (semantic-tag-new-variable $1 nil nil))))
570 (paren_class
571 ((dotted_name)))
572 (test
573 ((test_test))
574 ((lambdef)))
575 (test_test
576 ((and_test))
577 ((test_test OR and_test)
578 nil))
579 (and_test
580 ((not_test))
581 ((and_test AND not_test)
582 nil))
583 (not_test
584 ((NOT not_test)
585 nil)
586 ((comparison)))
587 (comparison
588 ((expr))
589 ((comparison comp_op expr)
590 nil))
591 (comp_op
592 ((LT))
593 ((GT))
594 ((EQ))
595 ((GE))
596 ((LE))
597 ((LTGT))
598 ((NE))
599 ((IN))
600 ((NOT IN))
601 ((IS))
602 ((IS NOT)))
603 (expr
604 ((xor_expr))
605 ((expr BAR xor_expr)
606 nil))
607 (xor_expr
608 ((and_expr))
609 ((xor_expr HAT and_expr)
610 nil))
611 (and_expr
612 ((shift_expr))
613 ((and_expr AMP shift_expr)
614 nil))
615 (shift_expr
616 ((arith_expr))
617 ((shift_expr shift_expr_operators arith_expr)
618 nil))
619 (shift_expr_operators
620 ((LTLT))
621 ((GTGT)))
622 (arith_expr
623 ((term))
624 ((arith_expr plus_or_minus term)
625 nil))
626 (plus_or_minus
627 ((PLUS))
628 ((MINUS)))
629 (term
630 ((factor))
631 ((term term_operator factor)
632 nil))
633 (term_operator
634 ((MULT))
635 ((DIV))
636 ((MOD))
637 ((DIVDIV)))
638 (factor
639 ((prefix_operators factor)
640 nil)
641 ((power)))
642 (prefix_operators
643 ((PLUS))
644 ((MINUS))
645 ((TILDE)))
646 (power
647 ((atom trailer_zom exponent_zom)
648 (concat $1
649 (if $2
650 (concat " " $2 " ")
651 "")
652 (if $3
653 (concat " " $3)
654 ""))))
655 (trailer_zom
656 (nil)
657 ((trailer_zom trailer)
658 nil))
659 (exponent_zom
660 (nil)
661 ((exponent_zom EXPONENT factor)
662 nil))
663 (trailer
664 ((PAREN_BLOCK)
665 nil)
666 ((BRACK_BLOCK)
667 nil)
668 ((PERIOD NAME)
669 nil))
670 (atom
671 ((PAREN_BLOCK)
672 nil)
673 ((BRACK_BLOCK)
674 nil)
675 ((BRACE_BLOCK)
676 nil)
677 ((BACKQUOTE testlist BACKQUOTE)
678 nil)
679 ((NAME))
680 ((NUMBER_LITERAL))
681 ((one_or_more_string)))
682 (test_list_opt
683 (nil)
684 ((testlist)
685 nil))
686 (testlist
687 ((comma_sep_test_list comma_opt)))
688 (comma_sep_test_list
689 ((test))
690 ((comma_sep_test_list COMMA test)
691 (format "%s, %s" $1 $3)))
692 (one_or_more_string
693 ((STRING_LITERAL))
694 ((one_or_more_string STRING_LITERAL)
695 (concat $1 $2)))
696 (lambdef
697 ((LAMBDA varargslist_opt COLON test)
698 (format "%s %s" $1
699 (or $2 ""))))
700 (varargslist_opt
701 (nil)
702 ((varargslist)))
703 (varargslist
704 ((fpdef_opt_test_list_comma_zom rest_args)
705 (nconc $2 $1))
706 ((fpdef_opt_test_list comma_opt)))
707 (rest_args
708 ((MULT NAME multmult_name_opt)
709 nil)
710 ((EXPONENT NAME)
711 nil))
712 (multmult_name_opt
713 (nil)
714 ((COMMA EXPONENT NAME)
715 (wisent-raw-tag
716 (semantic-tag-new-variable $3 nil nil))))
717 (fpdef_opt_test_list_comma_zom
718 (nil)
719 ((fpdef_opt_test_list_comma_zom fpdef_opt_test COMMA)
720 (nconc $2 $1)))
721 (fpdef_opt_test_list
722 ((fpdef_opt_test))
723 ((fpdef_opt_test_list COMMA fpdef_opt_test)
724 (nconc $3 $1)))
725 (fpdef_opt_test
726 ((fpdef eq_test_opt)))
727 (fpdef
728 ((NAME)
729 (wisent-raw-tag
730 (semantic-tag-new-variable $1 nil nil))))
731 (fplist
732 ((fpdef_list comma_opt)))
733 (fpdef_list
734 ((fpdef))
735 ((fpdef_list COMMA fpdef)))
736 (eq_test_opt
737 (nil)
738 ((ASSIGN test)
739 nil))
740 (comma_opt
741 (nil)
742 ((COMMA)))
743 (semicolon_opt
744 (nil)
745 ((SEMICOLON))))
746 '(goal function_parameter paren_class indented_block function_parameters paren_classes indented_block_body)))
747 "Parser table.")
748
749 (defun wisent-python-wy--install-parser ()
750 "Setup the Semantic Parser."
751 (semantic-install-function-overrides
752 '((parse-stream . wisent-parse-stream)))
753 (setq semantic-parser-name "LALR"
754 semantic--parse-table wisent-python-wy--parse-table
755 semantic-debug-parser-source "python.wy"
756 semantic-flex-keywords-obarray wisent-python-wy--keyword-table
757 semantic-lex-types-obarray wisent-python-wy--token-table)
758 ;; Collect unmatched syntax lexical tokens
759 (semantic-make-local-hook 'wisent-discarding-token-functions)
760 (add-hook 'wisent-discarding-token-functions
761 'wisent-collect-unmatched-syntax nil t))
762
763 \f
764 ;;; Analyzers
765 ;;
766 (define-lex-block-type-analyzer wisent-python-wy--<block>-block-analyzer
767 "block analyzer for <block> tokens."
768 "\\s(\\|\\s)"
769 '((("(" LPAREN PAREN_BLOCK)
770 ("{" LBRACE BRACE_BLOCK)
771 ("[" LBRACK BRACK_BLOCK))
772 (")" RPAREN)
773 ("}" RBRACE)
774 ("]" RBRACK))
775 )
776
777 (define-lex-regex-type-analyzer wisent-python-wy--<symbol>-regexp-analyzer
778 "regexp analyzer for <symbol> tokens."
779 "\\(\\sw\\|\\s_\\)+"
780 nil
781 'NAME)
782
783 (define-lex-regex-type-analyzer wisent-python-wy--<number>-regexp-analyzer
784 "regexp analyzer for <number> tokens."
785 semantic-lex-number-expression
786 nil
787 'NUMBER_LITERAL)
788
789 (define-lex-string-type-analyzer wisent-python-wy--<punctuation>-string-analyzer
790 "string analyzer for <punctuation> tokens."
791 "\\(\\s.\\|\\s$\\|\\s'\\)+"
792 '((AT . "@")
793 (BACKQUOTE . "`")
794 (ASSIGN . "=")
795 (COMMA . ",")
796 (SEMICOLON . ";")
797 (COLON . ":")
798 (BAR . "|")
799 (TILDE . "~")
800 (PERIOD . ".")
801 (MINUS . "-")
802 (PLUS . "+")
803 (MOD . "%")
804 (DIV . "/")
805 (MULT . "*")
806 (AMP . "&")
807 (GT . ">")
808 (LT . "<")
809 (HAT . "^")
810 (NE . "!=")
811 (LTGT . "<>")
812 (HATEQ . "^=")
813 (OREQ . "|=")
814 (AMPEQ . "&=")
815 (MODEQ . "%=")
816 (DIVEQ . "/=")
817 (MULTEQ . "*=")
818 (MINUSEQ . "-=")
819 (PLUSEQ . "+=")
820 (LE . "<=")
821 (GE . ">=")
822 (EQ . "==")
823 (EXPONENT . "**")
824 (GTGT . ">>")
825 (LTLT . "<<")
826 (DIVDIV . "//")
827 (DIVDIVEQ . "//=")
828 (EXPEQ . "**=")
829 (GTGTEQ . ">>=")
830 (LTLTEQ . "<<="))
831 'punctuation)
832
833 (define-lex-keyword-type-analyzer wisent-python-wy--<keyword>-keyword-analyzer
834 "keyword analyzer for <keyword> tokens."
835 "\\(\\sw\\|\\s_\\)+")
836
837 \f
838 ;;; Epilogue
839 ;;
840
841 (provide 'semantic/wisent/python-wy)
842
843 ;;; semantic/wisent/python-wy.el ends here