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

Angelo zerr angelo.zerr at gmail.com
Mon May 21 02:13:35 PDT 2007


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070521/f526b968/attachment.html 


More information about the antlr-interest mailing list