本文整理汇总了C++中pANTLR3_LEXER::getCharIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ pANTLR3_LEXER::getCharIndex方法的具体用法?C++ pANTLR3_LEXER::getCharIndex怎么用?C++ pANTLR3_LEXER::getCharIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pANTLR3_LEXER
的用法示例。
在下文中一共展示了pANTLR3_LEXER::getCharIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
static pANTLR3_STRING
getText (pANTLR3_LEXER lexer)
{
if (lexer->rec->state->text)
{
return lexer->rec->state->text;
}
return lexer->input->substr(
lexer->input,
lexer->rec->state->tokenStartCharIndex,
lexer->getCharIndex(lexer) - lexer->input->charByteSize
);
}
示例2:
static pANTLR3_COMMON_TOKEN
emit (pANTLR3_LEXER lexer)
{
pANTLR3_COMMON_TOKEN token;
/* We could check pointers to token factories and so on, but
* we are in code that we want to run as fast as possible
* so we are not checking any errors. So make sure you have installed an input stream before
* trying to emit a new token.
*/
token = lexer->rec->state->tokFactory->newToken(lexer->rec->state->tokFactory);
if (token == NULL) { return NULL; }
/* Install the supplied information, and some other bits we already know
* get added automatically, such as the input stream it is associated with
* (though it can all be overridden of course)
*/
token->type = lexer->rec->state->type;
token->channel = lexer->rec->state->channel;
token->start = lexer->rec->state->tokenStartCharIndex;
token->stop = lexer->getCharIndex(lexer) - 1;
token->line = lexer->rec->state->tokenStartLine;
token->charPosition = lexer->rec->state->tokenStartCharPositionInLine;
if (lexer->rec->state->text != NULL)
{
token->textState = ANTLR3_TEXT_STRING;
token->tokText.text = lexer->rec->state->text;
}
else
{
token->textState = ANTLR3_TEXT_NONE;
}
token->lineStart = lexer->input->currentLine;
token->user1 = lexer->rec->state->user1;
token->user2 = lexer->rec->state->user2;
token->user3 = lexer->rec->state->user3;
token->custom = lexer->rec->state->custom;
lexer->rec->state->token = token;
return token;
}