【问题标题】:Errors when compiling a grammar编译语法时的错误
【发布时间】:2014-05-09 19:32:27
【问题描述】:

我有一个语法 P.g,直到最近才安静地编译。今天当我在命令提示符下输入:

java -cp .;../antlr-3.5-complete.jar org.antlr.Tool P.g

(语法在文件夹gram中,而antlr-3.5-complete.jar在父文件夹中,提示放在文件夹gram中。)

产生以下错误:

warning(24):  template error: context [/outputFile /parser /genericParser /region__/genericParser__m
embers] 32:3 no such property or can't access: org.antlr.tool.Grammar.indirectDelegates
Caused by: org.stringtemplate.v4.misc.STNoSuchPropertyException: no such property: org.antlr.tool.Gr
ammar.indirectDelegates
        at org.stringtemplate.v4.misc.ObjectModelAdaptor.throwNoSuchProperty(ObjectModelAdaptor.java
:106)
        at org.stringtemplate.v4.misc.ObjectModelAdaptor.lookupMethod(ObjectModelAdaptor.java:99)
        at org.stringtemplate.v4.misc.ObjectModelAdaptor.getProperty(ObjectModelAdaptor.java:67)
        at org.stringtemplate.v4.Interpreter.getObjectProperty(Interpreter.java:1158)
        at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:210)
        at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
        at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:703)
        at org.stringtemplate.v4.Interpreter.writeObjectNoOptions(Interpreter.java:635)
        at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:285)
        at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
        at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:703)
        at org.stringtemplate.v4.Interpreter.writeObjectNoOptions(Interpreter.java:635)
        at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:285)
        at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
        at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:703)
        at org.stringtemplate.v4.Interpreter.writeObjectNoOptions(Interpreter.java:635)
        at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:285)
        at org.stringtemplate.v4.Interpreter.exec(Interpreter.java:145)
        at org.stringtemplate.v4.ST.write(ST.java:415)
        at org.antlr.codegen.CodeGenerator.write(CodeGenerator.java:1296)
        at org.antlr.codegen.Target.genRecognizerFile(Target.java:98)
        at org.antlr.codegen.CodeGenerator.genRecognizer(CodeGenerator.java:459)
        at org.antlr.Tool.generateRecognizer(Tool.java:696)
        at org.antlr.Tool.process(Tool.java:509)
        at org.antlr.Tool.main(Tool.java:98)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.stringtemplate.v4.misc.Misc.invokeMethod(Misc.java:218)
        at org.stringtemplate.v4.misc.ObjectModelAdaptor.lookupMethod(ObjectModelAdaptor.java:84)
        ... 23 more
Caused by: java.lang.NullPointerException
        at java.util.Objects.requireNonNull(Unknown Source)
        at java.util.ArrayList.removeAll(Unknown Source)
        at org.antlr.tool.CompositeGrammar.getIndirectDelegates(CompositeGrammar.java:226)
        at org.antlr.tool.Grammar.getIndirectDelegates(Grammar.java:2722)
        ... 29 more

我没有改变任何东西。所有这些错误是由什么引起的?

非常感谢

【问题讨论】:

    标签: compilation antlr grammar


    【解决方案1】:

    使用 Java8 会出现这种情况,请尝试切换回 7

    【讨论】:

    • 为什么在 java8 中会发生这种情况?
    【解决方案2】:

    antlr 3.5最新版本没有这个问题(3.5.2)

    【讨论】:

    • 使用 antlr-3.5.2-complete.jar 可以在 macOS Sierra 上运行...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多