Directions: Use your own paper for answers. When you are done you may keep this exam sheet and should pick up an answer sheet.

P ---> E '#'
E ---> E '+' T | E '-' T | T
T ---> T '*' F | T '/' F | F
F ---> 'a' | 'b' | 'c' | '(' E ')'
sexpr ---> digit | '(' tail
tail ---> ')' | sexpr tail
Here you already have a scanner that will keep returning one
of three tokens: a digit, a left parenthesis, or a right parenthesis.
Without actually writing code, give a rough idea of what the
parser would look like by answering the questions:
S ---> E ("S" is the start symbol)
E ---> E '+' T | T
T ---> T '*' F | F
F ---> '(' E ')' | id
Use the following shift-reduce table for this grammar:
| id | * | + | ( | ) | $ |
-----+-----+-----+-----+-----+-----+-----+
S | | | | | | acc | ( "s" means "shift")
E | | | s | | s | r |
T | | s | r | | r | r | ( "r" means "reduce")
F | | r | r | | r | r |
id | | r | r | | r | r | ( "acc" means "accept")
* | s | | | s | | |
+ | s | | | s | | |
( | s | | | s | | |
) | | r | r | | r | r |
$ | s | | | s | | |
-----+-----+-----+-----+-----+-----+-----+
$ id * ( id + id ) $
(Remember that you should initially shift the starting
$.)