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

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

`

37

37

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

`

38

38

`small_stmt: (expr_stmt | del_stmt | pass_stmt | flow_stmt |

`

39

39

` 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))* [',']

`

42

43

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

`

43

44

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

`

44

45

`# For normal assignments, additional restrictions enforced by the interpreter

`

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

`

86

87

`or_test: and_test ('or' and_test)*

`

87

88

`and_test: not_test ('and' not_test)*

`

88

89

`not_test: 'not' not_test | comparison

`

89

``

`-

comparison: star_expr (comp_op star_expr)*

`

``

90

`+

comparison: expr (comp_op expr)*

`

90

91

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

`

91

``

`-

star_expr: ['*'] expr

`

``

92

`+

star_expr: '*' expr

`

92

93

`expr: xor_expr ('|' xor_expr)*

`

93

94

`xor_expr: and_expr ('^' and_expr)*

`

94

95

`and_expr: shift_expr ('&' shift_expr)*

`

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

`

101

102

` '[' [testlist_comp] ']' |

`

102

103

` '{' [dictorsetmaker] '}' |

`

103

104

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

`

104

``

`-

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

`

``

105

`+

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

`

105

106

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

`

106

107

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

`

107

108

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

`

108

109

`sliceop: ':' [test]

`

109

``

`-

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

`

``

110

`+

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

`

110

111

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

`

111

112

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

`

112

113

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

`

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

`

123

124

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

`

124

125

`comp_if: 'if' test_nocond [comp_iter]

`

125

126

``

126

``

`-

testlist1: test (',' test)*

`

127

``

-

128

127

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

`

129

128

`encoding_decl: NAME

`

130

129

``