bpo-35224: PEP 572 Implementation (#10497) · python/cpython@8f59ee0 (original) (raw)
`@@ -69,7 +69,7 @@ assert_stmt: 'assert' test [',' test]
`
69
69
``
70
70
`compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated | async_stmt
`
71
71
`async_stmt: 'async' (funcdef | with_stmt | for_stmt)
`
72
``
`-
if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
`
``
72
`+
if_stmt: 'if' namedexpr_test ':' suite ('elif' namedexpr_test ':' suite)* ['else' ':' suite]
`
73
73
`while_stmt: 'while' test ':' suite ['else' ':' suite]
`
74
74
`for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
`
75
75
`try_stmt: ('try' ':' suite
`
`@@ -83,6 +83,7 @@ with_item: test ['as' expr]
`
83
83
`except_clause: 'except' [test ['as' NAME]]
`
84
84
`suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
`
85
85
``
``
86
`+
namedexpr_test: test [':=' test]
`
86
87
`test: or_test ['if' or_test 'else' test] | lambdef
`
87
88
`test_nocond: or_test | lambdef_nocond
`
88
89
`lambdef: 'lambda' [varargslist] ':' test
`
`@@ -108,7 +109,7 @@ atom: ('(' [yield_expr|testlist_comp] ')' |
`
108
109
` '[' [testlist_comp] ']' |
`
109
110
` '{' [dictorsetmaker] '}' |
`
110
111
` NAME | NUMBER | STRING+ | '...' | 'None' | 'True' | 'False')
`
111
``
`-
testlist_comp: (test|star_expr) ( comp_for | (',' (test|star_expr))* [','] )
`
``
112
`+
testlist_comp: (namedexpr_test|star_expr) ( comp_for | (',' (namedexpr_test|star_expr))* [','] )
`
112
113
`trailer: '(' [arglist] ')' | '[' subscriptlist ']' | '.' NAME
`
113
114
`subscriptlist: subscript (',' subscript)* [',']
`
114
115
`subscript: test | [test] ':' [test] [sliceop]
`
`@@ -134,6 +135,7 @@ arglist: argument (',' argument)* [',']
`
134
135
`# multiple (test comp_for) arguments are blocked; keyword unpackings
`
135
136
`# that precede iterable unpackings are blocked; etc.
`
136
137
`argument: ( test [comp_for] |
`
``
138
`+
test ':=' test |
`
137
139
` test '=' test |
`
138
140
` '**' test |
`
139
141
` '*' test )
`