[antlr-interest] python grammar(s)

alexander krohn 12345alex at gmx.net
Thu Apr 3 13:12:29 PDT 2008


(sorry, i've sent this directly)

hi, johannes.

Johannes Luber schrieb:
> alexander krohn schrieb:
>> [...]
>> there are some more things python does not accept, while the antlr 
>> grammars do. how comes?
>>
>> are these just meant as examples?
>
> My theory is that the ANTLR python grammars are supersets over the 
> specification on python.org. Such grammar definitions tend to include 
> semantic limitations, which could be included in BNF form, but make it 
> more difficult to create good error diagnostics from. The solution is 
> then to do a second pass which filters the wrong semantics out.
>
> Johannes
>
can you explain what you mean by "semantic limitations"?

what would the second pass look like? what grammar should it use? a tree 
grammar maybe?

i want to do a mostly complete transformation using a heterogenous ast 
build by using rule arguments and return values. this puts more stuff to 
the rules than using rewrite rules but the result is really nice.

regards

alexander


More information about the antlr-interest mailing list