presto-parser/src/main/java/io/prestosql/sql/parser/ErrorHandler.java/ErrorHandler/syntaxError
class ErrorHandler:    @Override
    public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line, int charPositionInLine, String message, RecognitionException e)
    {
        try {
            Parser parser = (Parser) recognizer;

            ATN atn = parser.getATN();

            ATNState currentState;
            Token currentToken;
            RuleContext context;

            if (e != null) {
                currentState = atn.states.get(e.getOffendingState());
                currentToken = e.getOffendingToken();
                context = e.getCtx();

                if (e instanceof NoViableAltException) {
                    currentToken = ((NoViableAltException) e).getStartToken();
                }
            }
            else {
                currentState = atn.states.get(parser.getState());
                currentToken = parser.getCurrentToken();
                context = parser.getContext();
            }

            Analyzer analyzer = new Analyzer(parser, specialRules, specialTokens, ignoredRules);
            Result result = analyzer.process(currentState, currentToken.getTokenIndex(), context);

            // pick the candidate tokens associated largest token index processed (i.e., the path that consumed the most input)
            String expected = result.getExpected().stream()
                    .sorted()
                    .collect(Collectors.joining(", "));

            message = format("mismatched input '%s'. Expecting: %s", parser.getTokenStream().get(result.getErrorTokenIndex()).getText(), expected);
        }
        catch (Exception exception) {
            LOG.error(exception, "Unexpected failure when handling parsing error. This is likely a bug in the implementation");
        }

        throw new ParsingException(message, e, line, charPositionInLine);
    }