本文整理汇总了C++中pANTLR3_BASE_TREE::createChildrenList方法的典型用法代码示例。如果您正苦于以下问题:C++ pANTLR3_BASE_TREE::createChildrenList方法的具体用法?C++ pANTLR3_BASE_TREE::createChildrenList怎么用?C++ pANTLR3_BASE_TREE::createChildrenList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pANTLR3_BASE_TREE
的用法示例。
在下文中一共展示了pANTLR3_BASE_TREE::createChildrenList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static void
setChild (pANTLR3_BASE_TREE tree, ANTLR3_UINT32 i, void * child)
{
if (tree->children == NULL)
{
tree->createChildrenList(tree);
}
tree->children->set(tree->children, i, child, NULL, ANTLR3_FALSE);
}
示例2: freshenPACIndexesAll
void
addChild (pANTLR3_BASE_TREE tree, pANTLR3_BASE_TREE child)
{
ANTLR3_UINT32 n;
ANTLR3_UINT32 i;
if (child == NULL)
{
return;
}
if (child->isNilNode(child) == ANTLR3_TRUE)
{
if (child->children != NULL && child->children == tree->children)
{
// TODO: Change to exception rather than ANTLR3_FPRINTF?
//
ANTLR3_FPRINTF(stderr, "ANTLR3: An attempt was made to add a child list to itself!\n");
return;
}
// Add all of the children's children to this list
//
if (child->children != NULL)
{
if (tree->children == NULL)
{
// We are build ing the tree structure here, so we need not
// worry about duplication of pointers as the tree node
// factory will only clean up each node once. So we just
// copy in the child's children pointer as the child is
// a nil node (has not root itself).
//
tree->children = child->children;
child->children = NULL;
freshenPACIndexesAll(tree);
}
else
{
// Need to copy the children
//
n = child->children->size(child->children);
for (i = 0; i < n; i++)
{
pANTLR3_BASE_TREE entry;
entry = child->children->get(child->children, i);
// ANTLR3 lists can be sparse, unlike Array Lists
//
if (entry != NULL)
{
tree->children->add(tree->children, entry, (void (ANTLR3_CDECL *) (void *))child->free);
}
}
}
}
}
else
{
// Tree we are adding is not a Nil and might have children to copy
//
if (tree->children == NULL)
{
// No children in the tree we are adding to, so create a new list on
// the fly to hold them.
//
tree->createChildrenList(tree);
}
tree->children->add(tree->children, child, (void (ANTLR3_CDECL *)(void *))child->free);
}
}