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


Java CharStream.EOF属性代码示例

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


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

示例1: read

private int read() {
    int result = li.read();
    if (result == LexerInput.EOF) {
        result = CharStream.EOF;
    }

    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:NbLexerCharStream.java

示例2: LA

@Override
public int LA(int i) {
    if (i == 0)
        return 0; // undefined
    if (i < 0)
        i++; // e.g., translate LA(-1) to use offset 0
    if ((p + i - 1) >= n)
        return CharStream.EOF;
    return Character.toUpperCase(data[p + i - 1]);
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:10,代码来源:ANTLRNoCaseStringStream.java

示例3: LA

@Override
public int LA(int i)
{
    int result = stream.LT(i);

    switch (result) {
        case 0:
        case CharStream.EOF:
            return result;
        default:
            return Character.toUpperCase(result);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:13,代码来源:CaseInsensitiveStream.java

示例4: LA

@Override
public int LA(int i) {
    if (i == 0) {
        return 0; // undefined
    }
    if (i < 0) {
        i++; // e.g., translate LA(-1) to use offset 0
    }

    if ((p + i - 1) >= n) {

        return CharStream.EOF;
    }
    return Character.toUpperCase(data[p + i - 1]);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:15,代码来源:AntlrNoCaseStringStream.java

示例5: nextToken

@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;
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:39,代码来源:Lexer.java

示例6: fillBuffer

/**
 * Fills the buffer but stops on a div or div-equals token.
 */
@SuppressWarnings("unchecked")
@Override
protected void fillBuffer() {
	int oldP = p;
	int index = tokens.size();
	Token t = tokenSource.nextToken();
	while (t != null && t.getType() != CharStream.EOF) {
		// stop on div, div-equal and right curly brace tokens tokens.
		int type = t.getType();
		if (type == InternalN4JSLexer.Solidus || type == InternalN4JSLexer.SolidusEqualsSign
				|| type == InternalN4JSLexer.RightCurlyBracket) {
			t.setTokenIndex(index);
			tokens.add(t);
			index++;
			break;
		}
		boolean discard = false;
		// is there a channel override for token type?
		if (channelOverrideMap != null) {
			Integer channelI = (Integer) channelOverrideMap.get(Integer.valueOf(type));
			if (channelI != null) {
				t.setChannel(channelI.intValue());
			}
		}
		if (discardSet != null &&
				discardSet.contains(Integer.valueOf(type))) {
			discard = true;
		} else if (discardOffChannelTokens && t.getChannel() != this.channel) {
			discard = true;
		}
		if (!discard) {
			t.setTokenIndex(index);
			tokens.add(t);
			index++;
		}
		t = tokenSource.nextToken();
	}
	// leave p pointing at first token on channel
	p = oldP == -1 ? 0 : oldP;
	p = skipOffTokenChannels(p);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:44,代码来源:LazyTokenStream.java


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