【发布时间】:2016-07-19 11:13:26
【问题描述】:
我有一个习惯 ParsingException(String message, int location, String offendingText)
我希望我的解析器在遇到解析/词法分析错误时抛出此异常。
这是正确的吗?
@parser::members
{
@Override
public void notifyErrorListeners(Token offendingToken, String msg, RecognitionException ex)
{
throw new ParsingException(msg,offendingToken.getStartIndex(),offendingToken.getText());
}
}
@lexer::members {
@Override
public void recover(RecognitionException ex)
{
throw new ParsingException(ex.getMessage(),getCharPositionInLine(),ex.getOffendingToken().getText());
}
}
我收到一个 UnhandledException 错误。
【问题讨论】:
标签: java parsing error-handling exception-handling antlr4