]> code.delx.au - gnu-emacs/blob - lisp/cedet/semantic/wisent/python-wy.el
Merge from emacs-23; up to 2012-01-19T07:15:48Z!rgm@gnu.org.
[gnu-emacs] / 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-2012 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 \f
81 ;;; Prologue
82 ;;
83 \f
84 ;;; Declarations
85 ;;
86 (defconst wisent-python-wy--keyword-table
87 (semantic-lex-make-keyword-table
88 '(("and" . AND)
89 ("as" . AS)
90 ("assert" . ASSERT)
91 ("break" . BREAK)
92 ("class" . CLASS)
93 ("continue" . CONTINUE)
94 ("def" . DEF)
95 ("del" . DEL)
96 ("elif" . ELIF)
97 ("else" . ELSE)
98 ("except" . EXCEPT)
99 ("exec" . EXEC)
100 ("finally" . FINALLY)
101 ("for" . FOR)
102 ("from" . FROM)
103 ("global" . GLOBAL)
104 ("if" . IF)
105 ("import" . IMPORT)
106 ("in" . IN)
107 ("is" . IS)
108 ("lambda" . LAMBDA)
109 ("not" . NOT)
110 ("or" . OR)
111 ("pass" . PASS)
112 ("print" . PRINT)
113 ("raise" . RAISE)
114 ("return" . RETURN)
115 ("try" . TRY)
116 ("while" . WHILE)
117 ("yield" . YIELD))
118 '(("yield" summary "Create a generator function")
119 ("while" summary "Start a 'while' loop")
120 ("try" summary "Start of statements protected by exception handlers")
121 ("return" summary "Return from a function")
122 ("raise" summary "Raise an exception")
123 ("print" summary "Print each argument to standard output")
124 ("pass" summary "Statement that does nothing")
125 ("or" summary "Binary logical 'or' operator")
126 ("not" summary "Unary boolean negation operator")
127 ("lambda" summary "Create anonymous function")
128 ("is" summary "Binary operator that tests for object equality")
129 ("in" summary "Part of 'for' statement ")
130 ("import" summary "Load specified modules")
131 ("if" summary "Start 'if' conditional statement")
132 ("global" summary "Declare one or more symbols as global symbols")
133 ("from" summary "Modify behavior of 'import' statement")
134 ("for" summary "Start a 'for' loop")
135 ("finally" summary "Specify code to be executed after 'try' statements whether or not an exception occurred")
136 ("exec" summary "Dynamically execute Python code")
137 ("except" summary "Specify exception handlers along with 'try' keyword")
138 ("else" summary "Start the 'else' clause following an 'if' statement")
139 ("elif" summary "Shorthand for 'else if' following an 'if' statement")
140 ("del" summary "Delete specified objects, i.e., undo what assignment did")
141 ("def" summary "Define a new function")
142 ("continue" summary "Skip to the next iteration of enclosing 'for' or 'while' loop")
143 ("class" summary "Define a new class")
144 ("break" summary "Terminate 'for' or 'while' loop")
145 ("assert" summary "Raise AssertionError exception if <expr> is false")
146 ("as" summary "EXPR as NAME makes value of EXPR available as variable NAME")
147 ("and" summary "Logical AND binary operator ... ")))
148 "Table of language keywords.")
149
150 (defconst wisent-python-wy--token-table
151 (semantic-lex-make-type-table
152 '(("symbol"
153 (NAME))
154 ("number"
155 (NUMBER_LITERAL))
156 ("string"
157 (STRING_LITERAL))
158 ("punctuation"
159 (BACKQUOTE . "`")
160 (ASSIGN . "=")
161 (COMMA . ",")
162 (SEMICOLON . ";")
163 (COLON . ":")
164 (BAR . "|")
165 (TILDE . "~")
166 (PERIOD . ".")
167 (MINUS . "-")
168 (PLUS . "+")
169 (MOD . "%")
170 (DIV . "/")
171 (MULT . "*")
172 (AMP . "&")
173 (GT . ">")
174 (LT . "<")
175 (HAT . "^")
176 (NE . "!=")
177 (LTGT . "<>")
178 (HATEQ . "^=")
179 (OREQ . "|=")
180 (AMPEQ . "&=")
181 (MODEQ . "%=")
182 (DIVEQ . "/=")
183 (MULTEQ . "*=")
184 (MINUSEQ . "-=")
185 (PLUSEQ . "+=")
186 (LE . "<=")
187 (GE . ">=")
188 (EQ . "==")
189 (EXPONENT . "**")
190 (GTGT . ">>")
191 (LTLT . "<<")
192 (DIVDIV . "//")
193 (DIVDIVEQ . "//=")
194 (EXPEQ . "**=")
195 (GTGTEQ . ">>=")
196 (LTLTEQ . "<<="))
197 ("close-paren"
198 (RBRACK . "]")
199 (RBRACE . "}")
200 (RPAREN . ")"))
201 ("open-paren"
202 (LBRACK . "[")
203 (LBRACE . "{")
204 (LPAREN . "("))
205 ("block"
206 (BRACK_BLOCK . "(LBRACK RBRACK)")
207 (BRACE_BLOCK . "(LBRACE RBRACE)")
208 (PAREN_BLOCK . "(LPAREN RPAREN)"))
209 ("indentation"
210 (INDENT_BLOCK . "(INDENT DEDENT)")
211 (DEDENT . "[^:INDENT:]")
212 (INDENT . "^\\s-+"))
213 ("newline"
214 (NEWLINE . "\n"))
215 ("charquote"
216 (BACKSLASH . "\\")))
217 '(("keyword" :declared t)
218 ("symbol" :declared t)
219 ("number" :declared t)
220 ("punctuation" :declared t)
221 ("block" :declared t)))
222 "Table of lexical tokens.")
223
224 (defconst wisent-python-wy--parse-table
225 (progn
226 (eval-when-compile
227 (require 'semantic/wisent/comp))
228 (wisent-compile-grammar
229 '((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)
230 nil
231 (goal
232 ((NEWLINE))
233 ((simple_stmt))
234 ((compound_stmt)))
235 (simple_stmt
236 ((small_stmt_list semicolon_opt NEWLINE)))
237 (small_stmt_list
238 ((small_stmt))
239 ((small_stmt_list SEMICOLON small_stmt)))
240 (small_stmt
241 ((expr_stmt))
242 ((print_stmt))
243 ((del_stmt))
244 ((pass_stmt))
245 ((flow_stmt))
246 ((import_stmt))
247 ((global_stmt))
248 ((exec_stmt))
249 ((assert_stmt)))
250 (print_stmt
251 ((PRINT print_stmt_trailer)
252 (wisent-raw-tag
253 (semantic-tag-new-code $1 nil))))
254 (print_stmt_trailer
255 ((test_list_opt)
256 nil)
257 ((GTGT test trailing_test_list_with_opt_comma_opt)
258 nil))
259 (trailing_test_list_with_opt_comma_opt
260 (nil)
261 ((trailing_test_list comma_opt)
262 nil))
263 (trailing_test_list
264 ((COMMA test)
265 nil)
266 ((trailing_test_list COMMA test)
267 nil))
268 (expr_stmt
269 ((testlist expr_stmt_trailer)
270 (if
271 (and $2
272 (stringp $1)
273 (string-match "^\\(\\sw\\|\\s_\\)+$" $1))
274 (wisent-raw-tag
275 (semantic-tag-new-variable $1 nil nil))
276 (wisent-raw-tag
277 (semantic-tag-new-code $1 nil)))))
278 (expr_stmt_trailer
279 ((augassign testlist))
280 ((eq_testlist_zom)))
281 (eq_testlist_zom
282 (nil)
283 ((eq_testlist_zom ASSIGN testlist)
284 (identity $3)))
285 (augassign
286 ((PLUSEQ))
287 ((MINUSEQ))
288 ((MULTEQ))
289 ((DIVEQ))
290 ((MODEQ))
291 ((AMPEQ))
292 ((OREQ))
293 ((HATEQ))
294 ((LTLTEQ))
295 ((GTGTEQ))
296 ((EXPEQ))
297 ((DIVDIVEQ)))
298 (del_stmt
299 ((DEL exprlist)
300 (wisent-raw-tag
301 (semantic-tag-new-code $1 nil))))
302 (exprlist
303 ((expr_list comma_opt)
304 nil))
305 (expr_list
306 ((expr)
307 nil)
308 ((expr_list COMMA expr)
309 nil))
310 (pass_stmt
311 ((PASS)
312 (wisent-raw-tag
313 (semantic-tag-new-code $1 nil))))
314 (flow_stmt
315 ((break_stmt))
316 ((continue_stmt))
317 ((return_stmt))
318 ((raise_stmt))
319 ((yield_stmt)))
320 (break_stmt
321 ((BREAK)
322 (wisent-raw-tag
323 (semantic-tag-new-code $1 nil))))
324 (continue_stmt
325 ((CONTINUE)
326 (wisent-raw-tag
327 (semantic-tag-new-code $1 nil))))
328 (return_stmt
329 ((RETURN testlist_opt)
330 (wisent-raw-tag
331 (semantic-tag-new-code $1 nil))))
332 (testlist_opt
333 (nil)
334 ((testlist)
335 nil))
336 (yield_stmt
337 ((YIELD)
338 (wisent-raw-tag
339 (semantic-tag-new-code $1 nil)))
340 ((YIELD testlist)
341 (wisent-raw-tag
342 (semantic-tag-new-code $1 nil))))
343 (raise_stmt
344 ((RAISE zero_one_two_or_three_tests)
345 (wisent-raw-tag
346 (semantic-tag-new-code $1 nil))))
347 (zero_one_two_or_three_tests
348 (nil)
349 ((test zero_one_or_two_tests)
350 nil))
351 (zero_one_or_two_tests
352 (nil)
353 ((COMMA test zero_or_one_comma_test)
354 nil))
355 (zero_or_one_comma_test
356 (nil)
357 ((COMMA test)
358 nil))
359 (import_stmt
360 ((IMPORT dotted_as_name_list)
361 (wisent-raw-tag
362 (semantic-tag-new-include $2 nil)))
363 ((FROM dotted_name IMPORT star_or_import_as_name_list)
364 (wisent-raw-tag
365 (semantic-tag-new-include $2 nil))))
366 (dotted_as_name_list
367 ((dotted_as_name))
368 ((dotted_as_name_list COMMA dotted_as_name)))
369 (star_or_import_as_name_list
370 ((MULT)
371 nil)
372 ((import_as_name_list)
373 nil))
374 (import_as_name_list
375 ((import_as_name)
376 nil)
377 ((import_as_name_list COMMA import_as_name)
378 nil))
379 (import_as_name
380 ((NAME as_name_opt)
381 nil))
382 (dotted_as_name
383 ((dotted_name as_name_opt)))
384 (as_name_opt
385 (nil)
386 ((AS NAME)
387 (identity $2)))
388 (dotted_name
389 ((NAME))
390 ((dotted_name PERIOD NAME)
391 (format "%s.%s" $1 $3)))
392 (global_stmt
393 ((GLOBAL comma_sep_name_list)
394 (wisent-raw-tag
395 (semantic-tag-new-code $1 nil))))
396 (comma_sep_name_list
397 ((NAME))
398 ((comma_sep_name_list COMMA NAME)))
399 (exec_stmt
400 ((EXEC expr exec_trailer)
401 (wisent-raw-tag
402 (semantic-tag-new-code $1 nil))))
403 (exec_trailer
404 (nil)
405 ((IN test comma_test_opt)
406 nil))
407 (comma_test_opt
408 (nil)
409 ((COMMA test)
410 nil))
411 (assert_stmt
412 ((ASSERT test comma_test_opt)
413 (wisent-raw-tag
414 (semantic-tag-new-code $1 nil))))
415 (compound_stmt
416 ((if_stmt))
417 ((while_stmt))
418 ((for_stmt))
419 ((try_stmt))
420 ((funcdef))
421 ((class_declaration)))
422 (if_stmt
423 ((IF test COLON suite elif_suite_pair_list else_suite_pair_opt)
424 (wisent-raw-tag
425 (semantic-tag-new-code $1 nil))))
426 (elif_suite_pair_list
427 (nil)
428 ((elif_suite_pair_list ELIF test COLON suite)
429 nil))
430 (else_suite_pair_opt
431 (nil)
432 ((ELSE COLON suite)
433 nil))
434 (suite
435 ((simple_stmt)
436 (list $1))
437 ((NEWLINE indented_block)
438 (progn $2)))
439 (indented_block
440 ((INDENT_BLOCK)
441 (semantic-parse-region
442 (car $region1)
443 (cdr $region1)
444 'indented_block_body 1)))
445 (indented_block_body
446 ((INDENT)
447 nil)
448 ((DEDENT)
449 nil)
450 ((simple_stmt))
451 ((compound_stmt)))
452 (while_stmt
453 ((WHILE test COLON suite else_suite_pair_opt)
454 (wisent-raw-tag
455 (semantic-tag-new-code $1 nil))))
456 (for_stmt
457 ((FOR exprlist IN testlist COLON suite else_suite_pair_opt)
458 (wisent-raw-tag
459 (semantic-tag-new-code $1 nil))))
460 (try_stmt
461 ((TRY COLON suite except_clause_suite_pair_list else_suite_pair_opt)
462 (wisent-raw-tag
463 (semantic-tag-new-code $1 nil)))
464 ((TRY COLON suite FINALLY COLON suite)
465 (wisent-raw-tag
466 (semantic-tag-new-code $1 nil))))
467 (except_clause_suite_pair_list
468 ((except_clause COLON suite)
469 nil)
470 ((except_clause_suite_pair_list except_clause COLON suite)
471 nil))
472 (except_clause
473 ((EXCEPT zero_one_or_two_test)
474 nil))
475 (zero_one_or_two_test
476 (nil)
477 ((test zero_or_one_comma_test)
478 nil))
479 (funcdef
480 ((DEF NAME function_parameter_list COLON suite)
481 (wisent-raw-tag
482 (semantic-tag-new-function $2 nil $3))))
483 (function_parameter_list
484 ((PAREN_BLOCK)
485 (let
486 ((wisent-python-EXPANDING-block t))
487 (semantic-parse-region
488 (car $region1)
489 (cdr $region1)
490 'function_parameters 1))))
491 (function_parameters
492 ((LPAREN)
493 nil)
494 ((RPAREN)
495 nil)
496 ((function_parameter COMMA))
497 ((function_parameter RPAREN)))
498 (function_parameter
499 ((fpdef_opt_test))
500 ((MULT NAME)
501 (wisent-raw-tag
502 (semantic-tag-new-variable $2 nil nil)))
503 ((EXPONENT NAME)
504 (wisent-raw-tag
505 (semantic-tag-new-variable $2 nil nil))))
506 (class_declaration
507 ((CLASS NAME paren_class_list_opt COLON suite)
508 (wisent-raw-tag
509 (semantic-tag-new-type $2 $1 $5
510 (cons $3 nil)))))
511 (paren_class_list_opt
512 (nil)
513 ((paren_class_list)))
514 (paren_class_list
515 ((PAREN_BLOCK)
516 (let
517 ((wisent-python-EXPANDING-block t))
518 (mapcar 'semantic-tag-name
519 (semantic-parse-region
520 (car $region1)
521 (cdr $region1)
522 'paren_classes 1)))))
523 (paren_classes
524 ((LPAREN)
525 nil)
526 ((RPAREN)
527 nil)
528 ((paren_class COMMA)
529 (wisent-raw-tag
530 (semantic-tag-new-variable $1 nil nil)))
531 ((paren_class RPAREN)
532 (wisent-raw-tag
533 (semantic-tag-new-variable $1 nil nil))))
534 (paren_class
535 ((dotted_name)))
536 (test
537 ((test_test))
538 ((lambdef)))
539 (test_test
540 ((and_test))
541 ((test_test OR and_test)
542 nil))
543 (and_test
544 ((not_test))
545 ((and_test AND not_test)
546 nil))
547 (not_test
548 ((NOT not_test)
549 nil)
550 ((comparison)))
551 (comparison
552 ((expr))
553 ((comparison comp_op expr)
554 nil))
555 (comp_op
556 ((LT))
557 ((GT))
558 ((EQ))
559 ((GE))
560 ((LE))
561 ((LTGT))
562 ((NE))
563 ((IN))
564 ((NOT IN))
565 ((IS))
566 ((IS NOT)))
567 (expr
568 ((xor_expr))
569 ((expr BAR xor_expr)
570 nil))
571 (xor_expr
572 ((and_expr))
573 ((xor_expr HAT and_expr)
574 nil))
575 (and_expr
576 ((shift_expr))
577 ((and_expr AMP shift_expr)
578 nil))
579 (shift_expr
580 ((arith_expr))
581 ((shift_expr shift_expr_operators arith_expr)
582 nil))
583 (shift_expr_operators
584 ((LTLT))
585 ((GTGT)))
586 (arith_expr
587 ((term))
588 ((arith_expr plus_or_minus term)
589 nil))
590 (plus_or_minus
591 ((PLUS))
592 ((MINUS)))
593 (term
594 ((factor))
595 ((term term_operator factor)
596 nil))
597 (term_operator
598 ((MULT))
599 ((DIV))
600 ((MOD))
601 ((DIVDIV)))
602 (factor
603 ((prefix_operators factor)
604 nil)
605 ((power)))
606 (prefix_operators
607 ((PLUS))
608 ((MINUS))
609 ((TILDE)))
610 (power
611 ((atom trailer_zom exponent_zom)
612 (concat $1
613 (if $2
614 (concat " " $2 " ")
615 "")
616 (if $3
617 (concat " " $3)
618 ""))))
619 (trailer_zom
620 (nil)
621 ((trailer_zom trailer)
622 nil))
623 (exponent_zom
624 (nil)
625 ((exponent_zom EXPONENT factor)
626 nil))
627 (trailer
628 ((PAREN_BLOCK)
629 nil)
630 ((BRACK_BLOCK)
631 nil)
632 ((PERIOD NAME)
633 nil))
634 (atom
635 ((PAREN_BLOCK)
636 nil)
637 ((BRACK_BLOCK)
638 nil)
639 ((BRACE_BLOCK)
640 nil)
641 ((BACKQUOTE testlist BACKQUOTE)
642 nil)
643 ((NAME))
644 ((NUMBER_LITERAL))
645 ((one_or_more_string)))
646 (test_list_opt
647 (nil)
648 ((testlist)
649 nil))
650 (testlist
651 ((comma_sep_test_list comma_opt)))
652 (comma_sep_test_list
653 ((test))
654 ((comma_sep_test_list COMMA test)
655 (format "%s, %s" $1 $3)))
656 (one_or_more_string
657 ((STRING_LITERAL))
658 ((one_or_more_string STRING_LITERAL)
659 (concat $1 $2)))
660 (lambdef
661 ((LAMBDA varargslist_opt COLON test)
662 (format "%s %s" $1
663 (or $2 ""))))
664 (varargslist_opt
665 (nil)
666 ((varargslist)))
667 (varargslist
668 ((fpdef_opt_test_list_comma_zom rest_args)
669 (nconc $2 $1))
670 ((fpdef_opt_test_list comma_opt)))
671 (rest_args
672 ((MULT NAME multmult_name_opt)
673 nil)
674 ((EXPONENT NAME)
675 nil))
676 (multmult_name_opt
677 (nil)
678 ((COMMA EXPONENT NAME)
679 (wisent-raw-tag
680 (semantic-tag-new-variable $3 nil nil))))
681 (fpdef_opt_test_list_comma_zom
682 (nil)
683 ((fpdef_opt_test_list_comma_zom fpdef_opt_test COMMA)
684 (nconc $2 $1)))
685 (fpdef_opt_test_list
686 ((fpdef_opt_test))
687 ((fpdef_opt_test_list COMMA fpdef_opt_test)
688 (nconc $3 $1)))
689 (fpdef_opt_test
690 ((fpdef eq_test_opt)))
691 (fpdef
692 ((NAME)
693 (wisent-raw-tag
694 (semantic-tag-new-variable $1 nil nil))))
695 (fplist
696 ((fpdef_list comma_opt)))
697 (fpdef_list
698 ((fpdef))
699 ((fpdef_list COMMA fpdef)))
700 (eq_test_opt
701 (nil)
702 ((ASSIGN test)
703 nil))
704 (comma_opt
705 (nil)
706 ((COMMA)))
707 (semicolon_opt
708 (nil)
709 ((SEMICOLON))))
710 '(goal function_parameter paren_class indented_block function_parameters paren_classes indented_block_body)))
711 "Parser table.")
712
713 (defun wisent-python-wy--install-parser ()
714 "Setup the Semantic Parser."
715 (semantic-install-function-overrides
716 '((parse-stream . wisent-parse-stream)))
717 (setq semantic-parser-name "LALR"
718 semantic--parse-table wisent-python-wy--parse-table
719 semantic-debug-parser-source "python.wy"
720 semantic-flex-keywords-obarray wisent-python-wy--keyword-table
721 semantic-lex-types-obarray wisent-python-wy--token-table)
722 ;; Collect unmatched syntax lexical tokens
723 (semantic-make-local-hook 'wisent-discarding-token-functions)
724 (add-hook 'wisent-discarding-token-functions
725 'wisent-collect-unmatched-syntax nil t))
726
727 \f
728 ;;; Analyzers
729
730 (define-lex-block-type-analyzer wisent-python-wy--<block>-block-analyzer
731 "block analyzer for <block> tokens."
732 "\\s(\\|\\s)"
733 '((("(" LPAREN PAREN_BLOCK)
734 ("{" LBRACE BRACE_BLOCK)
735 ("[" LBRACK BRACK_BLOCK))
736 (")" RPAREN)
737 ("}" RBRACE)
738 ("]" RBRACK))
739 )
740
741 (define-lex-string-type-analyzer wisent-python-wy--<punctuation>-string-analyzer
742 "string analyzer for <punctuation> tokens."
743 "\\(\\s.\\|\\s$\\|\\s'\\)+"
744 '((BACKQUOTE . "`")
745 (ASSIGN . "=")
746 (COMMA . ",")
747 (SEMICOLON . ";")
748 (COLON . ":")
749 (BAR . "|")
750 (TILDE . "~")
751 (PERIOD . ".")
752 (MINUS . "-")
753 (PLUS . "+")
754 (MOD . "%")
755 (DIV . "/")
756 (MULT . "*")
757 (AMP . "&")
758 (GT . ">")
759 (LT . "<")
760 (HAT . "^")
761 (NE . "!=")
762 (LTGT . "<>")
763 (HATEQ . "^=")
764 (OREQ . "|=")
765 (AMPEQ . "&=")
766 (MODEQ . "%=")
767 (DIVEQ . "/=")
768 (MULTEQ . "*=")
769 (MINUSEQ . "-=")
770 (PLUSEQ . "+=")
771 (LE . "<=")
772 (GE . ">=")
773 (EQ . "==")
774 (EXPONENT . "**")
775 (GTGT . ">>")
776 (LTLT . "<<")
777 (DIVDIV . "//")
778 (DIVDIVEQ . "//=")
779 (EXPEQ . "**=")
780 (GTGTEQ . ">>=")
781 (LTLTEQ . "<<="))
782 'punctuation)
783
784 (define-lex-regex-type-analyzer wisent-python-wy--<symbol>-regexp-analyzer
785 "regexp analyzer for <symbol> tokens."
786 "\\(\\sw\\|\\s_\\)+"
787 nil
788 'NAME)
789
790 (define-lex-regex-type-analyzer wisent-python-wy--<number>-regexp-analyzer
791 "regexp analyzer for <number> tokens."
792 semantic-lex-number-expression
793 nil
794 'NUMBER_LITERAL)
795
796 (define-lex-keyword-type-analyzer wisent-python-wy--<keyword>-keyword-analyzer
797 "keyword analyzer for <keyword> tokens."
798 "\\(\\sw\\|\\s_\\)+")
799
800 \f
801 ;;; Epilogue
802 ;;
803
804 (provide 'semantic/wisent/python-wy)
805
806 ;;; semantic/wisent/python-wy.el ends here