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