CS 631, Fall 2009 Assignment #12: 10 points Date Due: Monday, 12/14/09. Read Sections 6.3, 6.6. (3) 1. Exercise 6.2.2(ii). Give: (a) syntax tree, (b) quadruples and (c) triples. (2) 2. Translate the executable statements of the following C program into three-address code using the SDD for while statements in Figure 6.36: main() { int i=0, a[10]; while (i<10) { a[i]=0; i=i+1; } } (2) 3. Exercise 6.6.1(b). (3) 4. Modify your lex/yacc expression compiler from HW#11, Problem 4, to extend the translation scheme of Figure 6.20, (based on C version in Figure 8.15 of Aho, 1st ed.) to include multiplication (*), division (/), subtraction (-) and integer constants. Add a grammar rule: E -> NUM which assigns a constant to a temporary variable generated by the newtemp() function. This can be done by having lex recognize the NUM token and using sscanf(yytext,"%d",&yylval) to return the numeric value of NUM in yylval to yacc. The translation of the grammar rule will assign the constant to the temporary variable in the form: $$nn = NUM.yylval; The value of the constant will be stored as $1 on the yacc value stack and needs to be printed as a string of digits in the assign. Use printf("%d",$1) to accomplish this. Test your expression compiler on: x = -b+4*a*c/(2*a); As in HW11, Problem 4, print the symbol table entries after the code. Hand in your lex/yacc program and the output from your compiler on the test expression.** **For full credit, turn in well commented program listing and output from your computer run.