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