[antlr-interest] a bug in nilNode in antlr3basetreeadaptor?

Xie, Linlin linlin.xie at siemens.com
Wed Jun 24 11:02:25 PDT 2009


Hi Jim,

 

We've upgraded to 3.1.3 from 3.0.1, it's a lot of pain in the upgrading,
as the many of the features we used of antlr changed in the new version,
especially the node recycling after the rulepostprocessing. 

 

Through debugging, I think it might be a bug in the way antlr's nilNode
works in antlr3basetreeadaptor. It uses the adaptor to create a tree
node from NULL, and then ultimately in newFromTree in antlr3commontoken,
it tries to reuse a node from the factory, if such node exists, then
copy the token and u to the node, but without wiping out the children of
it. When a root_0 is created in this way, and then adaptor->addchild to
root_0, it checks if the root_0 has already any child, if it doesn't it
would add the children of the subtree to it, and reset the subtree's
children to be null. Thus for a root_0 generated from a reused node, the
children wouldn't be null, so the subtree's children won't be reset. 

 

I think you've got to make it consistent, if you are generating a new
empty node, the new node's children have to be null. Plus, I don't think
it's that necessary to reset subtree's children, of course one reason is
that we need to use it in our @after action. 

 

Can you confirm to me if that's a bug, in case I got it wrong.

 

Thanks a lot.

Regards,

Linlin

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090624/ccfa9383/attachment.html 


More information about the antlr-interest mailing list