當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。