编译原理(陈火旺第三版)练习答案(19)
发布时间:2021-06-07
发布时间:2021-06-07
编译原理(陈火旺第三版)练习答案
P218-8
自下而上分析过程中把赋值语句A := B * (-C + D)翻译成四元式的步骤: 步骤 (1)
输入串 A := B * (-C + D)
栈四元式
A A- A-B A-B A-B-
(2) B * (-C + D)(3)* (-C + D): (4)(-C + D) (5)(-C + D) (6) (7) (8)
(-C + D) -C + D) C + D)
i := i i := E i := E*
i := E*( i := E*( i := E*( i := E*((-,C,-,T1) i := E*( i := E*( i := E*(
i := E*((+,T1,D,T2) i := E*( i := E*(E) i := E*E i := E A
A-B-T2 A-T3
(*,B,T2,T3) (:=,T3,-,A)
(9)D) (10)D) (11)D) (12) (13) (14) (15) (16) (17) (18)
D) ) ) )
(19)
P218-5 =
=10 x 20 的数组,C、D大小为10的数组,数组每维下届为1,每个数据项宽度为4,设A、B为
则:
A[i,j] := B[i,j] + C[A[k,1]] + D[i+j] T1 := i * 20 T1 := T1 + j T2 := A – 84 T3 := 4 * T1 T4 := i * 20 T4 := T4 + j T5 := B – 84 T6 := 4 * T4 T7 := T5[T6] T8 := k*20 T8 = T8 + 1 T9 := A – 84 T10 := 4 * T8 T11 := T9[T10] T12 := C – 4 T13 := 4 * T11 T14 := T12[T13]