@Override public void enterAlter_view(Alter_viewContext ctx) { throw new ParseCancellationException("Not finishing parse of ALTER VIEW"); }
@Override public void enterCreate_view(Create_viewContext ctx) { throw new ParseCancellationException("Not finishing parse of CREATE VIEW"); }
public class ThrowingErrorListener extends BaseErrorListener { public static final ThrowingErrorListener INSTANCE = new ThrowingErrorListener(); @Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) throws ParseCancellationException { throw new ParseCancellationException("line " + line + ":" + charPositionInLine + " " + msg); } }
/** Instead of recovering from exception {@code e}, re-throw it wrapped * in a {@link ParseCancellationException} so it is not caught by the * rule function catches. Use {@link Exception#getCause()} to get the * original {@link RecognitionException}. */ @Override public void recover(Parser recognizer, RecognitionException e) { for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) { context.exception = e; } throw new ParseCancellationException(e); }
/** Make sure we don't attempt to recover inline; if the parser * successfully recovers, it won't throw an exception. */ @Override public Token recoverInline(Parser recognizer) throws RecognitionException { InputMismatchException e = new InputMismatchException(recognizer); for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) { context.exception = e; } throw new ParseCancellationException(e); }
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { throw new ParseCancellationException(msg, e); } });
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { throw new ParseCancellationException(msg, e); } });
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) throws ParseCancellationException { throw new ParseCancellationException(msg); }
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) throws ParseCancellationException { throw new ParseCancellationException("line " + line + ":" + charPositionInLine + " " + msg); } }
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) throws ParseCancellationException { throw new ParseCancellationException("line " + line + ":" + charPositionInLine + " " + msg); } }
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { throw new ParseCancellationException(msg, e); } });
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) { throw new ParseCancellationException("line " + line + ":" + charPositionInLine + " " + msg); }
@Override public void syntaxError( Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException ex) throws ParseCancellationException { throw new ParseCancellationException("line " + line + ":" + charPositionInLine + " " + msg, ex); } });
private static <T> T checkFound(String expression, T instance) { if (instance != null) { return instance; } throw new ParseCancellationException( format( "variable [%s] not found", expression ) ); }
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) throws ParseCancellationException { log.debug("Syntax error location: column " + charPositionInLine + "\n" + msg); throw new ParseCancellationException("Syntax error location: column " + charPositionInLine + "\n" + msg); } }
@Override public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, RecognitionException e) throws ParseCancellationException { log.debug("Syntax error location: column " + charPositionInLine + "\n" + msg); throw new ParseCancellationException("Syntax error location: column " + charPositionInLine + "\n" + msg); } }
/** Instead of recovering from exception {@code e}, re-throw it wrapped * in a {@link ParseCancellationException} so it is not caught by the * rule function catches. Use {@link Exception#getCause()} to get the * original {@link RecognitionException}. */ @Override public void recover(Parser recognizer, RecognitionException e) { for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) { context.exception = e; } throw new ParseCancellationException(e); }
/** Instead of recovering from exception {@code e}, re-throw it wrapped * in a {@link ParseCancellationException} so it is not caught by the * rule function catches. Use {@link Exception#getCause()} to get the * original {@link RecognitionException}. */ @Override public void recover(Parser recognizer, RecognitionException e) { for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) { context.exception = e; } throw new ParseCancellationException(e); }
/** Instead of recovering from exception {@code e}, re-throw it wrapped * in a {@link ParseCancellationException} so it is not caught by the * rule function catches. Use {@link Exception#getCause()} to get the * original {@link RecognitionException}. */ @Override public void recover(Parser recognizer, RecognitionException e) { for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) { context.exception = e; } throw new ParseCancellationException(e); }
@Override public Token recoverInline(Parser recognizer) throws RecognitionException { InputMismatchException e = new InputMismatchException(recognizer); for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) { context.exception = e; } throw new ParseCancellationException(e); } }