手机版

编译原理 龙书答案(12)

发布时间:2021-06-08   来源:未知    
字号:

编译原理 龙书答案

4. 对所有形如B→C 的产生式,将C压栈 5. 返回2

(Aho)4.44 为练习4.4文法构造SLR分析表,解决冲突 解:拓广文法 R'→R

R→R ‘|’ R | RR | R* | (R) | a | b

I0={ R'→ R, R→ R ‘|’ R, R→ RR, R→ R*, R→ (R), R→ a, R→ b }

goto(I0, R) = { R'→R , R→R ‘|’ R, R→R R, R→R *, R→ R ‘|’ R, R→ RR, R→ R*, R→ (R), R→ a, R→ b } = I1

goto(I0, () = { R→( R), R→ R ‘|’ R, R→ RR, R→ R*, R→ (R), R→ a, R→ b } = I2 goto(I0, a) = { R→a } = I3 goto(I0, b) = { R→b } = I4

goto(I1, R) = { R→RR , R→R ‘|’ R, R→R R, R→R *, R→ R ‘|’ R, R→ RR, R→ R*, R→ (R), R→ a, R→ b } = I5

goto(I1, |) = { R→R ‘|’ R, R→ R ‘|’ R, R→ RR, R→ R*, R→ (R), R→ a, R→ b } = I6 goto(I1, *) = { R→R * } = I7 goto(I1, () = I2 goto(I1, a) = I3 goto(I1, b) = I4

goto(I2, R) = { R→(R ), R→R ‘|’ R, R→R R, R→R *, R→ R ‘|’ R, R→ RR, R→ R*, R→ (R), R→ a, R→ b } = I8 goto(I2, () = I2 goto(I2, a) = I3 goto(I2, b) = I4 goto(I5, R) = I5 goto(I5, |) = I6 goto(I5, *) = I7 goto(I5, () = I2 goto(I5, a) = I3 goto(I5, b) = I4

goto(I6, R) = { R→R ‘|’ R , R→R ‘|’ R, R→R R, R→R *, R→ R ‘|’ R, R→ RR, R→ R*, R→ (R), R→ a, R→ b } = I9 goto(I6, () = I2 goto(I6, a) = I3 goto(I6, b) = I4 goto(I8, R) = I5 goto(I8, |) = I6 goto(I8, *) = I7 goto(I8, () = I2

goto(I8, )) = { R→(R) } = I10 goto(I8, a) = I3 goto(I8, b) = I4 goto(I9, R) = I5

编译原理 龙书答案(12).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
×
二维码
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)