相同的 oracle SQL 语法使用 Antlr-3.3-complete.jar 生成且没有错误,并使用 Netbeans/GCC 或 Visual Studio 成功编译。
使用 Antlr-3.5-complete.jar 生成语法会生成 23500 行警告消息,描述模板错误,包括数百个异常。
代码是使用以下命令行生成的:
java -d64 -Xmn2000M -Xmx8000M -jar antlr-3.5-complete.jar OracleSQL_v2.g
antlr-3.5-complete.jar 于 2013 年 3 月 22 日从 antlr.org 网站下载。
该语法基于 Ivan.Brezina 发布的 antlr.org 站点中的 Oracle PL/SQL 语法。
生成的代码有 282 个未声明的标识符。许多$tokenRef
变量在生成的解析器 synpred 子例程中未声明。此外,生成的词法分析器有 100 个案例
error C2065: '_empty' : undeclared identifier
这是模板错误的子集:
warning(24): template error: context [/outputFile /parser] 1:1 could not pass through undefined attribute filterMode
600+ duplicate errors:
warning(24): template error: context [/outputFile /parser /genericParser /_sub45 /ruleAttributeScopeFuncMacro] 1:4 no such property or can't access: null.attributes
warning(24): template error: context [/outputFile /parser /genericParser] 155:5 no such property or can't access: null.apifuncs
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleInitializations /ruleInitializations] 4:1 no such property or can't access: null.attributes
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleBlockSingleAlt /alt /element /matchSet /matchSet /_sub127 /createNodeFromToken] 1:4 no such property or can't access: null.node
20 duplicate errors:
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleInitializations /ruleInitializations] 4:1 no such property or can't access: null.attributes
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleBlockSingleAlt /alt /element /block /_sub86 /altSwitchCase /alt /element /blockSingleAlt /alt /rewriteCode /rewriteAlt /rewriteElementList /rewriteElement /rewriteTree /rewriteElement /rewriteImaginaryTokenRefRoot /createImaginaryNode] 1:4 no such property or can't access: null.node
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleBlockSingleAlt /alt /element /block /_sub86 /altSwitchCase /alt /element /blockSingleAlt /alt /rewriteCode /rewriteAlt /rewriteElementList /rewriteElement /rewriteTree /rewriteElement /rewriteOptionalBlock /rewriteElementList /rewriteElement /rewriteTokenRef /createRewriteNodeFromElement] 1:4 no such property or can't access: null.node
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleBlockSingleAlt /alt /element /block /_sub86 /altSwitchCase /alt /element /blockSingleAlt /alt /rewriteCode /rewriteAlt /rewriteElementList /rewriteElement /rewriteTree /rewriteElement /rewriteTree /rewriteElement /rewriteImaginaryTokenRefRoot /createImaginaryNode] 1:4 no such property or can't access: null.node
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleBlockSingleAlt /alt /element /block /_sub86 /altSwitchCase /alt /element /blockSingleAlt /alt /rewriteCode /rewriteAlt /rewriteElementList /rewriteElement /rewriteTree /rewriteElement /rewriteTree /rewriteElement /rewriteTokenRef /createRewriteNodeFromElement] 1:4 no such property or can't access: null.node
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleBlockSingleAlt /alt /element /block /_sub86 /altSwitchCase /alt /rewriteCode /rewriteAlt /rewriteElementList /rewriteElement /rewriteTree /rewriteElement /rewriteImaginaryTokenRefRoot /createImaginaryNode] 1:4 no such property or can't access: null.node
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleInitializations /ruleInitializations] 4:1 no such property or can't access: null.attributes
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleBlockSingleAlt /alt /rewriteCode /rewriteAlt /rewriteElementList /rewriteElement /rewriteTree /rewriteElement /rewriteImaginaryTokenRefRoot /createImaginaryNode] 1:4 no such property or can't access: null.node
warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleInitializations /ruleInitializations] 4:1 no such property or can't access: null.attributes
200+ duplicate exceptions:
Caused by: org.stringtemplate.v4.misc.STNoSuchPropertyException: no such property: java.lang.String.referencedRule
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.writeIterator(Interpreter.java:733)
at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:708)
at org.stringtemplate.v4.Interpreter.writeObjectWithOptions(Interpreter.java:665)
at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:292)
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.writeIterator(Interpreter.java:733)
at org.stringtemplate.v4.Interpreter.writeObject(Interpreter.java:708)
at org.stringtemplate.v4.Interpreter.writeObjectWithOptions(Interpreter.java:665)
at org.stringtemplate.v4.Interpreter._exec(Interpreter.java:292)
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.CTarget.genRecognizerFile(CTarget.java:54)
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.NoSuchFieldException: referencedRule
at java.lang.Class.getField(Class.java:1537)
at org.stringtemplate.v4.misc.ObjectModelAdaptor.lookupMethod(ObjectModelAdaptor.java:88)
... 35 more
1800+ duplicate errors for [headerReturnScope, ruleAttributeScopeDecl, and ruleDeclarations]:
warning(24): template error: context [/headerFile /_sub143 /ruleAttributeScopeDecl] 1:4 no such property or can't access: null.attributes