2014《编译原理》期末复习资?完整?. - 百度文库 ر

Ͽɼ

I1 ,I2 ,I9 ƽԼͻ. FOLLOW Ϊ I1 FOLLOW(S)={ # }{ + }=

I2 FOLLOW(E)={ +, #, ) }{* }= I9 FOLLOW(E)={ +, #, ) }{* }=

SLR(1)ķ 2 STEP 1 2 3 4 5 6 7 8 S 0 04 045 043 042 048 0486 04864 X # # ( # (i # (F # (T # (E # (E+ # (E+ ( ( i + ( * i ) # ( i + ( * i ) # i + ( * i ) # + ( * i ) # + ( * i ) # + ( * i ) # + ( * i ) # ( * i ) # * i ) # action S4 S5 r6 r4 r2 S6 S4 error goto 3 2 8

4(һ) if a+b > b+c*d then while x*y>3 do x:=x-a*b else while b+c*d>10 do b:=b-(x*y+5) Ӧַ.

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) t1=a+b t2=c*d t3=b+t2 if t1>t3 goto (6) goto (14) t4=x*y if t4>3 goto (9) goto (13) t5=a*b t6=x-t5 x=t6 (12) (13) (14) (15) (16) (17) (18) (19) (20) (21) (22) (23) goto (6) goto (23) t7=c*d t8=b+t7 if t8>10 goto (18) goto (23) t9=x*y t10=t9+5 t11=b-t10 b=t11 goto (14)

() While a0 b0 do Begin

XX1

if a0 then aa1 else bb1 End

Ԫʽ. (10) ? ⣺

(1) (ja05) (2) (jߣߣ3) (3) (jb05 (4) (jߣߣ15) (5) (x1T1) (6) (:= T1ߣx) (7) (ja09) (8) (jߣߣ12) (9) (a1T2) (10) (:= T2ߣa) (11) (jߣߣ1) (12) (b1 T3) (13) (:= T3ߣb) (14) (jߣߣ1) (15)

5(һ)л(10) T12

T210MT1 T3SR T4SR

AT2 * T4 BA T5SR T6T3 * T5 BT6

(1) DAGͼ

(2) ʱֻABãдŻԪС

5(һ)⣺(1)DAG

(2) ŻԪʽ T3SR T4SR A5*T4

BT3T4

() P255-257 DAGͼ

Թ»GDAG

(1) T03.14 (2) T12* T0 (3) T2R+r (4) AT1 * T2 (5) BA (6) T32* T0 (7) T4R+r

(8) T5T3 * T4 (9) T6R-r (10) BT5 *T6 (11)if B<=10 goto (1) (1) DAGͼ

(2) ʱֻABãдŻԪС⣺1DAGͼ£

)

(3

2 Ԫ£ 1 TR+r

2

2 TR-r

6

3 A6.28* T4 BA*T

6

2

ġ ? 1.1

ȸNFAͼ

״̬ת:

A B C' D' E' I A B BC BD CBE 0 B BD B BD 1 B BC BC BCE BC DFAͼ