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