1 ;;; wisent-python-wy.el --- Generated parser support file
3 ;; Copyright (C) 2002, 2003, 2004, 2007 Richard Kim
5 ;; Author: Eric M. Ludlam <zappo@projectile.siege-engine.com>
6 ;; Created: 2007-06-05 21:47:04-0400
8 ;; X-RCS: $Id: wisent-python-wy.el,v 1.1 2007-11-26 15:12:33 michaels Exp $
10 ;; This file is not part of GNU Emacs.
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
17 ;; This software is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
29 ;; PLEASE DO NOT MANUALLY EDIT THIS FILE! It is automatically
30 ;; generated from the grammar file wisent-python.wy.
42 (defconst wisent-python-wy--keyword-table
43 (semantic-lex-make-keyword-table
48 ("continue" . CONTINUE)
73 '(("yield" summary "Create a generator function")
74 ("while" summary "Start a 'while' loop")
75 ("try" summary "Start of statements protected by exception handlers")
76 ("return" summary "Return from a function")
77 ("raise" summary "Raise an exception")
78 ("print" summary "Print each argument to standard output")
79 ("pass" summary "Statement that does nothing")
80 ("or" summary "Binary logical 'or' operator")
81 ("not" summary "Unary boolean negation operator")
82 ("is" summary "Binary operator that tests for object equality")
83 ("in" summary "Part of 'for' statement ")
84 ("import" summary "Load specified modules")
85 ("if" summary "Start 'if' conditional statement")
86 ("global" summary "Declare one or more symbols as global symbols")
87 ("from" summary "Modify behavior of 'import' statement")
88 ("for" summary "Start a 'for' loop")
89 ("finally" summary "Specify code to be executed after 'try' statements whether or not an exception occured")
90 ("exec" summary "Dynamically execute python code")
91 ("except" summary "Specify exception handlers along with 'try' keyword")
92 ("else" summary "Start the 'else' clause following an 'if' statement")
93 ("elif" summary "Shorthand for 'else if' following an 'if' statement")
94 ("del" summary "Delete specified objects, i.e., undo what assignment did")
95 ("def" summary "Define a new function")
96 ("continue" summary "Skip to the next interation of enclosing for or whilte loop")
97 ("class" summary "Define a new class")
98 ("break" summary "Terminate 'for' or 'while loop")
99 ("assert" summary "Raise AssertionError exception if <expr> is false")
100 ("and" summary "Logical AND binary operator ... ")))
101 "Table of language keywords.")
103 (defconst wisent-python-wy--token-table
104 (semantic-lex-make-type-table
159 (BRACK_BLOCK . "(LBRACK RBRACK)")
160 (BRACE_BLOCK . "(LBRACE RBRACE)")
161 (PAREN_BLOCK . "(LPAREN RPAREN)"))
163 (INDENT_BLOCK . "(INDENT DEDENT)")
164 (DEDENT . "[^:INDENT:]")
170 '(("keyword" :declared t)
171 ("symbol" :declared t)
172 ("number" :declared t)
173 ("punctuation" :declared t)
174 ("block" :declared t)))
175 "Table of lexical tokens.")
177 (defconst wisent-python-wy--parse-table
180 (require 'wisent-comp))
181 (wisent-compile-grammar
182 '((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 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)
189 ((small_stmt_list semicolon_opt NEWLINE)))
192 ((small_stmt_list SEMICOLON small_stmt)))
204 ((PRINT print_stmt_trailer)
206 (semantic-tag-new-code $1 nil))))
210 ((GTGT test trailing_test_list_with_opt_comma_opt)
212 (trailing_test_list_with_opt_comma_opt
214 ((trailing_test_list comma_opt)
219 ((trailing_test_list COMMA test)
222 ((testlist expr_stmt_trailer)
226 (string-match "^\\(\\sw\\|\\s_\\)+$" $1))
228 (semantic-tag-new-variable $1 nil nil))
230 (semantic-tag-new-code $1 nil)))))
232 ((augassign testlist))
236 ((eq_testlist_zom ASSIGN testlist)
254 (semantic-tag-new-code $1 nil))))
256 ((expr_list comma_opt)
261 ((expr_list COMMA expr)
266 (semantic-tag-new-code $1 nil))))
276 (semantic-tag-new-code $1 nil))))
280 (semantic-tag-new-code $1 nil))))
282 ((RETURN testlist_opt)
284 (semantic-tag-new-code $1 nil))))
292 (semantic-tag-new-code $1 nil))))
294 ((RAISE zero_one_two_or_three_tests)
296 (semantic-tag-new-code $1 nil))))
297 (zero_one_two_or_three_tests
299 ((test zero_one_or_two_tests)
301 (zero_one_or_two_tests
303 ((COMMA test zero_or_one_comma_test)
305 (zero_or_one_comma_test
310 ((IMPORT dotted_as_name_list)
312 (semantic-tag-new-include $2 nil)))
313 ((FROM dotted_name IMPORT star_or_import_as_name_list)
315 (semantic-tag-new-include $2 nil))))
318 ((dotted_as_name_list COMMA dotted_as_name)))
319 (star_or_import_as_name_list
322 ((import_as_name_list)
327 ((import_as_name_list COMMA import_as_name)
330 ((NAME name_name_opt)
333 ((dotted_name name_name_opt)))
340 ((dotted_name PERIOD NAME)
341 (format "%s.%s" $1 $3)))
343 ((GLOBAL comma_sep_name_list)
345 (semantic-tag-new-code $1 nil))))
348 ((comma_sep_name_list COMMA NAME)))
350 ((EXEC expr exec_trailer)
352 (semantic-tag-new-code $1 nil))))
355 ((IN test comma_test_opt)
362 ((ASSERT test comma_test_opt)
364 (semantic-tag-new-code $1 nil))))
371 ((class_declaration)))
373 ((IF test COLON suite elif_suite_pair_list else_suite_pair_opt)
375 (semantic-tag-new-code $1 nil))))
376 (elif_suite_pair_list
378 ((elif_suite_pair_list ELIF test COLON suite)
387 ((NEWLINE indented_block)
391 (semantic-parse-region
394 'indented_block_body 1)))
403 ((WHILE test COLON suite else_suite_pair_opt)
405 (semantic-tag-new-code $1 nil))))
407 ((FOR exprlist IN testlist COLON suite else_suite_pair_opt)
409 (semantic-tag-new-code $1 nil))))
411 ((TRY COLON suite except_clause_suite_pair_list else_suite_pair_opt)
413 (semantic-tag-new-code $1 nil)))
414 ((TRY COLON suite FINALLY COLON suite)
416 (semantic-tag-new-code $1 nil))))
417 (except_clause_suite_pair_list
418 ((except_clause COLON suite)
420 ((except_clause_suite_pair_list except_clause COLON suite)
423 ((EXCEPT zero_one_or_two_test)
425 (zero_one_or_two_test
427 ((test zero_or_one_comma_test)
430 ((DEF NAME function_parameter_list COLON suite)
432 (semantic-tag-new-function $2 nil $3))))
433 (function_parameter_list
436 ((wisent-python-EXPANDING-block t))
437 (semantic-parse-region
440 'function_parameters 1))))
446 ((function_parameter COMMA))
447 ((function_parameter RPAREN)))
452 (semantic-tag-new-variable $2 nil nil)))
455 (semantic-tag-new-variable $2 nil nil))))
457 ((CLASS NAME paren_class_list_opt COLON suite)
459 (semantic-tag-new-type $2 $1 $5
461 (paren_class_list_opt
463 ((paren_class_list)))
467 ((wisent-python-EXPANDING-block t))
468 (mapcar 'semantic-tag-name
469 (semantic-parse-region
472 'paren_classes 1)))))
480 (semantic-tag-new-variable $1 nil nil)))
481 ((paren_class RPAREN)
483 (semantic-tag-new-variable $1 nil nil))))
491 ((test_test OR and_test)
495 ((and_test AND not_test)
503 ((comparison comp_op expr)
523 ((xor_expr HAT and_expr)
527 ((and_expr AMP shift_expr)
531 ((shift_expr shift_expr_operators arith_expr)
533 (shift_expr_operators
538 ((arith_expr plus_or_minus term)
545 ((term term_operator factor)
553 ((prefix_operators factor)
561 ((atom trailer_zom exponent_zom)
571 ((trailer_zom trailer)
575 ((exponent_zom EXPONENT factor)
591 ((BACKQUOTE testlist BACKQUOTE)
595 ((one_or_more_string)))
601 ((comma_sep_test_list comma_opt)))
604 ((comma_sep_test_list COMMA test)
605 (format "%s, %s" $1 $3)))
608 ((one_or_more_string STRING_LITERAL)
611 ((LAMBDA varargslist_opt COLON test)
618 ((fpdef_opt_test_list_comma_zom rest_args)
620 ((fpdef_opt_test_list comma_opt)))
622 ((MULT NAME multmult_name_opt)
628 ((COMMA EXPONENT NAME)
630 (semantic-tag-new-variable $3 nil nil))))
631 (fpdef_opt_test_list_comma_zom
633 ((fpdef_opt_test_list_comma_zom fpdef_opt_test COMMA)
637 ((fpdef_opt_test_list COMMA fpdef_opt_test)
640 ((fpdef eq_test_opt)))
644 (semantic-tag-new-variable $1 nil nil))))
646 ((fpdef_list comma_opt)))
649 ((fpdef_list COMMA fpdef)))
660 '(goal function_parameter paren_class indented_block function_parameters paren_classes indented_block_body)))
663 (defun wisent-python-wy--install-parser ()
664 "Setup the Semantic Parser."
665 (semantic-install-function-overrides
666 '((parse-stream . wisent-parse-stream)))
667 (setq semantic-parser-name "LALR"
668 semantic--parse-table wisent-python-wy--parse-table
669 semantic-debug-parser-source "wisent-python.wy"
670 semantic-flex-keywords-obarray wisent-python-wy--keyword-table
671 semantic-lex-types-obarray wisent-python-wy--token-table)
672 ;; Collect unmatched syntax lexical tokens
673 (semantic-make-local-hook 'wisent-discarding-token-functions)
674 (add-hook 'wisent-discarding-token-functions
675 'wisent-collect-unmatched-syntax nil t))
680 (require 'semantic-lex)
682 (define-lex-keyword-type-analyzer wisent-python-wy--<keyword>-keyword-analyzer
683 "keyword analyzer for <keyword> tokens."
684 "\\(\\sw\\|\\s_\\)+")
686 (define-lex-block-type-analyzer wisent-python-wy--<block>-block-analyzer
687 "block analyzer for <block> tokens."
689 '((("(" LPAREN PAREN_BLOCK)
690 ("{" LBRACE BRACE_BLOCK)
691 ("[" LBRACK BRACK_BLOCK))
697 (define-lex-regex-type-analyzer wisent-python-wy--<symbol>-regexp-analyzer
698 "regexp analyzer for <symbol> tokens."
703 (define-lex-regex-type-analyzer wisent-python-wy--<number>-regexp-analyzer
704 "regexp analyzer for <number> tokens."
705 semantic-lex-number-expression
709 (define-lex-string-type-analyzer wisent-python-wy--<punctuation>-string-analyzer
710 "string analyzer for <punctuation> tokens."
711 "\\(\\s.\\|\\s$\\|\\s'\\)+"
756 (provide 'wisent-python-wy)
758 ;;; wisent-python-wy.el ends here