"Chad Whitacre" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I've been playing around with the parser module, and based on the 
> documentation I would expect all symbols in a parse tree to be part of 
> the grammar.[1] For example, I find this line in the symbol module docs:
>
>   Refer to the file Grammar/Grammar in the Python distribution for the
>   definitions of the names in the context of the language grammar.[2]
>
> However, the program below gives me a human-readable parse tree (also 
> below) that contains symbols that don't seem to be in the grammar, e.g., 
> small_stmt, expr_stmt, factor. Is my expectation wrong?

Did you not find them in grammar.txt, which you referenced, or 
Grammar/Grammar is the source, which you did not.  Guido has said that the 
grammar in the ref manual, meant for human consumption, is equivalent to 
but not quite the same as the grammar used to generate the parser, which 
has to meet LL1 constraints.

> [1] http://python.org/doc/ref/grammar.txt
> [2] http://python.org/doc/lib/module-symbol.html

Terry J. Reedy



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to