grammar question

Martin v. Loewis martin at v.loewis.de
Tue Feb 26 04:32:41 EST 2002


Nick Collier <nick at src.uchicago.edu> writes:

> Anyway, I thought that the Python grammar was LL(1) compliant and
> yet when I translate the grammar into the Coco/R LL(1) parser
> generator I get lots of errors like:

[...]
> Where X and Y are productions such as arglist, etc. 

My guess is that your translation into Coco/R is incorrect. I cannot
spot any ambiguity in arglist. Considering

arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test)

it may be that, given "argument "," argument ","', it finds itself
incapable of determining whether this is the second argument belongs
to the first subexpression or the second one. For pgen, it does not
matter: this all belongs into the production arglist, and is shifted
on the right-hand side until the first token of the follow-set is
found. If you had to split this production into multiple rules to
implement the Kleene star or the parentheses, you are likely running
into problems.

Regards,
Martin



More information about the Python-list mailing list