作为ANTLR的新手,我遇到了一个问题:我的语法包括
COMMENT : ( '*' {getCharPositionInLine()==0}? .* NL
| '*' {getCharPositionInLine()>0}? .* NL {System.out.println("* at wrong position"); notifyListeners("xxx");}
);这意味着我想检查一行是否以* (OK)开头,或者*是否在另一个位置(错误)。
在IntelliJ IDEA中,我得到以下编译错误:
Error:(106, 68) java: cannot find symbol
symbol: method notifyErrorListeners(java.lang.String)
location: class MQSC.MQSCLexer由于这似乎是“确定的ANTLR4参考”一书中所描述的解决方案,我被卡住了。这是正确的方式吗,我错过了什么吗?
发布于 2017-02-24 21:25:02
对于Maven项目,您似乎需要在类路径中使用ANTLR Java Runtime依赖项,这将是:
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.6</version>
</dependency>否则,下载antlr-runtime-4.6.jar并将其添加到module dependencies中。
https://stackoverflow.com/questions/42439391
复制相似问题