@@ -32,17 +32,23 @@ decorator: '@' dotted_name [ '(' [arglist] ')' ] NEWLINE
3232decorators: decorator+
3333funcdef: [decorators] 'def' NAME parameters ':' suite
3434parameters: '(' [varargslist] ')'
35- varargslist: (fpdef ['=' test] ',')* ('*' NAME [',' '**' NAME] | '**' NAME) | fpdef ['=' test] (',' fpdef ['=' test])* [',']
35+ varargslist: ((fpdef ['=' test] ',')*
36+ ('*' NAME [',' '**' NAME] | '**' NAME) |
37+ fpdef ['=' test] (',' fpdef ['=' test])* [','])
3638fpdef: NAME | '(' fplist ')'
3739fplist: fpdef (',' fpdef)* [',']
3840
3941stmt: simple_stmt | compound_stmt
4042simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE
41- small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt
42- expr_stmt: testlist (augassign (yield_expr|testlist) | ('=' (yield_expr|testlist))*)
43- augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' | '<<=' | '>>=' | '**=' | '//='
43+ small_stmt: (expr_stmt | print_stmt | del_stmt | pass_stmt | flow_stmt |
44+ import_stmt | global_stmt | exec_stmt | assert_stmt)
45+ expr_stmt: testlist (augassign (yield_expr|testlist) |
46+ ('=' (yield_expr|testlist))*)
47+ augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |
48+ '<<=' | '>>=' | '**=' | '//=')
4449# For normal assignments, additional restrictions enforced by the interpreter
45- print_stmt: 'print' ( [ test (',' test)* [','] ] | '>>' test [ (',' test)+ [','] ] )
50+ print_stmt: 'print' ( [ test (',' test)* [','] ] |
51+ '>>' test [ (',' test)+ [','] ] )
4652del_stmt: 'del' exprlist
4753pass_stmt: 'pass'
4854flow_stmt: break_stmt | continue_stmt | return_stmt | raise_stmt | yield_stmt
@@ -53,7 +59,8 @@ yield_stmt: yield_expr
5359raise_stmt: 'raise' [test [',' test [',' test]]]
5460import_stmt: import_name | import_from
5561import_name: 'import' dotted_as_names
56- import_from: 'from' dotted_name 'import' ('*' | '(' import_as_names ')' | import_as_names)
62+ import_from: ('from' ('.')* dotted_name
63+ 'import' ('*' | '(' import_as_names ')' | import_as_names))
5764import_as_name: NAME [NAME NAME]
5865dotted_as_name: dotted_name [NAME NAME]
5966import_as_names: import_as_name (',' import_as_name)* [',']
@@ -67,7 +74,11 @@ compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
6774if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
6875while_stmt: 'while' test ':' suite ['else' ':' suite]
6976for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
70- try_stmt: 'try' ':' suite ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite] | 'finally' ':' suite)
77+ try_stmt: ('try' ':' suite
78+ ((except_clause ':' suite)+
79+ ['else' ':' suite]
80+ ['finally' ':' suite] |
81+ 'finally' ':' suite))
7182# NB compile.c makes sure that the default except clause is last
7283except_clause: 'except' [test [',' test]]
7384suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
@@ -85,7 +96,11 @@ arith_expr: term (('+'|'-') term)*
8596term: factor (('*'|'/'|'%'|'//') factor)*
8697factor: ('+'|'-'|'~') factor | power
8798power: atom trailer* ['**' factor]
88- atom: '(' [yield_expr|testlist_gexp] ')' | '[' [listmaker] ']' | '{' [dictmaker] '}' | '`' testlist1 '`' | NAME | NUMBER | STRING+
99+ atom: ('(' [yield_expr|testlist_gexp] ')' |
100+ '[' [listmaker] ']' |
101+ '{' [dictmaker] '}' |
102+ '`' testlist1 '`' |
103+ NAME | NUMBER | STRING+)
89104listmaker: test ( list_for | (',' test)* [','] )
90105testlist_gexp: test ( gen_for | (',' test)* [','] )
91106lambdef: 'lambda' [varargslist] ':' test
@@ -117,4 +132,3 @@ testlist1: test (',' test)*
117132encoding_decl: NAME
118133
119134yield_expr: 'yield' [testlist]
120-
0 commit comments