编译原理课后习题答案(陈火旺+第三版)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
第二章
P36-6
(1)
L G ()1是0~9组成的数字串
(2)
最左推导:
N ND NDD NDDD DDDD DDD DD D N ND DD D N ND NDD DDD DD D ⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒0010120127334
556568
最右推导:
N ND N ND N ND N D N ND N D N ND N ND N D ⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒⇒77272712712701274434
886868568
P36-7
G(S)
O N O D N S O AO A AD N
→→→→→1357924680|||||||||||
P36-8
文法:
E T E T E T T
F T F T F F E i
→+-→→|||*|/()| 最左推导:
E E T T T
F T i T i T F i F F i i F i i i E T T F F F i F i E i E T i T T i F T i i T i i F i i i ⇒+⇒+⇒+⇒+⇒+⇒+⇒+⇒+⇒⇒⇒⇒⇒⇒+⇒+⇒+⇒+⇒+⇒+********()*()*()*()*()*()*()
最右推导:
E E T E T
F E T i E F i E i i T i i F i i i i i E T F T F F F E F E T F E F F E i F T i F F i F i i i i i ⇒+⇒+⇒+⇒+⇒+⇒+⇒+⇒+⇒⇒⇒⇒⇒+⇒+⇒+⇒+⇒+⇒+⇒+**********()*()*()*()*()*()*()*()
语法树:/********************************
E
E F
T
E +
T F F T +i
i
i
E
E
F
T
E
-T F F T -i
i
i
E
E
F
T
+T F F
T
i
i
i
*i+i+i
i-i-i
i+i*i
*****************/
P36-9
句子iiiei 有两个语法树:
S iSeS iSei iiSei iiiei S iS iiSeS iiSei iiiei ⇒⇒⇒⇒⇒⇒⇒⇒
P36-10
/**************
)
(|)(|S T T
TS S →→
***************/
P36-11
/*************** L1:
ε
||cC C ab aAb A AC S →→→ L2:
bc
bBc B aA A AB S ||→→→ε
L3:
ε
ε||aBb B aAb A AB S →→→ L4:
A
B B A A B A S |01|10|→→→ε ***************/
第三章习题参考答案
P64–7
(1)
确定化:
最小化:
{,,,,,},{}
{,,,,,}{,,}{,,,,,}{,,,}
{,,,,},{},{}{,,,,}{,,}
{,,,},{},{},{}
{,,,}{,0123456012345135012345124601234560123413501234560123101
0==== 301231240123456011011223323401234561
01
01}{,,,}{,,}
{,},{,}{},{},{}
{,}{}{,}{,}
{,}{}{,}{}{},{},{,},{},{},{}
=====
P64
–8
(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(10
P64–12
(a)
确定化:
给状态编号:
最小化:
{,},{,
}
{,}{}{,}{}
{,}{,}{,}{}{,},{},{}
01230
1101223032330123a b
a b ====
(b)
已经确定化了,进行最小化
最小化:
{{,}, {,,,}}
012345011012423451305234523452410243535353524012435011012424{,}{}{,}{,}
{,,,}{,,,}{,,,}{,,,}{,}{,}{,}{,}{,}{,}{,}{,}{{,},{,},{,}}
{,}{}{,}{,}{,}a b a b a b a b a b a =============={,}{,}{,}{,}{,}{,}{,}
10243535353524 b a b
a
P64–14
(2):