Question: 7a) Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table below .
7a) Show a complete bottom-up parse, including the parse stack contents, input string, and action for the string below using the parse table below.
(id + id) * id.
7b) Show a rightmost derivation for the string above, and show how the bottom-up parse you completed above correctly finds all of the handles for the input string above.
| I | C | Id | + | * | ) | $ | E | T |
| 1 | S4 | S5 | - | - | - | - | 2 | 3 |
| 2 | S6 | S7 | accept | |||||
| 3 | R1 | R1 | R1 | R1 | ||||
| 4 | S4 | S5 | 8 | 3 | ||||
| 5 | R6 | R6 | R6 | R6 | ||||
| 6 | S4 | S5 | 9 | |||||
| 7 | S4 | S5 | 10 | |||||
| 8 | S6 | S7 | S11 | |||||
| 9 | R2 | R2 | R2 | R2 | ||||
| 10 | R3 | R3 | R3 | R3 | ||||
| 11 | R5 | R5 | R5 | R5 |
Where R=reduce, S=shift, - = error
Parse table above was created from this question: Create an LR(0) parse table for the following grammar. Show all steps (creating closures, the DFA, the transition table, and finally the parse table): E -> E + T | E * T | T T -> ( E ) | id.
I only need 7a and 7b answered. Just giving more context. Thanks!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
