-1
使用JavaCC 6.0_1,并将JDK_VERSION设置为(默认值)1.5, 我无法使用ParseException的getErrorOffset方法 - 尽管存在Java docs stating that it exists。ParseException找不到符号getErrorOffset
有什么我错过了吗?
最低例如:
PARSER_BEGIN(B)
class B {
public static void main(String[] args) {
ParseException p = new ParseException("Test", 2);
System.out.println(p.getErrorOffset());
}
}
PARSER_END(B)
TOKEN: {<TRIVIAL: "foo">}
结果:
$ javacc B.jj
[...]
Parser generated successfully.
$ javac ./*.java
./B.java:5: error: no suitable constructor found for ParseException(String,int)
ParseException p = new ParseException("Test", 2);
^
constructor ParseException.ParseException(Token,int[][],String[]) is not applicable
(actual and formal argument lists differ in length)
constructor ParseException.ParseException() is not applicable
(actual and formal argument lists differ in length)
constructor ParseException.ParseException(String) is not applicable
(actual and formal argument lists differ in length)
./B.java:6: error: cannot find symbol
System.out.println(p.getErrorOffset());
^
symbol: method getErrorOffset()
location: variable p of type ParseException
2 errors
(第二误差同样地,表示ParseException的的 “误差偏移” 部分是神秘缺席...)
这不是一个真正的问题。这只是一个声明,你不能做一些无法完成的事情。您无法调用方法。如果你想知道为什么你不能使用这种方法,那是因为没有这种方法。 如果您遇到需要帮助解决的实际问题:例如, “我如何找到与ParseException相关的源坐标?”那么我建议你关闭这个问题,并问问你实际上需要一个答案,如果你不能自己回答。 –