On Sun, Mar 8, 2009 at 2:18 PM, Nick Coghlan <ncogh...@gmail.com> wrote: > Fabio Zadrozny wrote: >> Because it is able to handle the constructs removing the ambiguity, >> and make things right semantically later on, but I don't like the idea >> of being so different from the official grammar (although I'm running >> out of choices). > > I'm not sure it is the same (or at least related) problem, but a parsing > ambiguity was also reported for the lambda varargslist in 2.x: > http://bugs.python.org/issue2009 > > I think I'd be happier with fiddling the Grammar to eliminate these > problems if Guido was to chime in as the author of pgen though... (since > pgen appears to be able to make sense of the grammar as it currently > stands, while other parsers sometimes have trouble)
To be honest I wasn't aware of this ambiguity. It seems that whoever wrote the patch for argument unpacking (a, b, *c = ...) got "lucky" with an ambiguous grammar. This surprises me, because IIRC usually pgen doesn't like ambiguities. Other parser generators usually have some way to deal with ambiguous grammars, but they also usually have features that make it unnecessary to use the exact same grammar as pgen -- for example, most parser generators are able to backtrack or look ahead more than one token, so that they can distinguish between "a = b" and "a" once the '=' token is seen, rather than having to commit to parse an expression first. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com