CompileErrorStrategy.java 文件源码

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

项目:BigDataScript 作者:
/** Make sure we don't attempt to recover inline; if the parser
 *  successfully recovers, it won't throw an exception.
 */
@Override
public Token recoverInline(Parser recognizer) throws RecognitionException {
    InputMismatchException e = new InputMismatchException(recognizer);

    String message = "Cannot parse input, near '" + e.getOffendingToken().getText() + "'";
    CompilerMessage cm = new CompilerMessage(e.getOffendingToken().getInputStream().getSourceName(), e.getOffendingToken().getLine(), -1, message, MessageType.ERROR);
    CompilerMessages.get().add(cm);

    // Add exception to all contexts
    for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent())
        context.exception = e;

    throw new ParseCancellationException(e);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号