0
我正在編寫一個yacc文件作爲編譯器的一部分。 我有以下錯誤:在Yacc中嵌入代碼
lang_grammar.y:143.54-55: $2 of `ClassDeclaration' has no declared type
lang_grammar.y:143.69-70: $4 of `ClassDeclaration' has no declared type
lang_grammar.y:143.84-85: $6 of `ClassDeclaration' has no declared type
發生在此行中我.Y文件:
CLASS { /* code will be embedded here */ } ID EXTENDS ID '{' ClassBody '}'
{ $$.classDeclaration = new ClassDeclaration($2.identifier, $4.identifier, $6.classBody); }
當我刪除內嵌入代碼:
CLASS ID EXTENDS ID '{' ClassBody '}'
{ $$.classDeclaration = new ClassDeclaration($2.identifier, $4.identifier, $6.classBody); }
它工作得很好。
在yacc中嵌入代碼有限制嗎?我的印象是這是可能的。
謝謝。
啊,所以整個嵌入部分(從{}到)一個指數,然後計算 – pseudosudo 2011-05-20 09:15:17