diff options
| author | Bill Wohler | 2012-11-24 19:43:02 -0800 |
|---|---|---|
| committer | Bill Wohler | 2012-11-24 19:43:02 -0800 |
| commit | 5244bc019bf7376caff3bb198ff674e0ad9fb0e6 (patch) | |
| tree | 02ee1615e904771f692ec2957c79a08ae029a13d /admin/grammars/python.wy | |
| parent | 9f7e719509474e92f85955e22e57ffeebd4e96f3 (diff) | |
| parent | c07a6ded1df2f4156badc9add2953579622c3722 (diff) | |
| download | emacs-5244bc019bf7376caff3bb198ff674e0ad9fb0e6.tar.gz emacs-5244bc019bf7376caff3bb198ff674e0ad9fb0e6.zip | |
Merge from trunk.
Diffstat (limited to 'admin/grammars/python.wy')
| -rw-r--r-- | admin/grammars/python.wy | 69 |
1 files changed, 59 insertions, 10 deletions
diff --git a/admin/grammars/python.wy b/admin/grammars/python.wy index b30305ee78a..f17f41c9b1b 100644 --- a/admin/grammars/python.wy +++ b/admin/grammars/python.wy | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | ;;; python.wy -- LALR grammar for Python | 1 | ;;; python.wy -- LALR grammar for Python |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2002-2011 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2002-2012 Free Software Foundation, Inc. |
| 4 | ;; Copyright (C) 2001-2010 Python Software Foundation | 4 | ;; Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, |
| 5 | ;; 2009, 2010 Python Software Foundation; All Rights Reserved | ||
| 5 | 6 | ||
| 6 | ;; Author: Richard Kim <ryk@dspwiz.com> | 7 | ;; Author: Richard Kim <ryk@dspwiz.com> |
| 7 | ;; Maintainer: Richard Kim <ryk@dspwiz.com> | 8 | ;; Maintainer: Richard Kim <ryk@dspwiz.com> |
| @@ -87,6 +88,12 @@ | |||
| 87 | ;; -------- | 88 | ;; -------- |
| 88 | 89 | ||
| 89 | %package wisent-python-wy | 90 | %package wisent-python-wy |
| 91 | %provide semantic/wisent/python-wy | ||
| 92 | |||
| 93 | %{ | ||
| 94 | (declare-function wisent-python-reconstitute-function-tag "semantic/wisent/python") | ||
| 95 | (declare-function wisent-python-reconstitute-class-tag "semantic/wisent/python") | ||
| 96 | } | ||
| 90 | 97 | ||
| 91 | %languagemode python-mode | 98 | %languagemode python-mode |
| 92 | 99 | ||
| @@ -172,6 +179,7 @@ | |||
| 172 | %token <punctuation> COMMA "," | 179 | %token <punctuation> COMMA "," |
| 173 | %token <punctuation> ASSIGN "=" | 180 | %token <punctuation> ASSIGN "=" |
| 174 | %token <punctuation> BACKQUOTE "`" | 181 | %token <punctuation> BACKQUOTE "`" |
| 182 | %token <punctuation> AT "@" | ||
| 175 | 183 | ||
| 176 | 184 | ||
| 177 | ;; ----------------- | 185 | ;; ----------------- |
| @@ -306,6 +314,10 @@ | |||
| 306 | %put WHILE summary | 314 | %put WHILE summary |
| 307 | "Start a 'while' loop" | 315 | "Start a 'while' loop" |
| 308 | 316 | ||
| 317 | %keyword WITH "with" | ||
| 318 | %put WITH summary | ||
| 319 | "Start statement with an associated context object" | ||
| 320 | |||
| 309 | %keyword YIELD "yield" | 321 | %keyword YIELD "yield" |
| 310 | %put YIELD summary | 322 | %put YIELD summary |
| 311 | "Create a generator function" | 323 | "Create a generator function" |
| @@ -544,8 +556,10 @@ import_stmt | |||
| 544 | 556 | ||
| 545 | ;; dotted_as_name (',' dotted_as_name)* | 557 | ;; dotted_as_name (',' dotted_as_name)* |
| 546 | dotted_as_name_list | 558 | dotted_as_name_list |
| 547 | : dotted_as_name | 559 | : dotted_as_name_list COMMA dotted_as_name |
| 548 | | dotted_as_name_list COMMA dotted_as_name | 560 | (cons $3 $1) |
| 561 | | dotted_as_name | ||
| 562 | (list $1) | ||
| 549 | ; | 563 | ; |
| 550 | 564 | ||
| 551 | ;; ('*' | import_as_name (',' import_as_name)*) | 565 | ;; ('*' | import_as_name (',' import_as_name)*) |
| @@ -648,6 +662,7 @@ compound_stmt | |||
| 648 | | while_stmt | 662 | | while_stmt |
| 649 | | for_stmt | 663 | | for_stmt |
| 650 | | try_stmt | 664 | | try_stmt |
| 665 | | with_stmt | ||
| 651 | | funcdef | 666 | | funcdef |
| 652 | | class_declaration | 667 | | class_declaration |
| 653 | ; | 668 | ; |
| @@ -755,13 +770,46 @@ zero_one_or_two_test | |||
| 755 | ; | 770 | ; |
| 756 | 771 | ||
| 757 | ;;;============================================================================ | 772 | ;;;============================================================================ |
| 773 | ;;@@ with_stmt | ||
| 774 | ;;;============================================================================ | ||
| 775 | |||
| 776 | ;; with_stmt: 'with' test [ with_var ] ':' suite | ||
| 777 | with_stmt | ||
| 778 | : WITH test COLON suite | ||
| 779 | (CODE-TAG $1 nil) | ||
| 780 | | WITH test with_var COLON suite | ||
| 781 | (CODE-TAG $1 nil) ;; TODO capture variable | ||
| 782 | ; | ||
| 783 | |||
| 784 | with_var | ||
| 785 | : AS expr | ||
| 786 | () ;; TODO capture | ||
| 787 | ; | ||
| 788 | |||
| 789 | ;;;============================================================================ | ||
| 758 | ;;;@@ funcdef | 790 | ;;;@@ funcdef |
| 759 | ;;;============================================================================ | 791 | ;;;============================================================================ |
| 760 | 792 | ||
| 761 | ;; funcdef: 'def' NAME parameters ':' suite | 793 | decorator |
| 794 | : AT dotted_name varargslist_opt NEWLINE | ||
| 795 | (FUNCTION-TAG $2 "decorator" $3) | ||
| 796 | ; | ||
| 797 | |||
| 798 | decorators | ||
| 799 | : decorator | ||
| 800 | (list $1) | ||
| 801 | | decorator decorators | ||
| 802 | (cons $1 $2) | ||
| 803 | ; | ||
| 804 | |||
| 805 | ;; funcdef: [decorators] 'def' NAME parameters ':' suite | ||
| 762 | funcdef | 806 | funcdef |
| 763 | : DEF NAME function_parameter_list COLON suite | 807 | : DEF NAME function_parameter_list COLON suite |
| 764 | (FUNCTION-TAG $2 nil $3) | 808 | (wisent-python-reconstitute-function-tag |
| 809 | (FUNCTION-TAG $2 nil $3) $5) | ||
| 810 | | decorators DEF NAME function_parameter_list COLON suite | ||
| 811 | (wisent-python-reconstitute-function-tag | ||
| 812 | (FUNCTION-TAG $3 nil $4 :decorators $1) $6) | ||
| 765 | ; | 813 | ; |
| 766 | 814 | ||
| 767 | function_parameter_list | 815 | function_parameter_list |
| @@ -797,10 +845,11 @@ function_parameter | |||
| 797 | ;; classdef: 'class' NAME ['(' testlist ')'] ':' suite | 845 | ;; classdef: 'class' NAME ['(' testlist ')'] ':' suite |
| 798 | class_declaration | 846 | class_declaration |
| 799 | : CLASS NAME paren_class_list_opt COLON suite | 847 | : CLASS NAME paren_class_list_opt COLON suite |
| 800 | (TYPE-TAG $2 $1 ;; Name "class" | 848 | (wisent-python-reconstitute-class-tag |
| 801 | $5 ;; Members | 849 | (TYPE-TAG $2 $1 ;; Name "class" |
| 802 | (cons $3 nil) ;; (SUPERCLASSES . INTERFACES) | 850 | $5 ;; Members |
| 803 | ) | 851 | (cons $3 nil) ;; (SUPERCLASSES . INTERFACES) |
| 852 | )) | ||
| 804 | ; | 853 | ; |
| 805 | 854 | ||
| 806 | ;; ['(' testlist ')'] | 855 | ;; ['(' testlist ')'] |