本文整理汇总了C++中pANTLR3_COMMON_TOKEN::getChannel方法的典型用法代码示例。如果您正苦于以下问题:C++ pANTLR3_COMMON_TOKEN::getChannel方法的具体用法?C++ pANTLR3_COMMON_TOKEN::getChannel怎么用?C++ pANTLR3_COMMON_TOKEN::getChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pANTLR3_COMMON_TOKEN
的用法示例。
在下文中一共展示了pANTLR3_COMMON_TOKEN::getChannel方法的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;
}
示例2: printToken
void printToken(pANTLR3_COMMON_TOKEN tok)
{
printf("[");
printf("@\%d,", (int)tok->getTokenIndex(tok));
printf("\%d:", (int)tok->getStartIndex(tok));
printf("\%d=", (int)tok->getStopIndex(tok));
printf("'\%s',", tok->getText(tok)->chars);
printf("<\%d>,", (int)tok->getType(tok));
if (tok->getChannel(tok) > ANTLR3_TOKEN_DEFAULT_CHANNEL) {
printf("channel=\%d,", (int)tok->getChannel(tok));
}