[antlr-interest] grammars with AST support

Johannes Luber jaluber at gmx.de
Wed Feb 6 14:02:28 PST 2008


Peter Bulychev schrieb:
> Hello.
> 
> I perform research on static analysis and my tool takes on input AST 
> representation of programs.
> I want to use ANTRL to produce ASTs for different programming languages 
> (C, C++, C#, Java, Python, ...).
> Where can I get grammars which can produce AST?
> 
> I have searched http://www.antlr.org/grammar/list, but there are no 
> AST-featured grammars, which supports this ability.

Until now no one has written such grammars or finished them already. 
Reasons are:

- In case of C and C++, I don't believe that ANTLR can handle the 
preprocessor part correctly without any custom code (C# has a similar 
corner case, but its effect can be nearly ignored - or checked against 
to inform the programmer to change the code a bit)
- The tree transformation part is only possibly with ANTLR 3.1. More 
complicated need this for correct implementation.
- C++ is supposed to be hellish for compiler builders, so I don't expect 
a grammar popping up soon
- There are still ANTLR bugs, which prevent the use of some allowed 
constructs - that's the case for my own work-in-progress C# grammar.

If you like, I can send you the sources, but at best I have finished 
only 20% what is required for a full compiler.

Johannes


More information about the antlr-interest mailing list