List of usage examples for org.antlr.v4.runtime FailedPredicateException getOffendingToken
public Token getOffendingToken()
From source file:com.nextbreakpoint.nextfractal.contextfree.compiler.CompilerErrorStrategy.java
License:Open Source License
@Override protected void reportFailedPredicate(Parser recognizer, FailedPredicateException e) { String message = generateErrorMessage("Failed predicate", recognizer); CompilerError error = new CompilerError(CompilerError.ErrorType.CFDG_COMPILER, e.getOffendingToken().getLine(), e.getOffendingToken().getCharPositionInLine(), e.getOffendingToken().getStartIndex(), recognizer.getCurrentToken().getStopIndex() - recognizer.getCurrentToken().getStartIndex(), message);// w w w . j a v a2 s.c o m logger.log(Level.FINE, error.toString(), e); errors.add(error); }
From source file:com.nextbreakpoint.nextfractal.mandelbrot.compiler.CompilerErrorStrategy.java
License:Open Source License
@Override protected void reportFailedPredicate(Parser recognizer, FailedPredicateException e) { String message = generateErrorMessage("Failed predicate", recognizer); CompilerError error = new CompilerError(CompilerError.ErrorType.M_COMPILER, e.getOffendingToken().getLine(), e.getOffendingToken().getCharPositionInLine(), e.getOffendingToken().getStartIndex(), recognizer.getCurrentToken().getStopIndex() - recognizer.getCurrentToken().getStartIndex(), message);// ww w.j a v a 2 s . co m logger.log(Level.FINE, error.toString(), e); errors.add(error); }
From source file:com.sample.JavaErrorStrategy.java
License:BSD License
/** * This is called by {@link #reportError} when the exception is a * {@link FailedPredicateException}.//from ww w . j a va2 s. c om * * @see #reportError * * @param recognizer * the parser instance * @param e * the recognition exception */ protected void reportFailedPredicate(@NotNull Parser recognizer, @NotNull FailedPredicateException e) { String ruleName = recognizer.getRuleNames()[recognizer.getContext().getRuleIndex()]; String msg = "rule " + ruleName + " " + e.getMessage(); recognizer.notifyErrorListeners(e.getOffendingToken(), msg, e); }
From source file:org.beetl.core.parser.BeetlAntlrErrorStrategy.java
License:BSD License
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()); throw exception; }