
Intermediate Code 229
a C compiler, which then outputs finished object or machine code, we restrict ourselves to more
traditional intermediate codes.
We now discuss several possible Intermediate forms of the program. We also indicate how to
generate the intermediate code for some of them. For that purpose we use the following example
grammar, given in yacc input format.
program : ’P’ stmt-list ’.’ ;
stmt-list : stmt
| stmt ’;’ stmt-list ;
stmt : expr | if | while | let ;
if : ’I’ ’(’ expr ’)’ stmt-list ’E’
| ’I’ ’(’ expr ’)’ stmt-list ’:’ stmt-list ’E’;
while : ’W’ ’(’ expr ’)’ stmt-list ’Z’ ;
let : ’L’ ’a’ ’=’ expr ;
expr : term | term ’+’ expr ; ...