本文整理汇总了C++中pANTLR3_BASE_TREE::getCharPositionInLine方法的典型用法代码示例。如果您正苦于以下问题:C++ pANTLR3_BASE_TREE::getCharPositionInLine方法的具体用法?C++ pANTLR3_BASE_TREE::getCharPositionInLine怎么用?C++ pANTLR3_BASE_TREE::getCharPositionInLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pANTLR3_BASE_TREE
的用法示例。
在下文中一共展示了pANTLR3_BASE_TREE::getCharPositionInLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dumpTree
std::string MySQLRecognitionBase::dumpTree(pANTLR3_UINT8 *tokenNames, pANTLR3_BASE_TREE tree, const std::string &indentation)
{
std::string result;
ANTLR3_UINT32 char_pos = tree->getCharPositionInLine(tree);
ANTLR3_UINT32 line = tree->getLine(tree);
pANTLR3_STRING token_text = tree->getText(tree);
pANTLR3_COMMON_TOKEN token = tree->getToken(tree);
const char* utf8 = (const char*)token_text->chars;
if (token != NULL)
{
ANTLR3_UINT32 token_type = token->getType(token);
pANTLR3_UINT8 token_name;
if (token_type == EOF)
token_name = (pANTLR3_UINT8)"EOF";
else
token_name = tokenNames[token_type];
#ifdef ANTLR3_USE_64BIT
result = base::strfmt("%s(line: %i, offset: %i, length: %" PRId64 ", index: %" PRId64 ", %s[%i]) %s\n",
indentation.c_str(), line, char_pos, token->stop - token->start + 1, token->index, token_name,
token_type, utf8);
#else
result = base::strfmt("%s(line: %i, offset: %i, length: %i, index: %i, %s[%i]) %s\n",
indentation.c_str(), line, char_pos, token->stop - token->start + 1, token->index, token_name,
token_type, utf8);
#endif
}
else
{
result = base::strfmt("%s(line: %i, offset: %i, nil) %s\n", indentation.c_str(), line, char_pos, utf8);
}
for (ANTLR3_UINT32 index = 0; index < tree->getChildCount(tree); index++)
{
pANTLR3_BASE_TREE child = (pANTLR3_BASE_TREE)tree->getChild(tree, index);
std::string child_text = dumpTree(tokenNames, child, indentation + "\t");
result += child_text;
}
return result;
}
示例2:
ASTNode::ASTNode(const pANTLR3_BASE_TREE node)
{
m_LineNumber = node->getLine(node);
m_CharPosition = node->getCharPositionInLine(node);
pANTLR3_BASE_TREE n = node;
while ((n != NULL) && (n->u == NULL))
{
if (n->u != NULL)
{
m_FileName = (wchar_t*) n->u;
node->u = n->u;
break;
}
else
{
n = n->getParent(n);
}
}
}