[antlr-interest] python grammar(s)

alexander krohn 12345alex at gmx.net
Wed Apr 2 21:12:27 PDT 2008


hi.

i'm trying to use the python grammars that exist. i found one for python 
2.3 done by terence and one updated version for python 2.5 done by frank.

both versions don't match with the grammar(s) i found on python.org

some example, the del-statement:

antlr-grammars just say:
del_stmt : 'del' exprlist;

the grammar on python.org says something about

del_stmt ::= 
             "del" target_list

and for target_list:

target_list ::= 
             target ("," target)* [","]
  
target ::= 
             identifier
                | "(" target_list ")"
                | "[" target_list "]"
                | attributeref
                | subscription
                | slicing

etc.

the "target"-stuff doesn't even exist in the antlr-grammars. they would 
accept a line like
del 1 + 1
which python spits out with a SyntaxError.

there are some more things python does not accept, while the antlr 
grammars do. how comes?

are these just meant as examples?

regards

alexander

grammar links:
http://www.python.org/doc/2.3/ref/grammar.txt
http://www.python.org/doc/2.5/ref/grammar.txt


More information about the antlr-interest mailing list