[antlr-interest] Heterogeneous tree nodes question

micha micha-1 at fantasymail.de
Mon Feb 9 07:42:37 PST 2009


in this docu:

http://www.antlr.org/wiki/display/ANTLR3/Tree+construction#Treeconstruction-
treegrammarAST

there is as sample on how to use the node token option to indicate node types 
for parsers and tree parsers.

I've tried this and the parser allocates my new class correctly, but how do I 
access the class in the treeparser?
the parser generates the following tree node (Fub is my new class):
root_1 = (CommonTree)adaptor.becomeRoot(new Fub(ADDRESS, 
(arg!=null)?arg.data:null)), root_1);

So the Fub is generated, but in the Treeparser the Fub ist lost, even if I 
write the rule as follows:

test: ^ADDRESS<Fub> ...  {
	   //where is my Fub data?
	}
	;

it seems, that in the treeparser the <Fub> is lost...

cheers
 Michael




More information about the antlr-interest mailing list