编译原理 龙书答案
a/b] } = I6
goto(I1, a) = I3, goto(I1, b) = {[S→b , a/b]} = I7
goto(I2, S) = {[S→AS , $/a/b], [A→S A, a/b], [A→ SA, a/b], [A→ a, a/b], [S→ AS, a/b], [S→ b, a/b] } = I8
goto(I2, A) = I2, goto(I2, a) = I3, goto(I2, b) = I4 goto(I5, S) = I5, goto(I5, A) = I6, goto(I5, a) = I3, goto(I5, b) = I7
goto(I6, S) = {[S→AS , a/b], [A→S A, a/b], [A→ SA, a/b], [A→ a, a/b], [S→ AS, a/b], [S→ b, a/b] } = I9
goto(I6, A) = {[S→A S, a/b] , [S→ AS, a/b], [S→ b, a/b], [A→ SA, a/b], [A→ a, a/b] } = I10 goto(I6, a) = I3, goto(I6, b) = I7 goto(I8, S) = I5, goto(I8, A) = I6, goto(I8, a) = I3, goto(I8, b) = I7 goto(I9, S) = I5, goto(I9, A) = I6, goto(I9, a) = I3, goto(I9, b) = I7 goto(I10, S) = I9, goto(I10, A) = I10, goto(I10, a) = I3, goto(I10, b) = I7 规范LR分析表为:
f) 利用LR(1)项目集合并的方法构造LALR分析表 解:
同心集合并:
I2 10 = {[S→A S, $/a/b] , [S→ AS, $/a/b], [S→
b, $/a/b], [A→ SA, a/b], [A→ a, a/b] } I47 = {[S→b , $/a/b]}
I89 = {[S→AS , $/a/b], [A→S A, a/b], [A→ SA, a/b], [A→ a, a/b], [S→ AS, a/b], [S→ b, a/b] }