List of usage examples for org.antlr.v4.runtime InputMismatchException getExpectedTokens
public IntervalSet getExpectedTokens()
From source file:org.beetl.core.parser.BeetlAntlrErrorStrategy.java
License:BSD License
protected void reportInputMismatch(@NotNull Parser recognizer, @NotNull InputMismatchException e) { String msg = " " + getTokenErrorDisplay(e.getOffendingToken()) + " " + e.getExpectedTokens().toString(recognizer.getTokenNames()); BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg, e); exception.token = this.getGrammarToken(e.getOffendingToken()); throw exception; }
From source file:org.fiware.kiara.generator.exceptions.ExceptionErrorStrategy.java
License:Open Source License
@Override public void reportInputMismatch(Parser recognizer, InputMismatchException e) throws RecognitionException { String msg = ""; msg += "In file " + recognizer.getSourceName() + " at line " + recognizer.getContext().start.getLine() + ": "; msg += "Mismatched input " + getTokenErrorDisplay(e.getOffendingToken()); msg += " expecting one of " + e.getExpectedTokens().toString(recognizer.getTokenNames()) + "\n"; msg += "Line Number " + recognizer.getContext().start.getLine() + ", Column " + recognizer.getContext().start.getCharPositionInLine() + ";"; RecognitionException ex = new RecognitionException(msg, recognizer, recognizer.getInputStream(), recognizer.getContext());// ww w . ja v a2 s. co m ex.initCause(e); throw ex; }