我正在使用 jflex 和 byaccj 来构建 AST。我无法解决错误并且我使用了类型转换,但错误仍然存在
对于语法中的以下规则:
program : CLASS Program '{' field_decl '}' {
program1 $$ = new program1($1.sval, $2.sval, $4.obj);
}
;
我已经在我的.java
文件中声明了这一点
abstract class program extends ASTnode{
}
class program1 extends program {
private classexp ce = null;
private String id="Program";
private ArrayList<field_decl> fdecl = null;
public program1(classexp ce,String id, ArrayList<field_decl> fdecl) {
super();
this.ce = ce;
this.id = id;
this.fdecl = fdecl;
}
}
错误是:
{program1 yyval= new program1(val_peek(4).sval,val_peek(3).sval,val_peek(1).obj);}
^
required: classexp,String,ArrayList<field_decl>
found: String,String,Object
reason: actual argument String cannot be converted to classexp by method invocation conversion
1 error