org.antlr.v4.runtime.FailedPredicateException Java Examples
The following examples show how to use
org.antlr.v4.runtime.FailedPredicateException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KsqlParserErrorStrategy.java From ksql-fork-with-deep-learning-function with Apache License 2.0 | 6 votes |
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); } } }
Example #2
Source File: DescriptiveErrorStrategy.java From groovy with Apache License 2.0 | 6 votes |
@Override public void recover(Parser recognizer, RecognitionException e) { for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) { context.exception = e; } if (PredictionMode.LL.equals(recognizer.getInterpreter().getPredictionMode())) { 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); } } throw new ParseCancellationException(e); }
Example #3
Source File: BeetlAntlrErrorStrategy.java From beetl2.0 with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void reportError(Parser recognizer, RecognitionException e) { // if we've already reported an error and have not matched a token // yet successfully, don't report any errors. if (inErrorRecoveryMode(recognizer)) { // System.err.print("[SPURIOUS] "); return; // don't report spurious errors } beginErrorCondition(recognizer); if (e instanceof NoViableAltException) { reportNoViableAlternative(recognizer, (NoViableAltException) e); } else if (e instanceof InputMismatchException) { reportInputMismatch(recognizer, (InputMismatchException) e); } else if (e instanceof FailedPredicateException) { reportFailedPredicate(recognizer, (FailedPredicateException) e); } else { // System.err.println("unknown recognition error type: " + e.getClass().getName()); BeetlException exception = new BeetlException(BeetlException.PARSER_UNKNOW_ERROR, e.getClass().getName(), e); // exception.token = this.getGrammarToken(e.getOffendingToken()); exception.pushToken(this.getGrammarToken(e.getOffendingToken())); throw exception; } }
Example #4
Source File: BeetlAntlrErrorStrategy.java From beetl2.0 with BSD 3-Clause "New" or "Revised" License | 5 votes |
protected void reportFailedPredicate(@NotNull Parser recognizer, @NotNull FailedPredicateException e) { String ruleName = recognizer.getRuleNames()[recognizer.getContext().getRuleIndex()]; BeetlException exception = new BeetlParserException(BeetlException.PARSER_PREDICATE_ERROR, ruleName, e); // exception.token = this.getGrammarToken(e.getOffendingToken()); exception.pushToken(this.getGrammarToken(e.getOffendingToken())); throw exception; }
Example #5
Source File: DescriptiveErrorStrategy.java From groovy with Apache License 2.0 | 4 votes |
protected String createFailedPredicateErrorMessage(Parser recognizer, FailedPredicateException e) { return e.getMessage(); }
Example #6
Source File: DescriptiveErrorStrategy.java From groovy with Apache License 2.0 | 4 votes |
protected void reportFailedPredicate(Parser recognizer, FailedPredicateException e) { notifyErrorListeners(recognizer, this.createFailedPredicateErrorMessage(recognizer, e), e); }
Example #7
Source File: GroovyLangParser.java From groovy with Apache License 2.0 | 4 votes |
@Override protected FailedPredicateException createFailedPredicateException(String predicate, String message) { return new LightWeightFailedPredicateException(this, predicate, message); }