[antlr-interest] Tree rewriting -- adding subtrees

The Researcher researcher0x00 at gmail.com
Thu Apr 14 06:59:07 PDT 2011


It's nice to know others have the same problems as me.

Since you are in this realm, other things to watch out for are

1. Don't rely on ToStringTree() alone. My current version is modified to
return the token type value and token type name. If you hit a bug an the
match does not work as expected, you will need to see the token type and
this is when the modified ToStringTree() will come in handy.

2. I am still teaching myself on this one so take with a grain of salt, but
the trees are not true trees, they are also tokens streams. When
constructing a new tree, not only do you have to build as a tree but also as
a list of tokens. Problems with xxx.HasNext() tipped me off to look at this.
I plan on spending this morning building a set of test grammars to build
tree items: empty, single item, list, and tree.

Basically don't fall into the what you believe or expect to be true vs what
is true trap.

If you learn something or something I stated is incorrect please update.

Thanks, Eric


More information about the antlr-interest mailing list