Directions: Use your own paper for this exam.
P ---> E '$'
E ---> E '+' T | E '-' T | T
T ---> T '*' S | T '/' S | S
S ---> F '^' S | F
F ---> 'a' | 'b' | 'c' | 'd' | '(' E ')'
S ---> b M b ("S" is the start symbol)
M ---> ( L
M ---> a
L ---> M a )
Use the following shift-reduce table for this grammar:
| b | a | ( | ) | $ |
-----+-----+-----+-----+-----+------+
S | | | | | acc |
M | s | s | | | |
L | r | r | | | |
b | | s | s | | r |
a | r | r | | s | |
( | s | s | s | | |
) | r | r | | | |
$ b ( ( a a ) a ) b $
(Remember that you should initially shift the starting
$ and then shift the next symbol.)
A ---> lower-case '=' E ';'