[antlr-interest] [C-target] "replaceChildren" implementation

Дмитрий Ильин dmitry.m.ilyin at gmail.com
Sun May 1 09:44:57 PDT 2011


Case of same number of input nodes and nodes to replace:

j = 0;
for (i = startChildIndex; i <= stopChildIndex; i++)
{
child = (pANTLR3_BASE_TREE) newChildren->get(newChildren, *j*);
 parent->children->set(parent->children, i, child, NULL, ANTLR3_FALSE);
child->setParent(child, parent);
child->setChildIndex(child, i);
}

Why "j"? It is always 0. "i - startChildIndex" may be used instead of "j".

In case of more nodes to input  we use what we can, then adding new nodes.
But we adding to the end of the children vector instead of inserting to
vector after nodes that we reused. (libantlr3c-3.3-SNAPSHOT)

Dmitry Ilyin


More information about the antlr-interest mailing list