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


Java Parser.notifyErrorListeners方法代碼示例

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


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

示例1: reportNoViableAlternative

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
@Override
protected void reportNoViableAlternative(Parser recognizer, NoViableAltException e) {
	// change error message from default implementation
	TokenStream tokens = recognizer.getInputStream();
	String input;
	if (tokens != null) {
		if (e.getStartToken().getType() == Token.EOF) {
			input = "the end";
		} else {
			input = escapeWSAndQuote(tokens.getText(e.getStartToken(), e.getOffendingToken()));
		}
	} else {
		input = escapeWSAndQuote("<unknown input>");
	}
	String msg = "inadmissible input at " + input;
	recognizer.notifyErrorListeners(e.getOffendingToken(), msg, e);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:18,代碼來源:CapitulatingErrorStrategy.java

示例2: reportError

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
public void reportError(Parser recognizer, RecognitionException e) {
  if (!this.inErrorRecoveryMode(recognizer)) {
    this.beginErrorCondition(recognizer);
    if (e instanceof NoViableAltException) {
      this.reportNoViableAlternative(recognizer, (NoViableAltException) e);
    } else if (e instanceof InputMismatchException) {
      this.reportInputMismatch(recognizer, (InputMismatchException) e);
    } else if (e instanceof FailedPredicateException) {
      this.reportFailedPredicate(recognizer, (FailedPredicateException) e);
    } else {
      System.err.println("unknown recognition error type: " + e.getClass().getName());
      recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e);
    }

  }
}
 
開發者ID:confluentinc,項目名稱:ksql,代碼行數:17,代碼來源:KsqlParserErrorStrategy.java

示例3: reportNoViableAlternative

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
protected void reportNoViableAlternative(Parser recognizer, NoViableAltException e) {
  TokenStream tokens = recognizer.getInputStream();
  String input;
  if (tokens != null) {
    if (e.getStartToken().getType() == -1) {
      input = "<EOF>";
    } else {
      input = tokens.getText(e.getStartToken(), e.getOffendingToken());
    }
  } else {
    input = "<unknown input>";
  }

  String msg = "no viable alternative at input " + this.escapeWSAndQuote(input);
  recognizer.notifyErrorListeners(e.getOffendingToken(), msg, e);
}
 
開發者ID:confluentinc,項目名稱:ksql,代碼行數:17,代碼來源:KsqlParserErrorStrategy.java

示例4: reportNoViableAlternative

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public void reportNoViableAlternative(@NotNull Parser recognizer, @NotNull NoViableAltException e)
{
    TokenStream tokens = recognizer.getInputStream();
    String input;
    if (tokens instanceof TokenStream)
    {
        if (e.getStartToken().getType() == Token.EOF)
            input = "<EOF>";
        else
            input = getText(tokens, e.getStartToken(), e.getOffendingToken());
    }
    else
    {
        input = "<unknown input>";
    }
    String msg = "no viable alternative at input " + escapeWSAndQuote(input);
    recognizer.notifyErrorListeners(e.getOffendingToken(), msg, e);
}
 
開發者ID:HuaweiBigData,項目名稱:StreamCQL,代碼行數:23,代碼來源:CQLErrorStrategy.java

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

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

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

示例8: reportError

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
@Override
public void reportError(Parser recognizer, RecognitionException e) {
  if (e instanceof InvalidSignatureException) {
    recognizer.notifyErrorListeners(e.getOffendingToken(), e.getMessage(), e);
    return;
  }
  super.reportError(recognizer, e);
}
 
開發者ID:impossibl,項目名稱:stencil,代碼行數:9,代碼來源:StencilErrorStrategy.java

示例9: reportInputMismatch

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
@Override
protected void reportInputMismatch(Parser recognizer, InputMismatchException e) {
	// change error message from default implementation
	String msg = "mismatched input " + getTokenErrorDisplay(e.getOffendingToken()) + " expecting operator";
	recognizer.notifyErrorListeners(e.getOffendingToken(), msg, e);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:7,代碼來源:CapitulatingErrorStrategy.java

示例10: reportInputMismatch

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
protected void reportInputMismatch(Parser recognizer, InputMismatchException e) {
  String msg =
      "Syntax error. There is a mismatch between the expected term and te term in the query. "
      + "Please check the line and column in the query.";
  recognizer.notifyErrorListeners(e.getOffendingToken(), msg, e);
}
 
開發者ID:confluentinc,項目名稱:ksql,代碼行數:7,代碼來源:KsqlParserErrorStrategy.java

示例11: reportNoViableAlternative

import org.antlr.v4.runtime.Parser; //導入方法依賴的package包/類
/**
 * @see DefaultErrorStrategy#reportNoViableAlternative
 */
@Override
protected void reportNoViableAlternative(Parser parser, NoViableAltException e) {
    String msg = "can't choose between alternatives"; // nonstandard msg
    parser.notifyErrorListeners(e.getOffendingToken(), msg, e);
}
 
開發者ID:globalforge,項目名稱:infix,代碼行數:9,代碼來源:FixRulesErrorStrategy.java


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