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


Java Token.EOF_TOKEN属性代码示例

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


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

示例1: createContextsForLastCompleteNode

@Override
protected void createContextsForLastCompleteNode(EObject previousModel, boolean strict) {
	String currentNodePrefix = getPrefix(currentNode);
	if (!Strings.isEmpty(currentNodePrefix) && !currentNode.getText().equals(currentNodePrefix)) {
		lexer.setCharStream(new ANTLRStringStream(currentNodePrefix));
		Token token = lexer.nextToken();
		if (token == Token.EOF_TOKEN) { // error case - nothing could be parsed
			return;
		}
		while (token != Token.EOF_TOKEN) {
			if (isErrorToken(token))
				return;
			token = lexer.nextToken();
		}
	}
	String prefix = "";
	Collection<FollowElement> followElements = getParser().getFollowElements(rootNode, 0, completionOffset, strict);
	doCreateContexts(lastCompleteNode, currentNode, prefix, previousModel, followElements);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:ContentAssistContextFactory.java

示例2: createTokenSource

@Override
protected TokenSource createTokenSource(String string) {
	List<Token> tokens = highlightingParser.getTokens(string);
	Iterator<Token> iter = tokens.iterator();
	return new TokenSource() {

		@Override
		public Token nextToken() {
			if (iter.hasNext()) {
				return iter.next();
			}
			return Token.EOF_TOKEN;
		}

		@Override
		public String getSourceName() {
			return "Text: " + string;
		}
	};
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:ParserBasedDocumentTokenSource.java

示例3: announce

@Override
protected void announce(Token start, Token stop, AbstractElement element) {
	if (start != null && start != Token.EOF_TOKEN) {
		if (start == stop) {
			announce(start, element);
		} else {
			CommonToken castedStart = (CommonToken) start;
			if (stop == null) { // possible error condition
				if (start.getTokenIndex() == state.lastErrorIndex) {
					return;
				}
			}
			CommonToken castedEnd = (CommonToken) stop;
			Integer newType = rewriter.rewrite(castedStart, element);
			if (newType != null && castedEnd != null && castedEnd != Token.EOF_TOKEN) {
				LazyTokenStream castedInput = (LazyTokenStream) this.input;
				for (int i = castedStart.getTokenIndex() + 1; i < castedEnd.getTokenIndex(); i++) {
					Token token = castedInput.get(i);
					if (token.getChannel() != Token.HIDDEN_CHANNEL)
						token.setType(newType);
				}
				castedEnd.setType(newType);
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:InternalHighlightingParser.java

示例4: createContextsForLastCompleteNode

@Override
protected void createContextsForLastCompleteNode(EObject previousModel, boolean strict) {
	String currentNodePrefix = getPrefix(currentNode);
	if (!Strings.isEmpty(currentNodePrefix) && !currentNode.getText().equals(currentNodePrefix)) {
		lexer.setCharStream(new ANTLRStringStream(currentNodePrefix));
		Token token = lexer.nextToken();
		if (token == Token.EOF_TOKEN) {
			return;
		}
		while (token != Token.EOF_TOKEN) {
			if (isErrorToken(token)) {
				return;
			}
			token = lexer.nextToken();
		}
	}
	String prefix = "";
	Collection<FollowElement> followElements = parseFollowElements(completionOffset, strict);
	doCreateContexts(lastCompleteNode, currentNode, prefix, previousModel, followElements);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:PartialContentAssistContextFactory.java

示例5: createContextsForLastCompleteNode

protected void createContextsForLastCompleteNode(EObject previousModel, boolean strict) {
	String currentNodePrefix = getPrefix(currentNode);
	if (!Strings.isEmpty(currentNodePrefix) && !currentNode.getText().equals(currentNodePrefix)) {
		lexer.setCharStream(new ANTLRStringStream(currentNodePrefix));
		Token token = lexer.nextToken();
		if (token == Token.EOF_TOKEN) { // error case - nothing could be parsed
			return;
		}
		while(token != Token.EOF_TOKEN) {
			if (isErrorToken(token))
				return;
			token = lexer.nextToken();
		}
	}
	String prefix = "";
	String completeInput = getInputToParse(document, completionOffset);
	Collection<FollowElement> followElements = parser.getFollowElements(completeInput, strict);
	doCreateContexts(lastCompleteNode, currentNode, prefix, previousModel, followElements);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:19,代码来源:ContentAssistContextFactory.java

示例6: nextToken

/**
 * Implementation of the {@link TokenSource} interface. Return new tokens as long as there are some, afterwards
 * return {@link Token#EOF_TOKEN}.
 */
@Override
public Token nextToken() {
	if (next != null) {
		Token result = next;
		next = null;
		return result;
	}
	if (!leafNodes.hasNext()) {
		return Token.EOF_TOKEN;
	}
	ILeafNode leaf = leafNodes.next();
	if (leaf.getTotalOffset() >= endOffset) {
		leafNodes = Iterators.emptyIterator();
		return Token.EOF_TOKEN;
	}
	if (leaf.getTotalEndOffset() <= startOffset) {
		return nextToken();
	}
	if (leaf.getTotalEndOffset() > endOffset) {
		return toPrefixToken(leaf);
	}
	SyntaxErrorMessage syntaxErrorMessage = leaf.getSyntaxErrorMessage();
	if (syntaxErrorMessage != null && SEMICOLON_INSERTED.equals(syntaxErrorMessage.getIssueCode())) {
		return toASIToken(leaf);
	}
	if (leaf.isHidden()) {
		return processHiddenToken(leaf);
	}
	int tokenType = tokenTypeMapper.getInternalTokenType(leaf);
	return new CommonToken(tokenType, leaf.getText());
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:35,代码来源:NodeModelTokenSource.java

示例7: processHiddenToken

/**
 * Skips the given leaf as it's hidden. If it was the last token to be returned, a hidden token may be syntesized if
 * would affect the semicolon insertion.
 */
private Token processHiddenToken(ILeafNode leaf) {
	Token result = nextToken();
	if (result == Token.EOF_TOKEN && Strings.countLineBreaks(leaf.getText()) > 0) {
		next = result;
		CommonToken hidden = new CommonToken(tokenTypeMapper.getInternalTokenType(leaf), leaf.getText());
		hidden.setChannel(Token.HIDDEN_CHANNEL);
		return hidden;
	}
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:14,代码来源:NodeModelTokenSource.java

示例8: exhaustTokenSource

private void exhaustTokenSource() {
	LazyTokenStream casted = (LazyTokenStream) this.input;
	int marked = casted.mark();
	try {
		while (casted.LT(1) != Token.EOF_TOKEN) {
			casted.consume();
		}
	} finally {
		casted.rewind(marked);
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:11,代码来源:InternalSemicolonInjectingParser.java

示例9: 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

示例10: nextToken

@Override
public Token nextToken() {
	if (iter.hasNext()) {
		ILookAheadTerminal lookAhead = iter.next();
		return lookAhead.getToken();
	}
	return Token.EOF_TOKEN;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:8,代码来源:LookAheadBasedTokenSource.java

示例11: error

@Override
protected void error(NoViableAltException nvae) {
	if (nvae.token == Token.EOF_TOKEN) {
		int lookAheadAddOn = getRecognizer().lookAheadAddOn;
		int lookAhead = ((XtextTokenStream)nvae.input).getCurrentLookAhead();
		if ((lookAhead >= lookAheadAddOn && lookAheadAddOn > 0) || (lookAhead == 0 && lookAheadAddOn > 0) || lookAhead == -1)
			getRecognizer().failedPredicateAtEOF = true;
	}
	super.error(nvae);
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:10,代码来源:DFA.java

示例12: nextToken

@Override
public Token nextToken() {
	if (tokenCount == 0)
		return Token.EOF_TOKEN;
	return new CommonToken(tokenCount--, "Text");
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:6,代码来源:XtextTokenStreamTest.java


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