recursion in grammar?

logistix at cathoderaymission.net logistix at cathoderaymission.net
Mon Dec 29 15:35:11 CET 2003


Michael Hudson <mwh at python.net> wrote in message news:<m365fzsxtz.fsf at pc150.maths.bris.ac.uk>...
> Stephen Horne <steve at ninereeds.fsnet.co.uk> 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'
'not'

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
DFA's.




More information about the Python-list mailing list