当前位置: 首页>>代码示例>>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;未经允许,请勿转载。