编译原理 龙书答案
goto(I6, S) = I7, goto(I6, A) = I2, goto(I6, a) = I3, goto(I7, S) = I5, goto(I7, A) = I6, goto(I7, a) = I3,
c) 构造SLR分析表 解:
FIRST(S) = FIRST(A) = {a, b} FOLLOW(S) = {$, a, b} FOLLOW(A) = {a, b}
goto(I6, b) = I4 goto(I7, b) = I4
SLR分析表冲突,分析过程有多种可能路径,选择其中一种导致正确结果的即可。
e) 构造规范LR分析表 解:
I0 = { [S’→ S, $], [S→ AS, $/a/b], [S→ b, $/a/b], [A→ SA, a/b], [A→ a, a/b] }
goto(I0, S) = {[S’→S , $], [A→S A, a/b], [A→ SA, a/b], [A→ a, a/b], [S→ AS, a/b], [S→ b, a/b]} = I1
goto(I0, A) = {[S→A S, $/a/b] , [S→ AS, $/a/b], [S→ b, $/a/b], [A→ SA, a/b], [A→ a, a/b] } = I2 goto(I0, a) = { [A→a , a/b] } = I3, goto(I0, b) = {[S→b , $/a/b]} = I4
goto(I1, S) = { [A→S A, a/b], [A→ SA, a/b], [A→ a, a/b], [S→ AS, a/b], [S→ b, a/b]} = I5
goto(I1, A) = { [A→SA , a/b], [S→A S, a/b], [S→ AS, a/b], [S→ b, a/b], [A→ SA, a/b], [A→ a,