[antlr-interest] Strategy for Java AST rewrite

Brendon McLean antlr at twistedprotein.com
Mon Dec 3 12:24:21 PST 2007


Hi,

(Disclaimer: I've checked Google and searched the mailing list but I  
can't find the answer.)

I'm writing some code that needs to create a simple AST for Java.   
The AST will be used to identify code fragments that can be modified  
in a certain way and possibly written back to the file.  I've been  
leaning towards Antlr 3 because, from what I can gather it seems  
Antlr 3 has made it considerably easier to get token offsets and  
hence modify the underlying file.  On the other hand, there is a  
working 2.7 grammar with what seems to be a well thought out AST,  
which the new grammar is lacking.

I've been working on the new grammar but have run into a few things  
which make me wonder how much real-world action it's seen.  For  
example, it can currently match the annotation:

@Broken("Default Parameter", "Illegal Parameter").

The 2.7 grammar won't let this pass.  To add to my dilemma, it is  
obviously possible to make do with Antlr 2.7 as I've seen some syntax  
highlighting projects based on it.  What I am wondering boils down to  
three questions:

1.  Is anyone else working on the Java grammar at the moment that  
would mind collaborating?
2.  Are the reasons for using ANTLR 3 compelling enough for me in my  
case?
3.  Are people using the new Java grammar for anything serious.

Regards,
Brendon McLean.


More information about the antlr-interest mailing list