编译原理课后习题答案(陈火旺+第三版).pdf
《编译原理课后习题答案(陈火旺+第三版).pdf》由会员分享,可在线阅读,更多相关《编译原理课后习题答案(陈火旺+第三版).pdf(27页珍藏版)》请在冰豆网上搜索。
![编译原理课后习题答案(陈火旺+第三版).pdf](https://file1.bdocx.com/fileroot1/2022-10/22/fdc9cc74-23aa-46ec-a7bf-16e7a43f65bf/fdc9cc74-23aa-46ec-a7bf-16e7a43f65bf1.gif)
课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/第二章第二章PP3636-66
(1)LG()1是09组成的数字串
(2)最左推导:
NNDNDDNDDDDDDDDDDDDDNNDDDDNNDNDDDDDDDD0010120127334556568最右推导:
NNDNNDNNDNDNNDNDNNDNNDND77272712712701274434886868568PP3636-77G(S)ONODNSOAOAADN1357924680|P36P36-88文法:
ETETETTFTFTFFEi|*|/()|最左推导:
EETTTFTiTiTFiFFiiFiiiETTFFFiFiEiETiTTiFTiiTiiFiii*()*()*()*()*()*()*()最右推导:
EETETFETiEFiEiiTiiFiiiiiETFTFFFEFETFEFFEiFTiFFiFiiiii*()*()*()*()*()*()*()*()语法树:
/*课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/EEFTE+TFFT+iiiEEFTE-TFFT-iiiEEFT+TFFTiii*i+i+ii-i-ii+i*i*/P36P36-99句子iiiei有两个语法树:
SiSeSiSeiiiSeiiiieiSiSiiSeSiiSeiiiieiP36P36-1010/*)(|)(|STTTSS*/P36P36-1111/*L1:
|cCCabaAbAACSL2:
bcbBcBaAAABS|L3:
课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/L4:
ABBAABAS|01|10|*/第三章习题参考答案第三章习题参考答案P64P6477
(1)101101(|)*011011确定化:
01X1,2,31,2,32,32,3,42,32,32,3,42,3,42,3,52,3,42,3,52,32,3,4,Y2,3,4,Y2,3,52,3,4,01000110010111最小化:
X1234Y5XY6012354课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/,0123456012345135012345124601234560123413501234560123101003012312401234560110112233234012345610101,010010010111P64P6488
(1)01)0|1(*
(2)5|0(|)5|0()9|8|7|6|5|4|3|2|1|0)(9|8|7|6|5|4|3|2|1(*(3)*)110|0(01|)110|0(10P64P641212(a)aa,ba确定化:
ab00,110,10,111050124301课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/给状态编号:
ab012112203333aaabbbba最小化:
012301101223032330123ababaabbab(b)bbaabaabbaaa已经确定化了,进行最小化0123012023145课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/最小化:
012345011012423451305234523452410243535353524012435011012424,abababababa,10243535353524babbbaabaP64P641414
(1)010
(2):
(|)*010010确定化:
01X,1,Y1,Y201201YXYX21课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/1,Y1,Y221,Y给状态编号:
0101211221333300101110最小化:
0123011012231323301230101011100第四章第四章P81P8111
(1)按照T,S的顺序消除左递归|,)(|)(TSTTSTTaSSG递归子程序:
procedureS;beginifsym=aorsym=thenabvanceelseifsym=(0213013课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/thenbeginadvance;T;ifsym=)thenadvance;elseerror;endelseerrorend;procedureT;beginS;Tend;procedureT;beginifsym=,thenbeginadvance;S;Tendend;其中:
sym:
是输入串指针IP所指的符号advance:
是把IP调至下一个输入符号error:
是出错诊察程序
(2)FIRST(S)=a,(FIRST(T)=a,(FIRST(T)=,FOLLOW(S)=),#FOLLOW(T)=)FOLLOW(T)=)预测分析表a(),#SSaSST()TTSTTSTTSTTTTST,是LL
(1)文法P81P8122文法:
课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/b|*|()|FIRST(+E)FIRST()=+=FIRST(+E)FOLLOW(E)=+#,)=FIRST(T)FIRST()=(,a,b,=FIRST(T)FOLLOW(T)=(,a,b,+,),#=FIRST(*F)FIRST()=*=FIRST(*F)FOLLOW(F)=*(,a,b,+,),#=FIRST(E)FIRST(a)FIRST(b)FIRST()=所以,该文法式LL
(1)文法.(3)+*()ab#EETEETEETEETEEEEEETTFTTFTTFTTFTTTTTTTTTTTTT课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/FFPFFPFFPFFPFFFFF*FFFFFFPPE()PaPbP(4)procedureE;beginifsym=(orsym=aorsym=borsym=thenbeginT;EendelseerrorendprocedureE;beginifsym=+thenbeginadvance;Eendelseifsym)andsym#thenerrorendprocedureT;beginifsym=(orsym=aorsym=borsym=thenbeginF;TendelseerrorendprocedureT;beginifsym=(orsym=aorsym=borsym=thenTelseifsym=*thenerrorendprocedureF;beginifsym=(orsym=aorsym=borsym=thenbeginP;FendelseerrorendprocedureF;beginifsym=*thenbeginadvance;FendendprocedureP;beginifsym=aorsym=borsym=thenadvanceelseifsym=(then课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/beginadvance;E;ifsym=)thenadvanceelseerrorendelseerrorend;P81P8133/*
(1)是,满足三个条件。
(2)不是,对于A不满足条件3。
(3)不是,A、B均不满足条件3。
(4)是,满足三个条件。
*/第五章第五章P133P13311EETETF*短语:
E+T*F,T*F,直接短语:
T*F句柄:
T*FPP13313322文法:
SaTTTSS|(),|
(1)最左推导:
STTSSSaSaTaTSaSSaaSaaaSTSSSTSTSSTSSSSSSSTSSSTSSSSSSSSSaS()(,)(,)(,)(,()(,(,)(,(,)(,(,)(,(,)(,)(,)(),)(,),)(,),)(,),)(),),)(,),),)(,),),)(,),),)(,),),)(,),),)(,),(),)(,),(),)(,),(),)(,),(),)SSSaaSSSaaSSaaTSaaSSaaaSaaaa最右推导:
STTSTTTTSTTaTSaTaaSaaaaaSTSTaSaTaTSaTTaTSaTaaTSaaTaa()(,)(,()(,(,)(,(,)(,(,)(,(,)(,(,)(,(,)(,)(,)(,)(),)(,),)(,(),)(,(),)(,(),)(,(),)(,(),)(,(),)(),(),)(,),(),)(,),(),)(,),(),)(,),(),)SaaTaaTSaaTaaaSaaaaaaa
(2)(aa,a),(a),a)课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/a),(a),a)(T,ST,S),(a),a)(T)(T),(a),a)(SS,(a),a)(T,(a),a)(T,ST,S,(a),a)(T,(aa),a)(T,(SS),a)(T,(TT),a)(T,ST,S),a)(T)(T),a)(SS,a)(T,ST,S)(T)(T)S“移进-归约”过程:
步骤栈输入串动作0#(aa,a),(a),a)#预备1#(aa,a),(a),a)#进2#(aa,a),(a),a)#进3#(aa,a),(a),a)#进4#(a,a),(a),a)#进5#(S,a),(a),a)#归6#(T,a),(a),a)#归7#(T,a),(a),a)#进8#(T,a),(a),a)#进9#(T,S),(a),a)#归10#(T),(a),a)#归11#(T),(a),a)#进12#(S,(a),a)#归13#(T,(a),a)#归14#(T,(a),a)#进15#(T,(a),a)#进16#(T,S,(a),a)#归17#(T,(a),a)#归18#(T,(a),a)#进19#(T,(a),a)#进20#(T,(a),a)#进21#(T,(S),a)#归22#(T,(T),a)#归23#(T,(T),a)#进24#(T,S),a)#归25#(T),a)#归课后答案网课后答案网http:
/课后答案网课后答案网http:
/http:
/26#(T),a)#进27#(S,a)#归28#(T,a)#归29#(T,a)#进30#(T,a)#进