本文整理匯總了Java中org.antlr.runtime.Token.setCharPositionInLine方法的典型用法代碼示例。如果您正苦於以下問題:Java Token.setCharPositionInLine方法的具體用法?Java Token.setCharPositionInLine怎麽用?Java Token.setCharPositionInLine使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.antlr.runtime.Token
的用法示例。
在下文中一共展示了Token.setCharPositionInLine方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: nextToken
import org.antlr.runtime.Token; //導入方法依賴的package包/類
@Override
public Token nextToken() {
while (true) {
this.state.token = null;
this.state.channel = Token.DEFAULT_CHANNEL;
this.state.tokenStartCharIndex = input.index();
this.state.tokenStartCharPositionInLine = input.getCharPositionInLine();
this.state.tokenStartLine = input.getLine();
this.state.text = null;
if (input.LA(1) == CharStream.EOF) {
return Token.EOF_TOKEN;
}
try {
mTokens();
if (this.state.token == null) {
emit();
}
else if (this.state.token == Token.SKIP_TOKEN) {
continue;
}
return this.state.token;
}
catch (RecognitionException re) {
reportError(re);
if (re instanceof NoViableAltException ||
re instanceof FailedPredicateException) {
recover(re);
}
// create token that holds mismatched char
Token t = new CommonToken(input, Token.INVALID_TOKEN_TYPE, Token.HIDDEN_CHANNEL,
this.state.tokenStartCharIndex, getCharIndex() - 1);
t.setLine(this.state.tokenStartLine);
t.setCharPositionInLine(this.state.tokenStartCharPositionInLine);
tokenErrorMap.put(t, getErrorMessage(re, this.getTokenNames()));
emit(t);
return this.state.token;
}
}
}