CS 631, Fall 2009 Assignment #9: 10 points Date Due: Monday, 11/16/09. Read Sections 4.8-4.9 of Aho and yacc documentation. (3) 1. Rewrite the C version of the infix to postfix expression translator (see HW3, problem #1) to call yylex() in place of the code for lexan() in the file lexer.c. Use lex to create the yylex() function so that lexan() now merely calls yylex(), which recognizes NUMs, IDs, operators, skips whitespace and counts lines. Only NUMs, IDs, whitespace and newlines require regular expressions with actions. All other single characters can be returned as the character itself. The code to convert the value of a NUM and to enter an ID in the symbol table goes in the lex actions for these tokens. The lexbuf[] array is no longer needed since lex has its own input buffer and returns the matched strings in the global yytext, which has length yylen. Test the translator thoroughly to verify its correctness and hand in the well-commented source code and output from your tests.** (1) 2. Compile and test the yacc calculator program in Figure 4.58. The source file is available on the course website in /aho/Fig4.58.y. Show that addition and multiplication have the correct precedences and associativities.** (3) 3. Modify the expression grammar for the yacc calculator program in Figure 4.58 to include subtraction (-) and division (/) operators. The source file is available on the course website in /aho/Fig4.58.y. Modify the yylex() function to return a NUMBER token for integers up to 7 digits in length, as in Figure 4.59, using the grammar of Figure 4.58. Test your calculator to show that the operators work correctly and have the correct precedences and aassociativities.** (3) 4. Use yacc to create a parser for the "dangling else" grammar (4.67) on page 281. Use precedence and associativity declarations to produce a parser with no parse table conflicts. Print the parse table produced by yacc -v. Compare with Figure 4.51 on page 282 and explain any differences. Note: It isn't necessary to create a yylex() function because you don't have to run the parser.** **For full credit, turn in well commented program listings and the output of the computer runs for this problem.