[antlr-interest] Strategy for Java AST rewrite

Brendon McLean antlr at twistedprotein.com
Tue Dec 4 13:31:26 PST 2007


Thanks John.  You've gotten further than I have and you've gotten  
around some issues that I've run into (I had to use scoped variables  
for some hoisted predicates).  I'll try and integrate anything useful  
from my work if I find anything.  At the very least, perhaps I can  
fix an error or two that you've picked up from the original grammar.

Thanks again for sharing your work.

Regards,
Brendon.

On 4 Dec 2007, at 19:55, John Ridgway wrote:

> 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
>
>
> <JavaAST.g>
>
>
>
> 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