[antlr-interest] Is dupTree( ) completely recursive?

Kay Roepke kroepke at classdump.org
Sun Nov 26 17:40:39 PST 2006


On 26. Nov 2006, at 4:28 , Brian DeVries wrote:

> I'm looking at the code in BaseTree.dupTree( ) and  
> CommonTree.dupNode(), and
> the comment says it recursively walks the tree, but the code only  
> calls
> dupNode( ) for each child node, not dupTree( ). Thus, this only does a
> one-level down duplication, rather than duplicating the entire tree  
> all the
> way down. As a result, I'm having to subclass CommonTree and write a
> dupTree( ) that recursively invokes dupTree( ) for every child to  
> grab the
> whole tree.
>
> Is there an easier way to do this? Am I missing something? I would  
> think
> that BaseTree.dupTree( ) would do this for me, but it doesn't seem to.

Apparently that's a bug. I didn't even realize before, I had simply  
recoded
that from scratch for Objective C, so I didn't notice that behavior  
in the
Java runtime.

It seems that your solution is the way to go. You are right,  
BaseTree.dupTree()
should be doing exactly that.
I filed a bug: <http://www.antlr.org:8888/browse/ANTLR-50>

This should be fixed in the next beta release.

Thanks!

-k
-- 
Kay Röpke
http://classdump.org/






More information about the antlr-interest mailing list