[antlr-interest] Tree transformations

Tarun Khanna tarunkhanna at gmail.com
Thu Jul 14 09:24:58 PDT 2005


I guess yes. You can do something like 

E.addChild(B.getFirstChild());
and then set the child of B to NULL
B.setFirstChild(null) or B.setFirstChild(B.getFirstChild
().getNextSibling());

All you ANTLR experts, please let me know if the above procedure is correct. 
I would appreciate if you can point out the flaw as I spent a couple of days 
in trying to understand the AST stuff in ANTLR and if the above is flawed 
then I need to spend some more time.

Tarun

On 7/14/05, Jeff Dahl <jddahl at micron.com> wrote:
> 
> When transforming a tree, is it possible to move a subtree to some
> arbitrary node? For example, given the tree:
> 
> A
> |-- B
> | |-- C
> | | |-- attribute1
> | | | `-- value 1
> | | |-- attribute2
> | | | `-- value 2
> | | `-- attribute3
> | | `-- value 3
> | `-- D
> | `-- attribute4
> | `-- value 4
> |-- E
> | `-- attribute5
> | `-- value 5
> `-- F
> `-- attribute6
> `-- value 6
> 
> is it possible to move subtree "C" to subtree "E" as illustrated below?
> 
> A
> |-- B
> | `-- D
> | `-- attribute4
> | `-- value 4
> |-- E
> | |-- C
> | | |-- attribute1
> | | | `-- value 1
> | | |-- attribute2
> | | | `-- value 2
> | | `-- attribute3
> | | `-- value 3
> | `-- attribute5
> | `-- value 5
> `-- F
> `-- attribute6
> `-- value 6
> 
> Thanks,
> Jeff
> 
> 


-- 
Tarun Khanna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050714/b7878aed/attachment.html


More information about the antlr-interest mailing list