我正在尝试以 http://javacc.java.net/doc/errorrecovery.html中给出的 JavaCC 语法实现错误报告和恢复
提到代码后;
void Stm() :
{}
{
try {
(
IfStm()
|
WhileStm()
)
catch (ParseException e) {
error_skipto(SEMICOLON);
}
}
void error_skipto(int kind) {
ParseException e = generateParseException(); // generate the exception object.
System.out.println(e.toString()); // print the error message
Token t;
do {
t = getNextToken();
} while (t.kind != kind);
// The above loop consumes tokens all the way up to a token of
// "kind". We use a do-while loop rather than a while because the
// current token is the one immediately before the erroneous token
// (in our case the token immediately before what should have been
// "if"/"while".
}
JavaCC 无法解析该文件,在“尝试”字和行中显示错误
'void error_skipto(int kind)' .
这样做的正确方法是什么?
提前致谢
This is the error that is coming