[antlr-interest] can a tree grammar and the ANTLR toolkit be used to write genrative libraries

Terence Parr parrt at jguru.com
Fri Apr 25 12:48:14 PDT 2003


On Thursday, April 24, 2003, at 05:20  PM, aaanwar wrote:

> Greetings,
>
> This is a refinement of an earlier question:
>
> What I really want to be abel to do is programatically generate code
> in say java.
>
> So I would like to do something like.
>
> CompilationUnit cu = new CompilationUnit();
> cu.addClass("HelloWorld")
>   .addMethod( "main", PUBLIC | STATIC | , VOID);
>
> and so forth ...

Hi...I have essentially what you want, but it's not ready to be 
released. :(  You want a template like creature:

method ::= <<
<access> <returnType> <name>(<args:argumentDecl()>) {
     <slist:statement()>
}
 >>

I haven't figured out what to do with StringTemplate yet and I need to 
make it work better for ANTLR stuff.  Mainly used  now to generate web 
pages for jGUru and peerscope :)

Ter
--
Co-founder, http://www.jguru.com
Creator, ANTLR Parser Generator: http://www.antlr.org
Co-founder, http://www.peerscope.com link sharing, pure-n-simple
Lecturer in Comp. Sci., University of San Francisco


 

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




More information about the antlr-interest mailing list