當前位置: 首頁>>代碼示例>>Java>>正文


Java Token.INVALID_TOKEN_TYPE屬性代碼示例

本文整理匯總了Java中org.antlr.runtime.Token.INVALID_TOKEN_TYPE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Token.INVALID_TOKEN_TYPE屬性的具體用法?Java Token.INVALID_TOKEN_TYPE怎麽用?Java Token.INVALID_TOKEN_TYPE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.antlr.runtime.Token的用法示例。


在下文中一共展示了Token.INVALID_TOKEN_TYPE屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: consumeToken

@Override
public void consumeToken(Token token) {
    if (backtracking > 0 || resync) {
        return;
    }

    if (debug_tokens) {
        CommonToken ct = (CommonToken) token;
        int[] ctr = CommonTokenUtil.getCommonTokenOffsetRange(ct);
        System.out.println(token + "(" + ctr[0] + "-" + ctr[1] + ")");
    }

    //ignore the closing EOF token, we do not want it
    //it the parse tree
    if (token.getType() == Css3Lexer.EOF) {
        return;
    }

    //also ignore error tokens - they are added as children of ErrorNode-s in the recognitionException(...) method
    if (token.getType() == Token.INVALID_TOKEN_TYPE) {
        return;
    }

    lastConsumedToken = (CommonToken) token;

    RuleNode ruleNode = callStack.peek();
    TokenNode elementNode = new TokenNode(source, (CommonToken) token);
    elementNode.hiddenTokens = this.hiddenTokens;
    hiddenTokens.clear();
    ruleNode.addChild(elementNode);

    updateFirstTokens(ruleNode, lastConsumedToken);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:NbParseTreeBuilder.java

示例2: createLeafNode

private ILeafNode createLeafNode(Token token, EObject grammarElement) {
	boolean isHidden = token.getChannel() == HIDDEN;
	SyntaxErrorMessage error = null;
	if (!isHidden) {
		if (currentError != null) {
			error = currentError;
			currentError = null;
		}
	}
	if (token.getType() == Token.INVALID_TOKEN_TYPE) {
		if (error == null) {
			String lexerErrorMessage = ((XtextTokenStream) input).getLexerErrorMessage(token);
			LexerErrorContext errorContext = new LexerErrorContext(lexerErrorMessage);
			error = syntaxErrorProvider.getSyntaxErrorMessage(errorContext);
		}
	}
	if (grammarElement == null) {
		String ruleName = antlrTypeToLexerName.get(token.getType());
		grammarElement = allRules.get(ruleName);
	}
	CommonToken commonToken = (CommonToken) token;
	if (error != null)
		hadErrors = true;
	return nodeBuilder.newLeafNode(
			commonToken.getStartIndex(), 
			commonToken.getStopIndex() - commonToken.getStartIndex() + 1, 
			grammarElement, 
			isHidden, 
			error, 
			currentNode);
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:31,代碼來源:AbstractInternalAntlrParser.java

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

示例4: getMappedValue

protected String getMappedValue(final int tokenType) {
  String _xifexpression = null;
  if ((tokenType == Token.INVALID_TOKEN_TYPE)) {
    _xifexpression = HighlightingStyles.INVALID_TOKEN_ID;
  } else {
    _xifexpression = this.mappedValues[(tokenType - Token.MIN_TOKEN_TYPE)];
  }
  return _xifexpression;
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:9,代碼來源:TokenTypeToStringMapper.java

示例5: getPartitionType

@Override
public String getPartitionType(final int antlrTokenType) {
  // on lexer error return default content type
  if (antlrTokenType == Token.INVALID_TOKEN_TYPE) {
    return IDocument.DEFAULT_CONTENT_TYPE;
  }
  return getMappedValue(antlrTokenType);
}
 
開發者ID:dsldevkit,項目名稱:dsl-devkit,代碼行數:8,代碼來源:FixedTerminalsTokenTypeToPartitionMapper.java

示例6: getLexerErrorMessage

public String getLexerErrorMessage(Token invalidToken) {
	if (tokenSource instanceof org.eclipse.xtext.parser.antlr.Lexer) {
		return ((org.eclipse.xtext.parser.antlr.Lexer) tokenSource).getErrorMessage(invalidToken);
	}
	return (invalidToken.getType() == Token.INVALID_TOKEN_TYPE) ? "Invalid token " + invalidToken.getText() : null;
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:6,代碼來源:XtextTokenStream.java


注:本文中的org.antlr.runtime.Token.INVALID_TOKEN_TYPE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。