I am using jflex and byaccj to build an AST. I am unable to resolve the error and I have used type casting but the error persists
for the following rule in the grammar:
program : CLASS Program '{' field_decl '}' {
program1 $$ = new program1($1.sval, $2.sval, $4.obj);
}
;
and i have declared this in my .java
file
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;
}
}
The error is:
{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