grammar question

Martin v. Loewis martin at v.loewis.de
Wed Feb 27 03:55:34 EST 2002


Fernando Pereira <pereira at cis.upenn.edu> writes:

> > arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**'
> > test)
> 
> This production cannot be disambiguated top-down with *any* lookahead, for
> the reason you suggest. 

There is no reason to disambiguate anything here: this is a single
non-terminal. It has a first set of firstset(argument) \/ {'*', '**'}.

Notice that, because it just uses a regular syntax on the right-hand
side, there definitely is a deterministic finite automaton that
accepts precisely the words defined by the regular expression
(assuming, for the moment, that argument and test are tokens). For the
same reason, this production, in itself, defines a LL(1) language.

> Thus, it doesn't seem Python's grammar is LL(1). 

You definitely cannot conclude this statement from the above
production.

Regards,
Martin



More information about the Python-list mailing list