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


Java Parser.getCurrentToken方法代碼示例

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


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

示例1: reportUnwantedToken

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
protected void reportUnwantedToken(@NotNull Parser recognizer)
{
	if (inErrorRecoveryMode(recognizer))
	{
		return;
	}

	beginErrorCondition(recognizer);

	Token t = recognizer.getCurrentToken();
	String tokenName = getTokenErrorDisplay(t);
	IntervalSet expecting = getExpectedTokens(recognizer);
	String msg = "多餘輸入 " + tokenName + " 期望 " + expecting.toString(recognizer.getTokenNames());
	BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg);
	//		exception.token = this.getGrammarToken(t);
	exception.pushToken(this.getGrammarToken(t));
	throw exception;
}
 
開發者ID:javamonkey,項目名稱:beetl2.0,代碼行數:19,代碼來源:BeetlAntlrErrorStrategy.java

示例2: reportUnwantedToken

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
@Override
protected void reportUnwantedToken(Parser recognizer) {
	// change error message from default implementation
	if (inErrorRecoveryMode(recognizer)) {
		return;
	}

	beginErrorCondition(recognizer);

	Token t = recognizer.getCurrentToken();
	String tokenName = getTokenErrorDisplay(t);
	String msg = "extraneous input " + tokenName + " expecting operator";
	recognizer.notifyErrorListeners(t, msg, null);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:15,代碼來源:CapitulatingErrorStrategy.java

示例3: recoverInline

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
@Override
public Token recoverInline(final Parser recognizer) throws RecognitionException {
    final Token token = recognizer.getCurrentToken();
    final String message = "unexpected token [" + getTokenErrorDisplay(token) + "]" +
        " was expecting one of [" + recognizer.getExpectedTokens().toString(recognizer.getVocabulary()) + "].";

    Location location = new Location(sourceName, token.getStartIndex());
    throw location.createError(new IllegalArgumentException(message));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,代碼來源:ParserErrorStrategy.java

示例4: reportMissingToken

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
@Override
public void reportMissingToken(Parser recognizer) {
	beginErrorCondition(recognizer);
	Token t = recognizer.getCurrentToken();
	IntervalSet expecting = getExpectedTokens(recognizer);
	String msg = "missing " + expecting.toString(recognizer.getTokenNames()) + " at " + getTokenErrorDisplay(t);
	throw new RecognitionException(msg, recognizer, recognizer.getInputStream(), recognizer.getContext());
}
 
開發者ID:paypal,項目名稱:digraph-parser,代碼行數:9,代碼來源:GraphParser.java

示例5: reportUnwantedToken

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
protected void reportUnwantedToken(Parser recognizer) {
  if (!this.inErrorRecoveryMode(recognizer)) {
    this.beginErrorCondition(recognizer);
    Token t = recognizer.getCurrentToken();
    String tokenName = this.getTokenErrorDisplay(t);
    IntervalSet expecting = this.getExpectedTokens(recognizer);
    String msg =
        "extraneous input " + tokenName + " expecting "
        + expecting.toString(recognizer.getVocabulary());
    recognizer.notifyErrorListeners(t, msg, (RecognitionException) null);
  }
}
 
開發者ID:confluentinc,項目名稱:ksql,代碼行數:13,代碼來源:KsqlParserErrorStrategy.java

示例6: reportMissingToken

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
protected void reportMissingToken(Parser recognizer) {
  if (!this.inErrorRecoveryMode(recognizer)) {
    this.beginErrorCondition(recognizer);
    Token t = recognizer.getCurrentToken();
    IntervalSet expecting = this.getExpectedTokens(recognizer);
    String msg =
        "missing " + expecting.toString(recognizer.getVocabulary()) + " at " + this
            .getTokenErrorDisplay(t);
    recognizer.notifyErrorListeners(t, msg, (RecognitionException) null);
  }
}
 
開發者ID:confluentinc,項目名稱:ksql,代碼行數:12,代碼來源:KsqlParserErrorStrategy.java

示例7: consumeUntil

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
@Override
protected void consumeUntil(Parser recognizer, IntervalSet set) {
	Token o = recognizer.getCurrentToken();
	if ( o.getType()==Token.EOF ) {
		recognizer.getRuleContext().addErrorNode(o);
	}
	super.consumeUntil(recognizer, set);
}
 
開發者ID:antlr,項目名稱:jetbrains,代碼行數:9,代碼來源:ErrorStrategyAdaptor.java

示例8: getMissingSymbol

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
/** By default ANTLR makes the start/stop -1/-1 for invalid tokens
 *  which is reasonable but here we want to highlight the
 *  current position indicating that is where we lack a token.
 *  if no input, highlight at position 0.
 */
protected Token getMissingSymbol(Parser recognizer) {
	Token missingSymbol = super.getMissingSymbol(recognizer);
	// alter the default missing symbol.
	if ( missingSymbol instanceof CommonToken) {
		int start, stop;
		Token current = recognizer.getCurrentToken();
		start = current.getStartIndex();
		stop = current.getStopIndex();
		((CommonToken) missingSymbol).setStartIndex(start);
		((CommonToken) missingSymbol).setStopIndex(stop);
	}
	return missingSymbol;
}
 
開發者ID:antlr,項目名稱:jetbrains,代碼行數:19,代碼來源:ErrorStrategyAdaptor.java

示例9: reportMissingToken

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
@Override
public void reportMissingToken(Parser recognizer) {
    beginErrorCondition(recognizer);
    Token t = recognizer.getCurrentToken();
    IntervalSet expecting = getExpectedTokens(recognizer);
    String msg = "";
    msg += "In file " + recognizer.getSourceName() + " at line " + recognizer.getContext().start.getLine() + ": ";
    msg += "Missing "+expecting.toString(recognizer.getTokenNames()) + " at " + getTokenErrorDisplay(t) + ";";
    //msg += "Line Number " + recognizer.getContext().start.getLine() + ", Column " + recognizer.getContext().start.getCharPositionInLine() + ";";
    throw new RecognitionException(msg, recognizer, recognizer.getInputStream(), recognizer.getContext());
}
 
開發者ID:FIWARE-Middleware,項目名稱:KIARA,代碼行數:12,代碼來源:ParserExceptionErrorStrategyImpl.java


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