本文整理汇总了C++中pANTLR3_BASE_TREE::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ pANTLR3_BASE_TREE::toString方法的具体用法?C++ pANTLR3_BASE_TREE::toString怎么用?C++ pANTLR3_BASE_TREE::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pANTLR3_BASE_TREE
的用法示例。
在下文中一共展示了pANTLR3_BASE_TREE::toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static pANTLR3_STRING
toStringTree (pANTLR3_BASE_TREE tree)
{
pANTLR3_STRING string;
ANTLR3_UINT32 i;
ANTLR3_UINT32 n;
pANTLR3_BASE_TREE t;
if (tree->children == NULL || tree->children->size(tree->children) == 0)
{
return tree->toString(tree);
}
/* Need a new string with nothing at all in it.
*/
string = tree->strFactory->newRaw(tree->strFactory);
if (tree->isNilNode(tree) == ANTLR3_FALSE)
{
string->append8 (string, "(");
string->appendS (string, tree->toString(tree));
string->append8 (string, " ");
}
if (tree->children != NULL)
{
n = tree->children->size(tree->children);
for (i = 0; i < n; i++)
{
t = (pANTLR3_BASE_TREE) tree->children->get(tree->children, i);
if (i > 0)
{
string->append8(string, " ");
}
string->appendS(string, t->toStringTree(t));
}
}
if (tree->isNilNode(tree) == ANTLR3_FALSE)
{
string->append8(string,")");
}
return string;
}
示例2: if
static void
toStringWork (pANTLR3_TREE_NODE_STREAM tns, pANTLR3_BASE_TREE p, pANTLR3_BASE_TREE stop, pANTLR3_STRING buf)
{
ANTLR3_UINT32 n;
ANTLR3_UINT32 c;
if (!p->isNilNode(p) )
{
pANTLR3_STRING text;
text = p->toString(p);
if (text == NULL)
{
text = tns->ctns->stringFactory->newRaw(tns->ctns->stringFactory);
text->addc (text, ' ');
text->addi (text, p->getType(p));
}
buf->appendS(buf, text);
}
if (p == stop)
{
return; /* Finished */
}
n = p->getChildCount(p);
if (n > 0 && ! p->isNilNode(p) )
{
buf->addc (buf, ' ');
buf->addi (buf, ANTLR3_TOKEN_DOWN);
}
for (c = 0; c<n ; c++)
{
pANTLR3_BASE_TREE child;
child = p->getChild(p, c);
tns->toStringWork(tns, child, stop, buf);
}
if (n > 0 && ! p->isNilNode(p) )
{
buf->addc (buf, ' ');
buf->addi (buf, ANTLR3_TOKEN_UP);
}
}
示例3: emerson_printAST
pANTLR3_STRING emerson_printAST(pANTLR3_BASE_TREE tree, pANTLR3_UINT8* parserTokenNames)
{
pANTLR3_STRING string;
ANTLR3_UINT32 i;
ANTLR3_UINT32 n;
pANTLR3_BASE_TREE t;
if(tree->children == NULL || tree->children->size(tree->children) == 0)
{
return tree->toString(tree);
}
// THis is how you get a new string. The string is blank
string = tree->strFactory->newRaw(tree->strFactory);
if(tree->isNilNode(tree) == ANTLR3_FALSE)
{
string->append8 (string, "(");
pANTLR3_COMMON_TOKEN token = tree->getToken(tree);
ANTLR3_UINT32 type = token->type;
string->append(string, (const char*)parserTokenNames[type]);
string->append8(string, " ");
}
if(tree->children != NULL)
{
n = tree->children->size(tree->children);
for (i = 0; i < n; i++)
{
t = (pANTLR3_BASE_TREE) tree->children->get(tree->children, i);
if (i > 0)
{
string->append8(string, " ");
}
string->appendS(string, emerson_printAST(t,parserTokenNames));
}
}
if(tree->isNilNode(tree) == ANTLR3_FALSE)
{
string->append8(string,")");
}
return string;
}
示例4:
static pANTLR3_STRING
getText (pANTLR3_BASE_TREE tree)
{
return tree->toString(tree);
}