本文整理汇总了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);
}
示例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);
}
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}