当前位置: 首页>>代码示例>>Java>>正文


Java IntStream类代码示例

本文整理汇总了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;
}
 
开发者ID:mwillema,项目名称:protobuf-netbeans-plugin,代码行数:21,代码来源:AntlrCharStream.java

示例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);
}
 
开发者ID:kasonyang,项目名称:kalang,代码行数:24,代码来源:TokenUtilTest.java

示例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;
}
 
开发者ID:waterguo,项目名称:antsdb,代码行数:19,代码来源:MysqlCharStream.java

示例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];
}
 
开发者ID:wsdookadr,项目名称:mdetect,代码行数:18,代码来源:AntlrCaseInsensitiveFileStream.java

示例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];
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:19,代码来源:CaseInsensitiveInputStream.java

示例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];
}
 
开发者ID:meridor,项目名称:perspective-backend,代码行数:19,代码来源:CaseInsensitiveInputStream.java

示例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();
}
 
开发者ID:antlr,项目名称:jetbrains,代码行数:19,代码来源:ANTLRLexerAdaptor.java

示例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);
	}
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:19,代码来源:LexerATNSimulator.java

示例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);
	}
}
 
开发者ID:MegaApuTurkUltra,项目名称:Scratch-ApuC,代码行数:20,代码来源:LexerATNSimulator.java

示例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];
}
 
开发者ID:gerryai,项目名称:pddl-parser,代码行数:20,代码来源:CaseInsensitiveInputStream.java

示例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);
    }
}
 
开发者ID:dbiir,项目名称:rainbow,代码行数:14,代码来源:CaseInsensitiveStream.java

示例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;
}
 
开发者ID:mwillema,项目名称:protobuf-netbeans-plugin,代码行数:14,代码来源:AntlrCharStream.java

示例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);
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:12,代码来源:LexerATNFactory.java

示例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);
  }
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:13,代码来源:CaseInsensitiveStream.java

示例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];
    }
}
 
开发者ID:defano,项目名称:hypertalk-java,代码行数:11,代码来源:CaseInsensitiveInputStream.java


注:本文中的org.antlr.v4.runtime.IntStream类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。