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


Java Token.EOF属性代码示例

本文整理汇总了Java中org.antlr.runtime.Token.EOF属性的典型用法代码示例。如果您正苦于以下问题:Java Token.EOF属性的具体用法?Java Token.EOF怎么用?Java Token.EOF使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.antlr.runtime.Token的用法示例。


在下文中一共展示了Token.EOF属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: consumeUntil

/** Consume tokens until one matches the given token set */
    @Override
    public void consumeUntil(IntStream i, BitSet set) {
//        System.out.println("consumeUntil(" + set.toString(getTokenNames()) + ")");
        Token ttype;
        List<Token> skipped = new ArrayList<>();
        beginResync();
        try {
            while ((ttype = input.LT(1)) != null && ttype.getType() != Token.EOF && !set.member(ttype.getType())) {
//            System.out.println("consume during recover LA(1)=" + getTokenNames()[input.LA(1)]);
                input.consume();
                skipped.add(ttype);
            }
        } finally {
            endResync();
        }
        ((NbParseTreeBuilder) dbg).consumeSkippedTokens(skipped);
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ExtCss3Parser.java

示例2: toTokenString

public String toTokenString() {
	CharStream input = this.token.getInputStream();
	GrammarASTAdaptor adaptor = new GrammarASTAdaptor(input);
	CommonTreeNodeStream nodes =
		new CommonTreeNodeStream(adaptor, this);
	StringBuilder buf = new StringBuilder();
	GrammarAST o = (GrammarAST)nodes.LT(1);
	int type = adaptor.getType(o);
	while ( type!=Token.EOF ) {
		buf.append(" ");
		buf.append(o.getText());
		nodes.consume();
		o = (GrammarAST)nodes.LT(1);
		type = adaptor.getType(o);
	}
	return buf.toString();
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:17,代码来源:GrammarAST.java

示例3: nextToken

public Token nextToken()
{
    super.nextToken();
    if (tokens.size() == 0)
        return new CommonToken(Token.EOF);
    return tokens.remove(0);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:7,代码来源:CqlLexer.java

示例4: promoteEOL

/**
 * <p>
 * Promotes EOL which may lead to an automatically inserted semicolon. This is probably the most important method
 * for automatic semicolon insertion, as it is only possible to insert a semicolon in case of line breaks (even if
 * they are hidden in a multi-line comment!).
 * </p>
 */
public static void promoteEOL(Callback callback) {
	RecognizerSharedState state = callback.getState();
	TokenStream input = callback.getInput();
	// Don't promote EOL if there was a syntax error at EOF
	if (state.lastErrorIndex == input.size()) {
		return;
	}
	// Get current token and its type (the possibly offending token).
	Token prev = input.LT(-1);
	Token next = input.LT(1);
	int la = next.getType();

	// Promoting an EOL means switching it from off channel to on channel.
	// A ML_COMMENT gets promoted when it contains an EOL.
	for (int idx = prev == null ? 0 : prev.getTokenIndex() + 1, max = la == Token.EOF ? input.size()
			: next.getTokenIndex(); idx < max; idx++) {
		Token lt = input.get(idx);
		if (lt.getChannel() == Token.DEFAULT_CHANNEL) {
			// On channel token found: stop scanning (previously promoted)
			break;
		} else if (isSemicolonEquivalent(lt)) {
			// We found our EOL: promote the token to on channel, position the input on it and reset the rule
			// start.
			lt.setChannel(Token.DEFAULT_CHANNEL);
			input.seek(idx);
			break;
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:36,代码来源:SemicolonInjectionHelper.java

示例5: isSameTokenSequence

protected boolean isSameTokenSequence(TokenSource originalSource, TokenSource newSource, int expectedLength) {
	Token token = originalSource.nextToken();
	int newLength = 0;
	while(Token.EOF != token.getType()) {
		Token newToken = newSource.nextToken();
		if (token.getType() != newToken.getType()) {
			return false;
		}
		newLength += TokenTool.getLength(newToken);
		token = originalSource.nextToken();
	}
	return newLength == expectedLength;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:13,代码来源:TokenSequencePreservingPartialParsingHelper.java

示例6: addEOFTransitionToStartRules

/** Add an EOF transition to any rule end ATNState that points to nothing
    *  (i.e., for all those rules not invoked by another rule).  These
    *  are start symbols then.
 *
 *  Return the number of grammar entry points; i.e., how many rules are
 *  not invoked by another rule (they can only be invoked from outside).
 *  These are the start rules.
    */
public int addEOFTransitionToStartRules() {
	int n = 0;
	ATNState eofTarget = newState(null); // one unique EOF target for all rules
	for (Rule r : g.rules.values()) {
		ATNState stop = atn.ruleToStopState[r.index];
		if ( stop.getNumberOfTransitions()>0 ) continue;
		n++;
		Transition t = new AtomTransition(eofTarget, Token.EOF);
		stop.addTransition(t);
	}
	return n;
}
 
开发者ID:antlr,项目名称:codebuff,代码行数:20,代码来源:ParserATNFactory.java

示例7: doSplitToken

@Override
protected void doSplitToken(Token token, ITokenAcceptor result) {
	if (token.getType() == Token.EOF) {
		doSplitEofToken(token, result);
	} else {
		doSplitTokenImpl(token, result);	
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:AbstractIndentationTokenSource.java

示例8: testConsumeUntilEOF_large

@Test public void testConsumeUntilEOF_large() {
	tokenCount = 25000;
	XtextTokenStream stream = new XtextTokenStream(this, Token.DEFAULT_CHANNEL);
	while(stream.LA(1) != Token.EOF) {
		stream.consume();
		stream.LA(1);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:XtextTokenStreamTest.java

示例9: testConsumeUntilEOF_small

@Test public void testConsumeUntilEOF_small() {
	tokenCount = 25;
	XtextTokenStream stream = new XtextTokenStream(this, Token.DEFAULT_CHANNEL);
	while(stream.LA(1) != Token.EOF) {
		stream.consume();
		stream.LA(1);
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:XtextTokenStreamTest.java

示例10: doTestLookahead

protected void doTestLookahead(int lookAhead, int tokenCount) {
	this.tokenCount = tokenCount;
	XtextTokenStream stream = new XtextTokenStream(this, Token.DEFAULT_CHANNEL);
	while(stream.LA(1) != Token.EOF) {
		for(int i = 0; i < lookAhead; i++) {
			for(int j = i + 1; j < lookAhead; j++) {
				stream.LA(j - i);					
			}
			stream.consume();
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:XtextTokenStreamTest.java

示例11: doSplitToken

@Override
protected void doSplitToken(Token token, ITokenAcceptor result) {
	int nextLevel = (token.getType() == Token.EOF) ? 0 : countTabs(token.getText());
	while (this.level > nextLevel) {
		this.level--;
		result.accept(new CommonToken(InternalIndentationAwareTestLanguageLexer.RULE_END, ""));
	}
	result.accept(token);
	while (this.level < nextLevel) {
		this.level++;
		result.accept(new CommonToken(InternalIndentationAwareTestLanguageLexer.RULE_BEGIN, ""));
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:13,代码来源:IndentTokenSource.java

示例12: LA

@Override
public int LA(int i) {
	Token lookaheadToken = LT(i);
	int result = lookaheadToken.getType();
	if (result == Token.EOF && getListener() != null)
		getListener().announceEof(i);
	return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:ObservableXtextTokenStream.java

示例13: recover

@Override
public void recover(IntStream stream, RecognitionException ex) {
	if (recoveryListener != null)
		recoveryListener.beginErrorRecovery();
	removeUnexpectedElements();
	if (ex instanceof FailedPredicateException && ex.token.getType() == Token.EOF) {
		failedPredicateAtEOF = true;
	}
	super.recover(stream, ex);
	if (recoveryListener != null)
		recoveryListener.endErrorRecovery();
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:12,代码来源:BaseInternalContentAssistParser.java

示例14: shouldSplitToken

@Override
protected boolean shouldSplitToken(Token token) {
	return token.getType() == Token.EOF || shouldSplitTokenImpl(token);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:4,代码来源:AbstractIndentationTokenSource.java

示例15: shouldSplitToken

@Override
protected boolean shouldSplitToken(Token token) {
	return token.getType() == InternalIndentationAwareTestLanguageLexer.RULE_NL || token.getType() == Token.EOF;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:4,代码来源:IndentTokenSource.java


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