1 ;;; semantic/wisent/python-wy.el --- Generated parser support file
3 ;; Copyright (C) 2002-2004, 2007, 2010-2011 Free Software Foundation, Inc.
5 ;; This file is part of GNU Emacs.
7 ;; GNU Emacs is free software: you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 3 of the License, or
10 ;; (at your option) any later version.
12 ;; GNU Emacs is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 ;; This file was generated from the grammar file
23 ;; semantic/wisent/wisent-python.wy in the CEDET repository.
27 (require 'semantic
/lex
)
34 (defconst wisent-python-wy--keyword-table
35 (semantic-lex-make-keyword-table
41 ("continue" . CONTINUE
)
66 '(("yield" summary
"Create a generator function")
67 ("while" summary
"Start a 'while' loop")
68 ("try" summary
"Start of statements protected by exception handlers")
69 ("return" summary
"Return from a function")
70 ("raise" summary
"Raise an exception")
71 ("print" summary
"Print each argument to standard output")
72 ("pass" summary
"Statement that does nothing")
73 ("or" summary
"Binary logical 'or' operator")
74 ("not" summary
"Unary boolean negation operator")
75 ("lambda" summary
"Create anonymous function")
76 ("is" summary
"Binary operator that tests for object equality")
77 ("in" summary
"Part of 'for' statement ")
78 ("import" summary
"Load specified modules")
79 ("if" summary
"Start 'if' conditional statement")
80 ("global" summary
"Declare one or more symbols as global symbols")
81 ("from" summary
"Modify behavior of 'import' statement")
82 ("for" summary
"Start a 'for' loop")
83 ("finally" summary
"Specify code to be executed after 'try' statements whether or not an exception occurred")
84 ("exec" summary
"Dynamically execute Python code")
85 ("except" summary
"Specify exception handlers along with 'try' keyword")
86 ("else" summary
"Start the 'else' clause following an 'if' statement")
87 ("elif" summary
"Shorthand for 'else if' following an 'if' statement")
88 ("del" summary
"Delete specified objects, i.e., undo what assignment did")
89 ("def" summary
"Define a new function")
90 ("continue" summary
"Skip to the next iteration of enclosing 'for' or 'while' loop")
91 ("class" summary
"Define a new class")
92 ("break" summary
"Terminate 'for' or 'while' loop")
93 ("assert" summary
"Raise AssertionError exception if <expr> is false")
94 ("as" summary
"EXPR as NAME makes value of EXPR available as variable NAME")
95 ("and" summary
"Logical AND binary operator ... ")))
96 "Table of language keywords.")
98 (defconst wisent-python-wy--token-table
99 (semantic-lex-make-type-table
154 (BRACK_BLOCK .
"(LBRACK RBRACK)")
155 (BRACE_BLOCK .
"(LBRACE RBRACE)")
156 (PAREN_BLOCK .
"(LPAREN RPAREN)"))
158 (INDENT_BLOCK .
"(INDENT DEDENT)")
159 (DEDENT .
"[^:INDENT:]")
165 '(("keyword" :declared t
)
166 ("symbol" :declared t
)
167 ("number" :declared t
)
168 ("punctuation" :declared t
)
169 ("block" :declared t
)))
170 "Table of lexical tokens.")
172 (defconst wisent-python-wy--parse-table
175 (require 'semantic
/wisent
/comp
))
176 (wisent-compile-grammar
177 '((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
)
184 ((small_stmt_list semicolon_opt NEWLINE
)))
187 ((small_stmt_list SEMICOLON small_stmt
)))
199 ((PRINT print_stmt_trailer
)
201 (semantic-tag-new-code $
1 nil
))))
205 ((GTGT test trailing_test_list_with_opt_comma_opt
)
207 (trailing_test_list_with_opt_comma_opt
209 ((trailing_test_list comma_opt
)
214 ((trailing_test_list COMMA test
)
217 ((testlist expr_stmt_trailer
)
221 (string-match "^\\(\\sw\\|\\s_\\)+$" $
1))
223 (semantic-tag-new-variable $
1 nil nil
))
225 (semantic-tag-new-code $
1 nil
)))))
227 ((augassign testlist
))
231 ((eq_testlist_zom ASSIGN testlist
)
249 (semantic-tag-new-code $
1 nil
))))
251 ((expr_list comma_opt
)
256 ((expr_list COMMA expr
)
261 (semantic-tag-new-code $
1 nil
))))
271 (semantic-tag-new-code $
1 nil
))))
275 (semantic-tag-new-code $
1 nil
))))
277 ((RETURN testlist_opt
)
279 (semantic-tag-new-code $
1 nil
))))
287 (semantic-tag-new-code $
1 nil
)))
290 (semantic-tag-new-code $
1 nil
))))
292 ((RAISE zero_one_two_or_three_tests
)
294 (semantic-tag-new-code $
1 nil
))))
295 (zero_one_two_or_three_tests
297 ((test zero_one_or_two_tests
)
299 (zero_one_or_two_tests
301 ((COMMA test zero_or_one_comma_test
)
303 (zero_or_one_comma_test
308 ((IMPORT dotted_as_name_list
)
310 (semantic-tag-new-include $
2 nil
)))
311 ((FROM dotted_name IMPORT star_or_import_as_name_list
)
313 (semantic-tag-new-include $
2 nil
))))
316 ((dotted_as_name_list COMMA dotted_as_name
)))
317 (star_or_import_as_name_list
320 ((import_as_name_list)
325 ((import_as_name_list COMMA import_as_name
)
331 ((dotted_name as_name_opt
)))
338 ((dotted_name PERIOD NAME
)
339 (format "%s.%s" $
1 $
3)))
341 ((GLOBAL comma_sep_name_list
)
343 (semantic-tag-new-code $
1 nil
))))
346 ((comma_sep_name_list COMMA NAME
)))
348 ((EXEC expr exec_trailer
)
350 (semantic-tag-new-code $
1 nil
))))
353 ((IN test comma_test_opt
)
360 ((ASSERT test comma_test_opt
)
362 (semantic-tag-new-code $
1 nil
))))
369 ((class_declaration)))
371 ((IF test COLON suite elif_suite_pair_list else_suite_pair_opt
)
373 (semantic-tag-new-code $
1 nil
))))
374 (elif_suite_pair_list
376 ((elif_suite_pair_list ELIF test COLON suite
)
385 ((NEWLINE indented_block
)
389 (semantic-parse-region
392 'indented_block_body
1)))
401 ((WHILE test COLON suite else_suite_pair_opt
)
403 (semantic-tag-new-code $
1 nil
))))
405 ((FOR exprlist IN testlist COLON suite else_suite_pair_opt
)
407 (semantic-tag-new-code $
1 nil
))))
409 ((TRY COLON suite except_clause_suite_pair_list else_suite_pair_opt
)
411 (semantic-tag-new-code $
1 nil
)))
412 ((TRY COLON suite FINALLY COLON suite
)
414 (semantic-tag-new-code $
1 nil
))))
415 (except_clause_suite_pair_list
416 ((except_clause COLON suite
)
418 ((except_clause_suite_pair_list except_clause COLON suite
)
421 ((EXCEPT zero_one_or_two_test
)
423 (zero_one_or_two_test
425 ((test zero_or_one_comma_test
)
428 ((DEF NAME function_parameter_list COLON suite
)
430 (semantic-tag-new-function $
2 nil $
3))))
431 (function_parameter_list
434 ((wisent-python-EXPANDING-block t
))
435 (semantic-parse-region
438 'function_parameters
1))))
444 ((function_parameter COMMA
))
445 ((function_parameter RPAREN
)))
450 (semantic-tag-new-variable $
2 nil nil
)))
453 (semantic-tag-new-variable $
2 nil nil
))))
455 ((CLASS NAME paren_class_list_opt COLON suite
)
457 (semantic-tag-new-type $
2 $
1 $
5
459 (paren_class_list_opt
461 ((paren_class_list)))
465 ((wisent-python-EXPANDING-block t
))
466 (mapcar 'semantic-tag-name
467 (semantic-parse-region
470 'paren_classes
1)))))
478 (semantic-tag-new-variable $
1 nil nil
)))
479 ((paren_class RPAREN
)
481 (semantic-tag-new-variable $
1 nil nil
))))
489 ((test_test OR and_test
)
493 ((and_test AND not_test
)
501 ((comparison comp_op expr
)
521 ((xor_expr HAT and_expr
)
525 ((and_expr AMP shift_expr
)
529 ((shift_expr shift_expr_operators arith_expr
)
531 (shift_expr_operators
536 ((arith_expr plus_or_minus term
)
543 ((term term_operator factor
)
551 ((prefix_operators factor
)
559 ((atom trailer_zom exponent_zom
)
569 ((trailer_zom trailer
)
573 ((exponent_zom EXPONENT factor
)
589 ((BACKQUOTE testlist BACKQUOTE
)
593 ((one_or_more_string)))
599 ((comma_sep_test_list comma_opt
)))
602 ((comma_sep_test_list COMMA test
)
603 (format "%s, %s" $
1 $
3)))
606 ((one_or_more_string STRING_LITERAL
)
609 ((LAMBDA varargslist_opt COLON test
)
616 ((fpdef_opt_test_list_comma_zom rest_args
)
618 ((fpdef_opt_test_list comma_opt
)))
620 ((MULT NAME multmult_name_opt
)
626 ((COMMA EXPONENT NAME
)
628 (semantic-tag-new-variable $
3 nil nil
))))
629 (fpdef_opt_test_list_comma_zom
631 ((fpdef_opt_test_list_comma_zom fpdef_opt_test COMMA
)
635 ((fpdef_opt_test_list COMMA fpdef_opt_test
)
638 ((fpdef eq_test_opt
)))
642 (semantic-tag-new-variable $
1 nil nil
))))
644 ((fpdef_list comma_opt
)))
647 ((fpdef_list COMMA fpdef
)))
658 '(goal function_parameter paren_class indented_block function_parameters paren_classes indented_block_body
)))
661 (defun wisent-python-wy--install-parser ()
662 "Setup the Semantic Parser."
663 (semantic-install-function-overrides
664 '((parse-stream . wisent-parse-stream
)))
665 (setq semantic-parser-name
"LALR"
666 semantic--parse-table wisent-python-wy--parse-table
667 semantic-debug-parser-source
"wisent-python.wy"
668 semantic-flex-keywords-obarray wisent-python-wy--keyword-table
669 semantic-lex-types-obarray wisent-python-wy--token-table
)
670 ;; Collect unmatched syntax lexical tokens
671 (semantic-make-local-hook 'wisent-discarding-token-functions
)
672 (add-hook 'wisent-discarding-token-functions
673 'wisent-collect-unmatched-syntax nil t
))
678 (define-lex-keyword-type-analyzer wisent-python-wy--
<keyword
>-keyword-analyzer
679 "keyword analyzer for <keyword> tokens."
680 "\\(\\sw\\|\\s_\\)+")
682 (define-lex-block-type-analyzer wisent-python-wy--
<block
>-block-analyzer
683 "block analyzer for <block> tokens."
685 '((("(" LPAREN PAREN_BLOCK
)
686 ("{" LBRACE BRACE_BLOCK
)
687 ("[" LBRACK BRACK_BLOCK
))
693 (define-lex-regex-type-analyzer wisent-python-wy--
<symbol
>-regexp-analyzer
694 "regexp analyzer for <symbol> tokens."
699 (define-lex-regex-type-analyzer wisent-python-wy--
<number
>-regexp-analyzer
700 "regexp analyzer for <number> tokens."
701 semantic-lex-number-expression
705 (define-lex-string-type-analyzer wisent-python-wy--
<punctuation
>-string-analyzer
706 "string analyzer for <punctuation> tokens."
707 "\\(\\s.\\|\\s$\\|\\s'\\)+"
752 (provide 'semantic
/wisent
/python-wy
)
754 ;;; semantic/wisent/python-wy.el ends here