[antlr-interest] Re: How to use java parser to grab expressions from source?

charlweed charlweed at yahoo.com
Thu Jul 10 17:11:19 PDT 2003


Thanks Paul.
Right now I'm going to try Jparse. I don't know how it compares to 
the beautifier, but I just spent some time geting the makefiles to 
work on windows so I'm going to try it first ;-)

Cjharlweed

--- In antlr-interest at yahoogroups.com, paul taney <paultaney at y...> 
wrote:
> charlie,
> 
> You might want to start with Andy Tripp's
> java beautifier.  It's working for me, as
> I try to emit jython.  You have to put back
> parens and semis and things that were torn off.  
> His code does that.
> 
>     http://jazillian.com/antlr/emitter.html
> 
> paul
> 
> --- charlweed <charlweed at y...> wrote:
> > To make a long story short, I have a personal
> > project to add 
> > a "replace fields with setters" function to the
> > Netbeans Java editor. 
> > All I want to do (at the moment) is be able to
> > transform Java source 
> > code by replacing instances of 
> >     someIndentifier = <expression>; 
> > with 
> >     setSomeIndentifier(<expression>);
> > For all valid expressions.
> > 
> > After much experimenting with the example Java stuff
> > in the antlr 
> > distribution, it seems that the original source is
> > not stored in the 
> > finished AST tree. 
> > Accordingly, I am currently trying to augment the
> > expression() or 
> > assignmentExpression() method in JavaRecognizer, but
> > I'm stumbling 
> > around in the dark. I tried a method to transform
> > the AST variable 
> > expression_AST back into source code by walking it
> > and it's sub 
> > nodes. However:
> > (A) the AST tree seems to be empty for the life of
> > these calls , and 
> > (B) I still can't find the original source.
> > I get the (sinking) feeling that I need to extend
> > several classes, 
> > and use them instead of the defaults, but even after
> > walking through 
> > the tutorial, I'm afraid I don't know where to start
> > for 
> > JavaRecognizer and/or JavaLexer.
> > 
> > Any tips or pointers would be very much appreciated.
> > 
> > 
> > Thank you!
> > 
> > Charlweed 
> > 
> > 
> > 
> >  
> > 
> > Your use of Yahoo! Groups is subject to
> > http://docs.yahoo.com/info/terms/ 
> > 
> > 
> 
> 
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com


 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 




More information about the antlr-interest mailing list