[antlr-interest] Strategy for Java AST rewrite

John Ridgway john at jacelridge.com
Tue Dec 4 09:55:26 PST 2007


I've been working on an AST generating grammar for Java, which I  
intended to distribute when it was finished.  It's not yet finished,  
but I would certainly appreciate help and/or would be glad to help you.

What you point out is definitely an error in the grammar.

I'm attaching what I've got so far (which includes the error) so you  
can take a look at what I've done and criticize it (or trash it).

Peace
- John
Visiting Assistant Professor
Trinity College
Hartford, CT


-------------- next part --------------
A non-text attachment was scrubbed...
Name: JavaAST.g
Type: application/octet-stream
Size: 33914 bytes
Desc: not available
Url : http://www.antlr.org/pipermail/antlr-interest/attachments/20071204/94141ad2/attachment-0001.obj 
-------------- next part --------------




On Dec 3, 2007, at 3:24 PM, Brendon McLean wrote:

> 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