BeetlAntlrErrorStrategy.java 文件源码

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

项目:beetl2.0 作者:
@Override
public void reportError(Parser recognizer, RecognitionException e)
{
    // if we've already reported an error and have not matched a token
    // yet successfully, don't report any errors.
    if (inErrorRecoveryMode(recognizer))
    {
        //          System.err.print("[SPURIOUS] ");
        return; // don't report spurious errors
    }
    beginErrorCondition(recognizer);
    if (e instanceof NoViableAltException)
    {
        reportNoViableAlternative(recognizer, (NoViableAltException) e);
    }
    else if (e instanceof InputMismatchException)
    {
        reportInputMismatch(recognizer, (InputMismatchException) e);
    }
    else if (e instanceof FailedPredicateException)
    {
        reportFailedPredicate(recognizer, (FailedPredicateException) e);
    }
    else
    {
        //          System.err.println("unknown recognition error type: " + e.getClass().getName());
        BeetlException exception = new BeetlException(BeetlException.PARSER_UNKNOW_ERROR, e.getClass().getName(), e);
        //          exception.token = this.getGrammarToken(e.getOffendingToken());
        exception.pushToken(this.getGrammarToken(e.getOffendingToken()));

        throw exception;
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号