LexerErrorListener.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:elasticsearch-jdbc 作者:
@Override
public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int line,
                        int charPositionInLine, String msg, RecognitionException e) {

    String position = "line " + line + ", pos " + charPositionInLine;
    String charText = "";
    String hint = "";
    if (recognizer != null && recognizer instanceof Lexer) {
        Lexer lexer = (Lexer) recognizer;
        String fullText = lexer.getInputStream().toString();
        charText = String.valueOf(fullText.charAt(lexer.getCharIndex()));
        hint = AntlrUtils.underlineError(fullText, charText, line, charPositionInLine);
    }
    throw new LexicalErrorException(position + " near " + charText + " : " + msg + "\n" + hint, e);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号