The project consist in extending a parser for
miniC, from a lex and yacc file given by me, with intermediate code generation using the three address instruction.
**Example:**
For a function/procedure call p(x1,x2,…,xn) you should generate code of the form:
*param x1
param x2
.
.
.
param xn
call p,n*
**For:**
int A[10];
int main(){
int i;
int max;
int sum;
i=0; sum = 0;
while(i < 10){
max = findMax(i);
A[i] = max;
Sum = sum + max;
i = i + 1;
}
print_int(sum);
}
**Should generate:**
main:
i = 0
sum = 0
L1: if i < 10 goto L2
goto L3
L2: putparam i
max = call findMax, 1
A[i] = max
t1 = sum + max
sum = t1
t2 = i + 1
i = t2
goto L1
L3: putparam sum
call
The output is validated by using the three-address instruction simulator also given.
- Yacc and Lex tools.
The project should pass in the tests given.