![]() |
1
2
好吧,这个错误是因为
然后在lexer注释规则中,使用 gated semantic predicates 将该helper方法作为谓词中的布尔表达式:
演示语法:
还有一个主要的类来测试它:
然后执行以下命令: java -cp antlr-3.2.jar org.antlr.Tool DComments.g javac -cp antlr-3.2.jar *.java java -cp .:antlr-3.2.jar Main
(对于Windows,最后一个命令是:
产生以下输出: comment :: /+ comment /+ and +/ comment +/ comment :: /+ comment +/ |
![]() |
paranoider · /ANTLR解析器规则中的s/s 7 年前 |
![]() |
tuk · Antlr分析规则,用于分析具有匹配大括号的字符串 7 年前 |
![]() |
Ritwik Bhar · Antlr-解析多行#为C.g4定义 7 年前 |