[antlr-interest] Code munger & Simple grammar for code generation eclipse plugin Akrogen

Miguel Ping miguel.ping at gmail.com
Mon May 21 10:53:50 PDT 2007


If you're absolutely sure that you won't need a specialized grammar,
probably you can trim down an existing java grammar to suit your
needs. If you're familiar with antlr, it should be easy to do that.

As for adding grammars on the fly, you will always need to compile the
grammar. What you can do (with another generator :) is to compile the
grammar at runtime.

On 5/21/07, Angelo zerr <angelo.zerr at gmail.com> wrote:
> Hi,
> nobody is interested by my topic?
> Perhaps my explanation is very bad. If it is that, how can I do to interest
> you?
> Would you like more informations?
>
> Thank you for your answers.
>
> Regards Angelo
>
> 2007/5/21, Angelo zerr <angelo.zerr at gmail.com>:
> >
> > Hi,
> > I'm developer of code generation eclipse plugin Akrogen
> > http://akrogen.sourceforge.net/.
> > With Akrogen you describe your wizard page Eclipse with XML/XUL &
> > Javascript and you link it
> > to a template (Freemarker, Velocity, XSL,...). So it's easy to write your
> > own catalog of template.
> >
> > With Akrogen you can update properties/XML files (by keeping user
> > indentation, order of attribute,...).
> >
> > Now I would like manage updating of another file type (Java,
> > Javascript,...). Ex : wizard page generate java method and insert it
> > into java source file on the good position (into body class).
> >
> > I would like manage code munger as it's described here
> > http://www.codegeneration.net/tiki-index.php?page=CodeMungerModel
> >
> > To manage this case I would like execute 2 steps :
> > STEP 1 : . parse Java/Javascript,... file and build XML stream which
> > contains information about source file (switch grammar).
> >
> > Ex with this source Java class file :
> >
> > public class A { // <= line 1
> >
> >     /*
> >      *
> >     */
> >     public void method1() { // <= line 6
> >
> >     } // <= line 8
> > } // <= line 9
> >
> > After parsing (with anlr?), I would like obtain this XML stream :
> >
> > <sourcecode type="java">
> >    <class name="A" startLine="1" endline="9" >
> >       <method name="method1" startLine="6" endline="8" />
> >    </class>
> > </sourcecode>
> >
> > STEP 2 : Once the XML stream is obtained, you can use XPath to choose
> > where the code (generated) must be inserted
> > With XPath //class/method[last()] , you can insert generated code after
> > the last method of the class.
> >
> > STEP2 is easy but my problem comes from STEP1 (parse source file and build
> > XML stream).
> >
> > Can I manage this case with antlr? I have tried to do that, but my
> > problems are :
> >
> > 1. I would like write simple grammar just for detect method, class, fields
> > and get line number.
> >     With my test I must write the whole JAVA grammar to do that. Is it
> > possible to write simple grammar
> >     to detect start/end method, class, fields?
> >
> > 2. I would like the user of my Eclipse plugin can add another grammar. (Ex
> > : add grammar for Javascript DOJO Treeview (to add node))
> >     But with antlr, grammar must be compiled to be used. Can I use grammar
> > directly without compile the grammar into java class?
> >
> > If someone is interested with my topic or with Akrogen, don't hesitate to
> > contact me. I will happy to discuss with you.
> >
> > Thank you for your advice.
> >
> > Regards Angelo
> >
>


More information about the antlr-interest mailing list