
368 Compilers – Principles and Practice
Due to space constraints we do not propose to give the complete listings of the yacc action
terms, but give a few indicative examples below.
12.8.1 Arithmetic Expression
We give here the yacc action terms for expr ’+’ expr:
| expr ’+’ expr { fprintf(fout1,"+\n"); $$ = $3;
fprintf(fout2,"%d: ADD T%d T%d T%d\n", ++mcount,
tpop(), tpop(), ++tcount); tpush(tcount);
efadd();}
The files fout1 and fout2 get the RPN IR and 4-tuple IR outputs, respectively. The raw assembly
language code is generated by the function efadd() in the file codegen.c, which is:
efadd(){
emit(" faddp\n",0);
}
It outputs the FPU instruction ...