当前位置: 首页>>代码示例>>C++>>正文


C++ pANTLR3_LEXER::getCharIndex方法代码示例

本文整理汇总了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
							);

}
开发者ID:Abasti,项目名称:antlr,代码行数:15,代码来源:antlr3lexer.c

示例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;
}
开发者ID:ChitaGideon,项目名称:antlr3,代码行数:43,代码来源:antlr3lexer.c


注:本文中的pANTLR3_LEXER::getCharIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。