[antlr-interest] Resetting an AST tree walker
Terence Parr
parrt at cs.usfca.edu
Thu Apr 23 11:56:35 PDT 2009
On Apr 22, 2009, at 8:17 PM, Steve Souza wrote:
> <<I don't like this at all, but I believe in the thread that you cited
> earlier someone says it is the intended behaviour.>>
> I wonder what the logic is there. One of the big benefits of a tree
> walker is to be able to repeatedly walk the nodes. I hope they
> don't remove that capability from the BufferedTreeNodeStream.
Don't worry. We will keep the buffered version for sure. The primary
reason to avoid the buffered version is when you're tree is absolutely
huge and you can afford to create a big array pointing and all the
nodes. In the new tree filter mechanism, not yet officially released
but in the software, it needs to constantly parse little snippets of
the tree. re-creating an array for each subtree doesn't make much sense.
I'm surprised by the speed difference though. I might have to rethink
my filter; that is, which stream it uses.
> Did that one work for you? Except for increased memory is there
> ever a reason not to use BufferedTreeNodeStream instead of
> CommonTreeNodeStream?
Nope.
Ok, just checked. Added 2 unit tests. TreeIterator and
CommonTreeNodeStream reset properly. Perhaps it's the tree parser?
Ter
More information about the antlr-interest
mailing list