[antlr-interest] copy a tree in c

Stefan Lind stefan.lind at googlemail.com
Thu Oct 21 17:26:15 PDT 2010


Hi,
I am trying to copy a part of a tree with the goal to evaluate this part to
a later point. I wasn't able to find any tutorials or posts which describes
a solution for my problem so i hope you can help me.
The most promising function i found is the dupTree() function from the
pANTLR_BASE_TREE which i used as follows:
pANTLR3_BASE_TREE pBaseTree = (pANTLR3_BASE_TREE)
FUNCTION_DEF10->dupTree(FUNCTION_DEF10);
Then i tryed to reuse the tree pBaseTree to a later point but it failed
already when i used the toStringTree() function on it.
std::string treeString = (const char*)
pBaseTree->toStringTree(pBaseTree)->chars;
The output of the string treeString is nil. Between the dupTree() and
toStringTree(), antlr continues to evaluate the tree.
When i call the toStringTree() function right after the dupTree() call, it
delivers the correct ouput.

Does anyone see my mistake, or has any suggestion where i can find help?

Regards,
Stefan


More information about the antlr-interest mailing list