本文整理汇总了Java中org.antlr.v4.runtime.IntStream类的典型用法代码示例。如果您正苦于以下问题:Java IntStream类的具体用法?Java IntStream怎么用?Java IntStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntStream类属于org.antlr.v4.runtime包,在下文中一共展示了IntStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LA
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public int LA(int i) {
if (i == 0) {
// undefined behavior, precondition is violated
return 0;
}
if (i < 0) {
throw new UnsupportedOperationException("Not implemented yet");
}
int symbol = 0;
for (int j = 0; j < i && symbol != IntStream.EOF; j++) {
symbol = read();
}
backup(i);
return symbol;
}
示例2: test
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Test
public void test(){
CommonTokenStream ts = TokenStreamFactory.createTokenStream("class{ }");
int tokenSize = ts.size();
assertEquals(0, tokenSize);
List<Token> tokens = ts.getTokens();
assertEquals(0, tokens.size());
ts.consume();
ts.consume();
assertEquals("}", ts.LT(1).getText());
assertEquals("{", ts.LT(-1).getText());
assertEquals("class", ts.LT(-2).getText());
//why is it 4?
assertEquals(4, ts.size());
int consumeSize = 2;
while(ts.LA(1)!=IntStream.EOF){
ts.consume();
consumeSize++;
}
tokens = ts.getTokens();
assertEquals(5, tokens.size());
assertEquals(3, consumeSize);
}
示例3: LA
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public int LA(int i) {
if ( i==0 ) {
return 0; // undefined
}
if ( i<0 ) {
i++; // e.g., translate LA(-1) to use offset i=0; then data[p+0-1]
if ( (p+i-1) < 0 ) {
return IntStream.EOF; // invalid; no char before first char
}
}
if ( (p+i-1) >= n ) {
return IntStream.EOF;
}
int ch = this.buf.get(p+i-1);
return ch;
}
示例4: LA
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public int LA(int i) {
if (i == 0) {
return 0; // undefined
}
if (i < 0) {
i++; // e.g., translate LA(-1) to use offset i=0; then data[p+0-1]
if ((p + i - 1) < 0) {
return IntStream.EOF; // invalid; no char before first char
}
}
if ((p + i - 1) >= n) {
return IntStream.EOF;
}
return lookaheadData[p + i - 1];
}
示例5: LA
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public int LA(int i) {
if (i == 0) {
return 0;
}
if (i < 0) {
i++;
if ((p + i - 1) < 0) {
return IntStream.EOF;
}
}
if ((p + i - 1) >= n) {
return IntStream.EOF;
}
return la[p + i - 1];
}
示例6: LA
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public int LA(int i) {
if (i == 0) {
return 0; // undefined
}
if (i < 0) {
i++; // e.g., translate LA(-1) to use offset i=0; then data[p+0-1]
if ((p + i - 1) < 0) {
return IntStream.EOF; // invalid; no char before first char
}
}
if ((p + i - 1) >= n) {
return IntStream.EOF;
}
return lookaheadData[p + i - 1];
}
示例7: start
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public void start(CharSequence buffer, int startOffset, int endOffset, int initialState) {
this.buffer = buffer;
this.endOffset = endOffset;
CharStream in = new CharSequenceCharStream(buffer, endOffset, IntStream.UNKNOWN_SOURCE_NAME);
in.seek(startOffset);
ANTLRLexerState state;
if (startOffset == 0 && initialState == 0) {
state = getInitialState();
} else {
state = toLexerState(initialState);
}
applyLexerState(in, state);
advance();
}
示例8: failOrAccept
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
protected int failOrAccept(SimState prevAccept, CharStream input,
ATNConfigSet reach, int t)
{
if (prevAccept.dfaState != null) {
LexerActionExecutor lexerActionExecutor = prevAccept.dfaState.lexerActionExecutor;
accept(input, lexerActionExecutor, startIndex,
prevAccept.index, prevAccept.line, prevAccept.charPos);
return prevAccept.dfaState.prediction;
}
else {
// if no accept and EOF is first char, return EOF
if ( t==IntStream.EOF && input.index()==startIndex ) {
return Token.EOF;
}
throw new LexerNoViableAltException(recog, input, startIndex, reach);
}
}
示例9: accept
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
protected void accept(@NotNull CharStream input, LexerActionExecutor lexerActionExecutor,
int startIndex, int index, int line, int charPos)
{
if ( debug ) {
System.out.format(Locale.getDefault(), "ACTION %s\n", lexerActionExecutor);
}
// seek to after last char in token
input.seek(index);
this.line = line;
this.charPositionInLine = charPos;
if (input.LA(1) != IntStream.EOF) {
consume(input);
}
if (lexerActionExecutor != null && recog != null) {
lexerActionExecutor.execute(recog, input, startIndex);
}
}
示例10: LA
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
//CHECKSTYLE:OFF
public int LA(int i) {
//CHECKSTYLE:ON
if (i == 0) {
return 0; // undefined
}
if (i < 0) {
i++; // e.g., translate LA(-1) to use offset i=0; then data[p+0-1]
if ((p + i - 1) < 0) {
return IntStream.EOF; // invalid; no char before first char
}
}
if ((p + i - 1) >= n) {
return IntStream.EOF;
}
return lowerCaseData[p + i - 1];
}
示例11: LA
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public int LA(int i)
{
int result = stream.LA(i);
switch (result) {
case 0:
case IntStream.EOF:
return result;
default:
return Character.toUpperCase(result);
}
}
示例12: read
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
/**
* @return a valid character from input or IntStream.EOF if there is no more
* characters available on input.
*/
private int read() {
int result = input.read();
if (result == LexerInput.EOF) {
result = IntStream.EOF;
}
return result;
}
示例13: tokenRef
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public Handle tokenRef(TerminalAST node) {
// Ref to EOF in lexer yields char transition on -1
if ( node.getText().equals("EOF") ) {
ATNState left = newState(node);
ATNState right = newState(node);
left.addTransition(new AtomTransition(right, IntStream.EOF));
return new Handle(left, right);
}
return _ruleRef(node);
}
示例14: LA
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public int LA(int i) {
int result = stream.LA(i);
switch (result) {
case 0:
case IntStream.EOF:
return result;
default:
return Character.toUpperCase(result);
}
}
示例15: LA
import org.antlr.v4.runtime.IntStream; //导入依赖的package包/类
@Override
public int LA(int i) {
int data = super.LA(i);
if (data == 0 || data == IntStream.EOF) {
return data;
} else {
return lowercase[index() + i - 1];
}
}