编译原理 龙书答案(12)

时间:2025-01-18

编译原理 龙书答案

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

精彩图片

热门精选

大家正在看

× 游客快捷下载通道(下载后可以自由复制和排版)

限时特价:7 元/份 原价:20元

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219