本文整理汇总了C++中pANTLR3_BASE_TREE::getLine方法的典型用法代码示例。如果您正苦于以下问题:C++ pANTLR3_BASE_TREE::getLine方法的具体用法?C++ pANTLR3_BASE_TREE::getLine怎么用?C++ pANTLR3_BASE_TREE::getLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pANTLR3_BASE_TREE
的用法示例。
在下文中一共展示了pANTLR3_BASE_TREE::getLine方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: f
IntegerLiteralValueDef::IntegerLiteralValueDef(const pANTLR3_BASE_TREE node)
: LiteralValueDef(INTEGER_LITERAL, node)
{
assert(node->getType(node) == N_INT_LITERAL);
assert(node->getChildCount(node) == 1);
pANTLR3_BASE_TREE n = (pANTLR3_BASE_TREE) node->getChild(node, 0);
assert(n->getType(n) == INTL);
wchar_t* szStr = (wchar_t*) n->getText(n)->chars;
int value;
try
{
value = boost::lexical_cast<int, wchar_t*>(szStr);
}
catch (const std::exception&)
{
boost::wformat f(L"Invalid integer value: %1% at line %2%");
f % szStr % node->getLine(node);
ParserException e(f.str());
throw e;
}
m_IntValue = value;
}
示例2: 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;
}
示例3:
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);
}
}
}
示例4: if
StringLiteralValueDef::StringLiteralValueDef(const pANTLR3_BASE_TREE node)
: LiteralValueDef(STRING_LITERAL, node)
{
assert(node->getType(node) == N_STRING_LITERAL);
assert(node->getChildCount(node) == 1);
pANTLR3_BASE_TREE n, c;
n = (pANTLR3_BASE_TREE) node->getChild(node, 0);
assert(n->getType(n) == STRINGL);
wchar_t* szStr = (wchar_t*) n->getText(n)->chars;
std::wstringbuf strBuff;
int state = START_STATE;
for (wchar_t* pCurr = szStr; *pCurr != L'\0'; pCurr++)
{
wchar_t curr = *pCurr;
switch (state)
{
case START_STATE:
assert(curr == L'"');
state = NO_ESC_STATE;
break;
case NO_ESC_STATE:
if (curr == L'\\')
{
state = ESC_BEGIN_STATE;
}
else if (curr == L'"')
{
state = END_STATE;
}
else
{
strBuff.sputc(curr);
}
break;
case ESC_BEGIN_STATE:
switch (curr)
{
case L'b':
strBuff.sputc(L'\b');
state = NO_ESC_STATE;
break;
case L't':
strBuff.sputc(L'\t');
state = NO_ESC_STATE;
break;
case L'n':
strBuff.sputc(L'\n');
state = NO_ESC_STATE;
break;
case L'f':
strBuff.sputc(L'\f');
state = NO_ESC_STATE;
break;
case L'r':
strBuff.sputc(L'\r');
state = NO_ESC_STATE;
break;
case L'"':
strBuff.sputc(L'\"');
state = NO_ESC_STATE;
break;
case L'\'':
strBuff.sputc(L'\'');
state = NO_ESC_STATE;
break;
case L'\\':
strBuff.sputc(L'\\');
state = NO_ESC_STATE;
break;
default:
boost::wformat f(L"Unknown escape sequence \\%1% at line %2%");
f % curr % node->getLine(node);
ParserException e(f.str());
throw e;
}
break;
case END_STATE:
assert(false);
break;
default:
assert(false);
break;
}
}
assert(state == END_STATE);
m_StringValue = strBuff.str();
}