[antlr-interest] heterogeneous nodes and tree rewriting

michael micha-1 at fantasymail.de
Thu Oct 8 07:54:01 PDT 2009


I have a tree parser which output a new ast (tree rewriting).
The parser has attached some NodeData to some tree nodes, and one of my tree 
rewrite rules should just copy this node, like:

rule_x: NODE<NodeData> ; /* should copy NodeData, but doesn't */

If I do this then the node data is not duplicated.
If have to do:
rule_x: NODE {
	NodeData d = (NodeData)$NODE;
	} -> NODE<NodeData>[d]
;


I thought the incoming data is copied in case of an empty rule (see 
Tree construction during tree parsing in
http://www.antlr.org/wiki/display/ANTLR3/Tree+construction ) ??

cheers
 Michael

 


More information about the antlr-interest mailing list