fix an ambiguity in the grammar from the implementation of extended u… · python/cpython@4905e80

@@ -37,8 +37,9 @@ stmt: simple_stmt | compound_stmt

3737

simple_stmt: small_stmt (';' small_stmt)* [';'] NEWLINE

3838

small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt |

3939

import_stmt | global_stmt | nonlocal_stmt | assert_stmt)

40-

expr_stmt: testlist (augassign (yield_expr|testlist) |

41-

('=' (yield_expr|testlist))*)

40+

expr_stmt: testlist_star_expr (augassign (yield_expr|testlist) |

41+

('=' (yield_expr|testlist_star_expr))*)

42+

testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']

4243

augassign: ('+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' |

4344

'<<=' | '>>=' | '**=' | '//=')

4445

# For normal assignments, additional restrictions enforced by the interpreter

@@ -86,9 +87,9 @@ lambdef_nocond: 'lambda' [varargslist] ':' test_nocond

8687

or_test: and_test ('or' and_test)*

8788

and_test: not_test ('and' not_test)*

8889

not_test: 'not' not_test | comparison

89-

comparison: star_expr (comp_op star_expr)*

90+

comparison: expr (comp_op expr)*

9091

comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'

91-

star_expr: ['*'] expr

92+

star_expr: '*' expr

9293

expr: xor_expr ('|' xor_expr)*

9394

xor_expr: and_expr ('^' and_expr)*

9495

and_expr: shift_expr ('&' shift_expr)*

@@ -101,12 +102,12 @@ atom: ('(' [yield_expr|testlist_comp] ')' |

101102

'[' [testlist_comp] ']' |

102103

'{' [dictorsetmaker] '}' |

103104

NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')

104-

testlist_comp: test ( comp_for | (',' test)* [','] )

105+

testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )

105106

trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME

106107

subscriptlist: subscript (',' subscript)* [',']

107108

subscript: test | [test] ':' [test] [sliceop]

108109

sliceop: ':' [test]

109-

exprlist: star_expr (',' star_expr)* [',']

110+

exprlist: (expr|star_expr) (',' (expr|star_expr))* [',']

110111

testlist: test (',' test)* [',']

111112

dictorsetmaker: ( (test ':' test (comp_for | (',' test ':' test)* [','])) |

112113

(test (comp_for | (',' test)* [','])) )

@@ -123,8 +124,6 @@ comp_iter: comp_for | comp_if

123124

comp_for: 'for' exprlist 'in' or_test [comp_iter]

124125

comp_if: 'if' test_nocond [comp_iter]

125126126-

testlist1: test (',' test)*

127-128127

# not used in grammar, but may appear in "node" passed from Parser to Compiler

129128

encoding_decl: NAME

130129