recursion in grammar?

logistix at logistix at
Mon Dec 29 15:35:11 CET 2003

Michael Hudson <mwh at> wrote in message news:<m365fzsxtz.fsf at>...
> Stephen Horne <steve at> writes:
> > ANTLR definitely uses LL parsing. I don't know about Pythons parsing
> > engine, though I suspect it uses LR-style parsing.
> Nope, LL(1).  One thing you should note is that the grammar in the
> docs is *not* the grammar used by Python's parser generator -- that's
> Grammar/Grammar in the source distribution.  I'm not sure, but I
> suspect that the grammar in the docs is nastily ambiguous.  Certainly
> the actual Python parser lets through some stuff that get's thrown out
> in the compiler with SyntaxErrors.
> Cheers,
> mwh

Even the file Grammar/Grammar isn't quite LL(1).  It's close, but not
quite.  For example:

comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is'

Would never be able to get to the 'is' 'not' section with LL.  I
believe the parser generator straightens this out when it builds the

More information about the Python-list mailing list