Changeset 391 for python/trunk/Grammar
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (11 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Grammar/Grammar
r2 r391 11 11 # "How to Change Python's Grammar" 12 12 13 # Commands for Kees Blom's railroad program14 #diagram:token NAME15 #diagram:token NUMBER16 #diagram:token STRING17 #diagram:token NEWLINE18 #diagram:token ENDMARKER19 #diagram:token INDENT20 #diagram:output\input python.bla21 #diagram:token DEDENT22 #diagram:output\textwidth 20.04cm\oddsidemargin 0.0cm\evensidemargin 0.0cm23 #diagram:rules24 25 13 # Start symbols for the grammar: 26 # 27 # 28 # 14 # single_input is a single interactive statement; 15 # file_input is a module or sequence of commands read from an input file; 16 # eval_input is the input for the eval() and input() functions. 29 17 # NB: compound_stmt in single_input is followed by extra NEWLINE! 30 18 single_input: NEWLINE | simple_stmt | compound_stmt NEWLINE … … 81 69 try_stmt: ('try' ':' suite 82 70 ((except_clause ':' suite)+ 83 84 85 86 with_stmt: 'with' test [ with_var ]':' suite87 with_ var: 'as' expr71 ['else' ':' suite] 72 ['finally' ':' suite] | 73 'finally' ':' suite)) 74 with_stmt: 'with' with_item (',' with_item)* ':' suite 75 with_item: test ['as' expr] 88 76 # NB compile.c makes sure that the default except clause is last 89 77 except_clause: 'except' [test [('as' | ',') test]] … … 113 101 factor: ('+'|'-'|'~') factor | power 114 102 power: atom trailer* ['**' factor] 115 atom: ('(' [yield_expr|testlist_ gexp] ')' |103 atom: ('(' [yield_expr|testlist_comp] ')' | 116 104 '[' [listmaker] ']' | 117 '{' [dict maker] '}' |105 '{' [dictorsetmaker] '}' | 118 106 '`' testlist1 '`' | 119 107 NAME | NUMBER | STRING+) 120 108 listmaker: test ( list_for | (',' test)* [','] ) 121 testlist_ gexp: test ( gen_for | (',' test)* [','] )109 testlist_comp: test ( comp_for | (',' test)* [','] ) 122 110 lambdef: 'lambda' [varargslist] ':' test 123 111 trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME … … 127 115 exprlist: expr (',' expr)* [','] 128 116 testlist: test (',' test)* [','] 129 dictmaker: test ':' test (',' test ':' test)* [','] 117 dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) | 118 (test (comp_for | (',' test)* [','])) ) 130 119 131 120 classdef: 'class' NAME ['(' [testlist] ')'] ':' suite … … 134 123 |'*' test (',' argument)* [',' '**' test] 135 124 |'**' test) 136 argument: test [gen_for] | test '=' test # Really [keyword '='] test 125 # The reason that keywords are test nodes instead of NAME is that using NAME 126 # results in an ambiguity. ast.c makes sure it's a NAME. 127 argument: test [comp_for] | test '=' test 137 128 138 129 list_iter: list_for | list_if … … 140 131 list_if: 'if' old_test [list_iter] 141 132 142 gen_iter: gen_for | gen_if143 gen_for: 'for' exprlist 'in' or_test [gen_iter]144 gen_if: 'if' old_test [gen_iter]133 comp_iter: comp_for | comp_if 134 comp_for: 'for' exprlist 'in' or_test [comp_iter] 135 comp_if: 'if' old_test [comp_iter] 145 136 146 137 testlist1: test (',' test)*
Note:
See TracChangeset
for help on using the changeset viewer.