ANTLR4 notifyErrorListeners
ANTLR4 notifyErrorListeners
作为 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
因为这似乎是书中描述的解决方案"The definitive ANTLR4 reference",我被卡住了。这是正确的方法吗,我错过了什么吗?
您的类路径中似乎需要 ANTLR Java 运行时依赖项,对于 Maven 项目来说:
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.6</version>
</dependency>
否则下载antlr-runtime-4.6.jar and add it to the module dependencies.
作为 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
因为这似乎是书中描述的解决方案"The definitive ANTLR4 reference",我被卡住了。这是正确的方法吗,我错过了什么吗?
您的类路径中似乎需要 ANTLR Java 运行时依赖项,对于 Maven 项目来说:
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
<version>4.6</version>
</dependency>
否则下载antlr-runtime-4.6.jar and add it to the module dependencies.