grammar question

Martin v. Loewis martin at v.loewis.de
Wed Feb 27 04:05:02 EST 2002


nick.collier at verizon.net (Nick Collier) writes:

> I now have access to the actual error message and seems as if the
> problem is with argument. So the error messages look like:
> 
>   LL1 warning in argument: NAME is  start & successor of deletable
> structure

With "argument" being

argument: [test '='] test

Apparently, when it sees a NAME, it cannot determine whether that
belongs to the first test or the second one. Since those parts of the
production are not non-terminals in themselves, there is no ambiguity;
there would be an ambiguity if the grammar read

argument: kwargument | simpleargument
kwargument: test '=' test
simpleargument: test

In that case, NAME would be in the firstsets of both kwargument and
simpleargument. If your parser generator allows you to associate
semantic actions with each "deletable structure", or creates
distinguished abstract syntax for deletable structures (instead of
creating them just for non-terminals), it would effectively rewrite
the grammar to the second form (*), making it ambiguous.

> The same errors are repeated in arglist, picking up on the errors from
> argument.  Coco\R does create a parser here, so I guess I'm whether it
> will work, after all the python one certainly works!

Notice that this is a warning only: *if* you'd attach semantic actions
in unacceptable ways, you'ld get problems.

Regards,
Martin

(*) More precisely, the rewrite would read

argument: opt_kw test
opt_kw: | test '='

in which case NAME would live both in the firstset and the followset
of opt_kw, which is an ambiguity since opt_kw is not epsilon-free.



More information about the Python-list mailing list