2

同じOracleSQL文法は、Antlr-3.3-complete.jarを使用してエラーなしで生成され、Netbeans/GCCまたはVisualStudioを使用して正常にコンパイルされます。

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
4

3 に答える 3

2

3.5 より前のリリースのバグにより、これらのメッセージは意図せず抑制されていました。問題を修正するために一部のターゲットが更新されましたが、まだ更新されていない (指定していない) ターゲットを使用しているようです。

また、テンプレート エラーに関するメッセージは警告メッセージであり、エラーではないことに注意してください。出力は引き続き生成されるはずです。

コンパイラ エラーを再現するための小さな例を投稿できますか?

于 2013-03-22T20:00:49.783 に答える
0

同じエラーがあります。文法はhttp://www.antlr3.org/grammar/list.htmlから取得

エラーを再現するために必要なのは、ダウンロードして、添付の antlr-3.3-complete.jar の代わりに antlr-3.4-complete.jar (Makefile を変更) を提供し、Makefile を実行することだけです。

文法の処理中に多くの警告エラー。出力ソース ファイルは生成されますが、ANTLR 3.4 および 3.5 は次のような行を生成するため、コンパイルできません。

void ;
#undef RETURN_TYPE
#define RETURN_TYPE void

タイピング

grep undef.*RETURN_TYPE OracleSQLParser.c | nl
テンプレート C.stg を使用して、最初の 1135 件のケースが適切に入力されたことを示しています。1136 から生成されたソースの最後まで、すべてのオカレンスは void で埋められます。

出力を C ターゲットから Java に切り替えても、エラーは表示されません。

于 2013-03-25T06:45:09.853 に答える
0

「undeclared _empty」についても同じ問題が発生しました。私が見つけた最も簡単な例は次のとおりです。

foo: ( 'A'+ 'B' )+ 'A'+ ;

(このエラーケースは "Cyclic DFA" パターンに関連しているようですが、それが実際に何を意味するのかわかりません。)

ANTLR 3.5.1 は、次のようなパーサー ソースを生成します。

static const ANTLR3_INT32 * const dfa2_transitions[] =
{
    dfa2_T1, dfa2_T0, _empty, _empty
};

そして、これにより、宣言されていない「_empty」に対してコンパイルエラーが発生します。

その部分の前に、私は見つけました:

/** Used when there is no transition table entry for a particular state */
#define dfa2_T_empty        NULL

生成されたコードでは、「_empty」は「dfa2_T_empty」である必要があると思います。

現在、文法ファイルに簡単な回避策を入れています。しかし、これが実行時にうまく機能するかどうかはわかりません。

@header {
   #define _empty NULL
}
于 2014-01-10T09:30:56.077 に答える