Class SyntaxErrorListener

java.lang.Object
org.antlr.v4.runtime.BaseErrorListener
dev.frostlake.parser.SyntaxErrorListener
All Implemented Interfaces:
org.antlr.v4.runtime.ANTLRErrorListener

public class SyntaxErrorListener extends org.antlr.v4.runtime.BaseErrorListener
Custom ANTLR error listener that collects syntax errors and throws them in live Snowflake's wording (live-verified): every error renders on its own line under the one compilation-error prefix — a parser error as syntax error line L at position P unexpected 'TOK'. (token text verbatim, '<EOF>' at end of input), a lexer error (an unterminated literal or quoted identifier — the lexer consumed to end of input) as parse error line L at position P near '<EOF>'. positioned at the END of the input. The raw ANTLR diagnostics ("mismatched input ... expecting ...") stay available through SqlSyntaxException.getSyntaxErrors() and the logs.
  • Constructor Details

    • SyntaxErrorListener

      public SyntaxErrorListener(String sql)
    • SyntaxErrorListener

      public SyntaxErrorListener(String sql, boolean quiet)
  • Method Details

    • syntaxError

      public void syntaxError(org.antlr.v4.runtime.Recognizer<?,?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String msg, org.antlr.v4.runtime.RecognitionException e)
      Specified by:
      syntaxError in interface org.antlr.v4.runtime.ANTLRErrorListener
      Overrides:
      syntaxError in class org.antlr.v4.runtime.BaseErrorListener
    • firstErrorIsMissingTerminator

      public boolean firstErrorIsMissingTerminator()
      Whether the FIRST error was a block's statement ending without its semicolon: the engine read that statement whole, so no construct it does not know can explain the fault, and a CREATE may refuse the body as the account does.
    • hasErrors

      public boolean hasErrors()
    • getErrors

      public List<String> getErrors()
    • statementParse

      public void statementParse()
      Mark this listener as watching a whole STATEMENT, which enables the leading-token rule.
    • throwIfErrors

      public void throwIfErrors()