[antlr-interest] Custom data in ANTLR3_BASE_TREE in C runtime

Elvis Presley elvis at greentab.net
Thu May 6 10:11:58 PDT 2010


I'm using the ANTLR3 C runtime and I'd like to be able to add custom data to
my AST.  I see there is a "u" field in the ANTLR3_BASE_TREE, which I would
like to use to point to my own struct that contains the data I need for that
node in the tree.  My problem is that it doesn't look like "u" is ever
initialized to NULL so I don't have a way to determine if I need to allocate
new memory for my struct or not.

I can't quite figure out by looking at the code if there is a way to
override the behavior in ANTLR3_BASE_TREE or in the adaptor so that I can
always guarantee that "u" is always NULL or points to one of my custom
structs.   Any help here would be appreciated.  Thanks

--Bryce


More information about the antlr-interest mailing list