protected void reportNoViableAlternative(@NotNull Parser recognizer, @NotNull NoViableAltException e)
{
TokenStream tokens = recognizer.getInputStream();
String input;
if (tokens instanceof TokenStream)
{
if (e.getStartToken().getType() == Token.EOF)
input = "<文件尾>";
else
input = tokens.getText(e.getStartToken(), e.getOffendingToken());
}
else
{
input = "<未知输入>";
}
BeetlException exception = null;
if(keys.contains(e.getOffendingToken().getText())){
exception = new BeetlParserException(BeetlException.PARSER_VIABLE_ERROR,
"不允许"+e.getOffendingToken().getText()+"关键出现在这里"+":"+escapeWSAndQuote(input), e);
}else{
exception = new BeetlParserException(BeetlException.PARSER_VIABLE_ERROR,
escapeWSAndQuote(input), e);
}
// String msg = "no viable alternative at input " + escapeWSAndQuote(input);
exception.pushToken(this.getGrammarToken(e.getOffendingToken()));
throw exception;
}
BeetlAntlrErrorStrategy.java 文件源码
java
阅读 26
收藏 0
点赞 0
评论 0
项目:beetl2.0
作者:
评论列表
文章目录