[antlr-interest] Re: Is antlr the right tool for this job?

David Ryan oobles at hotmail.com
Thu Aug 19 17:10:29 PDT 2004



I think you'll find antlr would be great for this job.  Pretty much
all of the hard work has already been done for you.  There is a java
lexer/parser and AST recogniser on the antlr web site.

http://www.antlr.org/grammar/1090713067533/index.html

Use the lexer/parser to read in your Java source code into an AST. 
Then modify the AST recogniser to output the documentation you need.

I think you would add your documentation action to the method call in
primaryExpression.  There will probably be a couple of lines of fiddly
code to extract the string from the AST.

Goodluck,
David.

--- In antlr-interest at yahoogroups.com, William Bland <wjb at a...> wrote:
> Hello,
> 	I've been looking around for a while for a neat solution to a class of
> problems I have with a large chunk of Java code.  I need to be able to
> automatically generate documentation, starting by pulling certain
> literal strings out of method calls.  For example I need to be able to
> generate a list of all the literal strings that are fed to the method
> 
> 	StatsSystem.addStat(String name, Object value)
> 
> I had a look at AspectJ because someone thought it could do things like
> this, but it turns out it can't really.  My current techniques for doing
> this kind of thing involve some very messy awk/sed/grep stuff.  I'd like
> to move away from that (because it's very fragile and difficult to
> maintain) but so far I haven't found a good replacement.
> 
> It looks to me though, like antlr could be the right tool for the job. 
> If I understand correctly, I could generate an AST from our Java source,
> then walk the tree and pull out all the pieces of information I'm
> interested in.
> 
> Does this sound reasonable, or am I wanting antlr to do things it's not
> really designed for?
> 
> Thanks very much for your help.
> 
> Cheers,
> 	Bill.
> -- 
> Dr. William Bland                          www.abstractnonsense.com
> Now listening to Nothing (Media player is not running)



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

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





More information about the antlr-interest mailing list