image/svg+xmlPage3of34.Usingthisgrammar,whosethreeterminalsare
a
,
b
,and
c
,
E
→
aFbE
→
cF
→
EaFF
→
E
(a)Constructarightmostderivationfor
aacacbb
.Underlinethehandleofeachright-sententialform.
(b)Showthestepsofashift-reduce(bottom-up)parsercorrespondingtothisrightmostderivation.
(c)Showtheconcreteparsetreethatwouldbeconstructedduringthisshift-reduceparse.
5.
DrawtheLR(0)automatonforthefollowingambiguousgrammar.
if
,
else
,and
null
areterminals;thethird
ruleindicates
T
maybetheemptystring.Indicatethestateinwhichtheshift/reduceconflictappears.
Checkyourworkbyrunning‘‘ocamlyacc-v’’onthegrammarbelowandlookingthroughthe‘‘.output’’file.
Showpartofyour.outputfilebelowthatconfirmsyouranswer.
S
0
→
SS
→
if
STS
→
null
T
→
T
→
else
S