本文整理匯總了Java中org.antlr.runtime.CommonToken.setChannel方法的典型用法代碼示例。如果您正苦於以下問題:Java CommonToken.setChannel方法的具體用法?Java CommonToken.setChannel怎麽用?Java CommonToken.setChannel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.antlr.runtime.CommonToken
的用法示例。
在下文中一共展示了CommonToken.setChannel方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createToken
import org.antlr.runtime.CommonToken; //導入方法依賴的package包/類
/**
* Create a new token from the given prototype. Any argument besides the prototype is optional and
* will be ignored if its value is <code>null</code>.
*/
protected CommonToken createToken(CommonToken prototype, String text,
Integer charPosInLine, Integer channel, Integer start, Integer stop, Integer type) {
if (prototype == null)
throw new IllegalArgumentException("Prototype may not be null.");
CommonToken result = new CommonToken(prototype);
if (text != null)
result.setText(text);
if (charPosInLine != null)
result.setCharPositionInLine(charPosInLine.intValue());
if (channel != null)
result.setChannel(channel.intValue());
if (start != null)
result.setStartIndex(start.intValue());
if (stop != null)
result.setStopIndex(stop.intValue());
if (type != null)
result.setType(type.intValue());
return result;
}
示例2: processHiddenToken
import org.antlr.runtime.CommonToken; //導入方法依賴的package包/類
/**
* Skips the given leaf as it's hidden. If it was the last token to be returned, a hidden token may be syntesized if
* would affect the semicolon insertion.
*/
private Token processHiddenToken(ILeafNode leaf) {
Token result = nextToken();
if (result == Token.EOF_TOKEN && Strings.countLineBreaks(leaf.getText()) > 0) {
next = result;
CommonToken hidden = new CommonToken(tokenTypeMapper.getInternalTokenType(leaf), leaf.getText());
hidden.setChannel(Token.HIDDEN_CHANNEL);
return hidden;
}
return result;
}
示例3: createEndToken
import org.antlr.runtime.CommonToken; //導入方法依賴的package包/類
protected Token createEndToken(int offset) {
CommonToken result = new CommonToken(getEndTokenType());
result.setText("");
result.setChannel(Token.DEFAULT_CHANNEL);
result.setStartIndex(offset);
result.setStopIndex(offset-1);
return result;
}
示例4: createBeginToken
import org.antlr.runtime.CommonToken; //導入方法依賴的package包/類
protected Token createBeginToken(int offset) {
CommonToken result = new CommonToken(getBeginTokenType());
result.setText("");
result.setChannel(Token.DEFAULT_CHANNEL);
result.setStartIndex(offset);
result.setStopIndex(offset-1);
return result;
}