Search in sources :

Example 6 with BeetlParserException

use of org.beetl.core.exception.BeetlParserException in project beetl2.0 by javamonkey.

the class BeetlAntlrErrorStrategy method reportMissingToken.

protected void reportMissingToken(@NotNull Parser recognizer) {
    if (inErrorRecoveryMode(recognizer)) {
        return;
    }
    beginErrorCondition(recognizer);
    // Token t = recognizer.getCurrentToken();
    Token t = recognizer.getTokenStream().LT(-1);
    IntervalSet expecting = getExpectedTokens(recognizer);
    String expect = expecting.toString(recognizer.getTokenNames());
    if (expects.containsKey(expect)) {
        expect = expects.get(expect);
    }
    if (expect.equals("'>>'")) {
        expect = "'模板的占位结束符号'";
    }
    String tokenStr = getTokenErrorDisplay(t);
    String msg = "缺少输入 " + expect + " 在 " + tokenStr + " 后面";
    BeetlException exception = new BeetlParserException(BeetlException.PARSER_MISS_ERROR, msg);
    exception.pushToken(this.getGrammarToken(t));
    throw exception;
}
Also used : BeetlException(org.beetl.core.exception.BeetlException) BeetlParserException(org.beetl.core.exception.BeetlParserException) IntervalSet(org.antlr.v4.runtime.misc.IntervalSet) GrammarToken(org.beetl.core.statement.GrammarToken) Token(org.antlr.v4.runtime.Token)

Aggregations

BeetlException (org.beetl.core.exception.BeetlException)6 BeetlParserException (org.beetl.core.exception.BeetlParserException)6 Token (org.antlr.v4.runtime.Token)3 GrammarToken (org.beetl.core.statement.GrammarToken)3 IntervalSet (org.antlr.v4.runtime.misc.IntervalSet)2 TokenStream (org.antlr.v4.runtime.TokenStream)1 IteratorStatus (org.beetl.core.IteratorStatus)1