From: Gregory P. Smith ext:(%20%5BGoogle%20Inc.%5D) Date: Sat, 10 Sep 2016 01:19:51 +0000 (-0700) Subject: Issue #25969: Update the lib2to3 grammar to handle the unpacking X-Git-Tag: v3.6.0b1~132 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b822d6c89ac6dffe5304adf0ce77c2d42406338;p=python Issue #25969: Update the lib2to3 grammar to handle the unpacking generalizations added in 3.5. --- 3b822d6c89ac6dffe5304adf0ce77c2d42406338 diff --cc Lib/lib2to3/Grammar.txt index dcdd02d662,88f7884b5a..2f02e6f07c --- a/Lib/lib2to3/Grammar.txt +++ b/Lib/lib2to3/Grammar.txt @@@ -144,13 -145,22 +146,22 @@@ dictsetmaker: ( ((test ':' test | '**' classdef: 'class' NAME ['(' [arglist] ')'] ':' suite - arglist: (argument ',')* (argument [','] - |'*' test (',' argument)* [',' '**' test] - |'**' test) - argument: test [comp_for] | test '=' test # Really [keyword '='] test + arglist: argument (',' argument)* [','] + + # "test '=' test" is really "keyword '=' test", but we have no such token. + # These need to be in a single rule to avoid grammar that is ambiguous + # to our LL(1) parser. Even though 'test' includes '*expr' in star_expr, + # we explicitly match '*' here, too, to give it proper precedence. + # Illegal combinations and orderings are blocked in ast.c: + # multiple (test comp_for) arguements are blocked; keyword unpackings + # that precede iterable unpackings are blocked; etc. + argument: ( test [comp_for] | + test '=' test | + '**' expr | + star_expr ) comp_iter: comp_for | comp_if -comp_for: 'for' exprlist 'in' testlist_safe [comp_iter] +comp_for: [ASYNC] 'for' exprlist 'in' testlist_safe [comp_iter] comp_if: 'if' old_test [comp_iter] testlist1: test (',' test)*