A shift reduce parser carries out the actions specified within braces immediately after reducing with the corresponding rule of grammar
What is the translation of using the syntax directed translation scheme described by the above rules?
View worked solution
Answer: A
A shift-reduce parser processes the input from left to right, shifting symbols onto the stack and executing semantic actions immediately after a reduction is performed. Let us trace the parsing of the input string step-by-step:
| Stack | Remaining Input | Action / Reduction Rule | Output |
|---|---|---|---|
| \)</td> <td>\(xxxxyzz | Shift | - | |
| Reduce | 2 | ||
| Shift | - | ||
| Reduce | 3 | ||
| Reduce | 1 | ||
| Shift | - | ||
| \)</td> <td>Reduce \(W \rightarrow Sz | 3 | ||
| \)</td> <td>Reduce \(S \rightarrow xxW | 1 | ||
| \(\) | Accept | - |
Collecting the outputs in order of execution gives 23131.
Free practice · Your answers on this page are not saved.
