ParserErrorListener.java 文件源码

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

项目:freelib-edtf 作者:
public void syntaxError(Recognizer<?, ?> aRecognizer,
        Object aOffendingSymbol, int aLine, int aCharIndex,
        String aMessage, RecognitionException aException) {
    ANTLRErrorStrategy errorHandler = myParser.getErrorHandler();

    if (LOGGER.isWarnEnabled()) {
        LOGGER.warn(aMessage + " [" + aLine + ":" + aCharIndex + "]");
    }

    /*
     * Setting the lexer exception in the parser since I don't see a
     * getNumberOfSyntaxErrors() method in the lexer (like in antlr3) and
     * the lexer's errors aren't being reported by parser's method
     * 
     * I may just be missing the correct way this should be handled(?)
     */
    if (aException instanceof LexerNoViableAltException) {
        NoViableAltException exception = new NoViableAltException(myParser);
        errorHandler.reportError(myParser, exception);
    }
    else {
        errorHandler.reportError(myParser, aException);
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号