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