[antlr-interest] How to change AST node order in Java ?
Benjamin Niemann
pink at odahoda.de
Mon Nov 12 23:52:14 PST 2007
Hi,
Jaak Niit wrote:
> Is there solution to change AST node order in Java ?
>
> If current node have children A, B, C, D and I want to change order to
> A, D, B, C.
> BaseTree has methods deleteChild(int i) and addChild(Tree t),
> but addChild(int offset, Tree t) is missing.
>
> I want to write something like
> BaseTree D = t.getChild(3);
> t.deleteChild(3);
> t.addChild(1,D);
>
> So problem is how to add node in middle of list.
The API has been extended in the (not yet release) 3.1 release and
should provide what you need (or you may be able to achieve what you
want by using tree rewriting...).
You may either wait till it is available, or, if you are brave enough,
fetch the latest daily build from <http://www.antlr.org/download/build/>
and give it a try.
HTH
More information about the antlr-interest
mailing list