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


C++ pANTLR3_COMMON_TOKEN::getTokenIndex方法代码示例

本文整理汇总了C++中pANTLR3_COMMON_TOKEN::getTokenIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ pANTLR3_COMMON_TOKEN::getTokenIndex方法的具体用法?C++ pANTLR3_COMMON_TOKEN::getTokenIndex怎么用?C++ pANTLR3_COMMON_TOKEN::getTokenIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pANTLR3_COMMON_TOKEN的用法示例。


在下文中一共展示了pANTLR3_COMMON_TOKEN::getTokenIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/** Tell me how to create a token for use with imaginary token nodes.
 *  For example, there is probably no input symbol associated with imaginary
 *  token DECL, but you need to create it as a payload or whatever for
 *  the DECL node as in ^(DECL type ID).
 *
 *  This is a variant of createToken where the new token is derived from
 *  an actual real input token.  Typically this is for converting '{'
 *  tokens to BLOCK etc...  You'll see
 *
 *    r : lc='{' ID+ '}' -> ^(BLOCK[$lc] ID+) ;
 *
 *  If you care what the token payload objects' type is, you should
 *  override this method and any other createToken variant.
 *
 * NB: this being C it is not so easy to extend the types of creaeteToken.
 *     We will have to see if anyone needs to do this and add any variants to
 *     this interface.
 */
static	pANTLR3_COMMON_TOKEN
createTokenFromToken	(pANTLR3_BASE_TREE_ADAPTOR adaptor, pANTLR3_COMMON_TOKEN fromToken)
{
    pANTLR3_COMMON_TOKEN    newToken;

    newToken	= adaptor->tokenFactory->newToken(adaptor->tokenFactory);
    
    if	(newToken != NULL)
    {
	/* Create the text using our own string factory to avoid complicating
	 * commontoken.
	 */
	pANTLR3_STRING	text;

	newToken->toString  = fromToken->toString;
	text		    = fromToken->getText(fromToken);
	newToken->text	    = adaptor->strFactory->newPtr(adaptor->strFactory, text->chars, text->len);

	newToken->setLine		(newToken, fromToken->getLine(fromToken));
	newToken->setTokenIndex		(newToken, fromToken->getTokenIndex(fromToken));
	newToken->setCharPositionInLine	(newToken, fromToken->getCharPositionInLine(fromToken));
	newToken->setChannel		(newToken, fromToken->getChannel(fromToken));
	newToken->setType		(newToken, fromToken->getType(fromToken));
    }

    return  newToken;
}
开发者ID:jariba,项目名称:europa-pso,代码行数:45,代码来源:antlr3commontreeadaptor.c

示例2:

static pANTLR3_STRING	    
toStringTT  (pANTLR3_TOKEN_STREAM ts, pANTLR3_COMMON_TOKEN start, pANTLR3_COMMON_TOKEN stop)
{
	if	(start != NULL && stop != NULL)
	{
		return	ts->toStringSS(ts, (ANTLR3_UINT32)start->getTokenIndex(start), (ANTLR3_UINT32)stop->getTokenIndex(stop));
	}
	else
	{
		return	NULL;
	}
}
开发者ID:10114395,项目名称:android-5.0.0_r5,代码行数:12,代码来源:antlr3tokenstream.c


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