Flython
Terry Reedy
tjreedy at udel.edu
Mon Aug 16 14:56:29 EDT 2004
"Christopher T King" <squirrel at WPI.EDU> wrote in message
news:Pine.LNX.4.44.0408161041590.8576-100000 at ccc3.wpi.edu...
>I'm using http://docs.python.org/ref/grammar.txt as my grammar
>reference.
...
> :( Is there at least some rationale why the AST trees don't match the
> grammar definitions?
The grammar in the Ref Manual, which is collected together in the above
file, is intended and used for human comsumption. The equivalent but not
identical grammar in a source code file is intended and used for
parser-generator comsumption. It consitutes its own documentation. You
aren't the first person to trip on the difference. The rationale is that
people and parser generators 'think' differently.
I don't know whether AST trees exactly match the parser grammarr or if they
effectively follow a third form, hopefully also exactly equivalent. You
have wandered into as-yet inadequately documented internals land.
Terry J. Reedy
More information about the Python-list
mailing list