本文整理匯總了Java中org.antlr.runtime.CommonToken.setStopIndex方法的典型用法代碼示例。如果您正苦於以下問題:Java CommonToken.setStopIndex方法的具體用法?Java CommonToken.setStopIndex怎麽用?Java CommonToken.setStopIndex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.antlr.runtime.CommonToken
的用法示例。
在下文中一共展示了CommonToken.setStopIndex方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test_getTrimmedNodeRange
import org.antlr.runtime.CommonToken; //導入方法依賴的package包/類
public void test_getTrimmedNodeRange() {
String source = " hello! ";
// 012345678
CommonToken token = new CommonToken(Css3Lexer.IDENT);
token.setText(source);
token.setStartIndex(0);
token.setStopIndex(7); //len - 1 -> points to last char not the end!
Node node = new TokenNode(source, token);
assertEquals(" hello! ", node.image().toString());
int[] result = NodeUtil.getTrimmedNodeRange(node);
assertEquals(1, result[0]);
assertEquals(7, result[1]);
}
示例2: 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;
}
示例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;
}