このPHP EBNFを ANTLR v4 形式に移行しようとしています。
残念ながら、ANTLR は次のメッセージで壊れますcan't find rule grammarSpec or tree structure error
。
can't find rule grammarSpec or tree structure error:
(COMBINED_GRAMMAR Php (RULES (RULE start (BLOCK (ALT (top_statement_list 0))))
(RULE top_statement_list int _p (BLOCK (ALT (BLOCK (ALT {})) (* (BLOCK (ALT {2 >=
...
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.antlr.v4.parse.GrammarTreeVisitor.visit(GrammarTreeVisitor.java:206)
at org.antlr.v4.parse.GrammarTreeVisitor.visitGrammar(GrammarTreeVisitor.java:200)
at org.antlr.v4.semantics.SymbolCollector.process(SymbolCollector.java:76)
at org.antlr.v4.semantics.SemanticPipeline.process(SemanticPipeline.java:103)
at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:399)
at org.antlr.v4.Tool.process(Tool.java:384)
at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:343)
at org.antlr.v4.Tool.main(Tool.java:190)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
at org.antlr.v4.semantics.SymbolCollector.discoverOuterAlt(SymbolCollector.java:111)
at org.antlr.v4.parse.GrammarTreeVisitor.outerAlternative(GrammarTreeVisitor.java:2284)
at org.antlr.v4.parse.GrammarTreeVisitor.ruleBlock(GrammarTreeVisitor.java:2197)
at org.antlr.v4.parse.GrammarTreeVisitor.rule(GrammarTreeVisitor.java:1663)
at org.antlr.v4.parse.GrammarTreeVisitor.rules(GrammarTreeVisitor.java:1241)
at org.antlr.v4.parse.GrammarTreeVisitor.grammarSpec(GrammarTreeVisitor.java:480)
... 12 more
Exception in thread "main" java.lang.NullPointerException
at org.antlr.v4.tool.LeftRecursiveRule.getAltLabels(LeftRecursiveRule.java:91)
at org.antlr.v4.tool.Rule.hasAltSpecificContexts(Rule.java:200)
at org.antlr.v4.tool.LeftRecursiveRule.hasAltSpecificContexts(LeftRecursiveRule.java:60)
at org.antlr.v4.semantics.SymbolChecks.checkForLabelConflicts(SymbolChecks.java:150)
at org.antlr.v4.semantics.SymbolChecks.process(SymbolChecks.java:98)
at org.antlr.v4.semantics.SemanticPipeline.process(SemanticPipeline.java:107)
at org.antlr.v4.Tool.processNonCombinedGrammar(Tool.java:399)
at org.antlr.v4.Tool.process(Tool.java:384)
at org.antlr.v4.Tool.processGrammarsOnCommandLine(Tool.java:343)
at org.antlr.v4.Tool.main(Tool.java:190)
rules の数を減らすと、問題は発生しなくなりますが、ANTLR はシンボルの欠落について文句を言います。
エラーを追跡する方法のヒントを提供してくれる人はいますか? ルールの数を減らすための代替手段はありません。