编译原理第三版课后习题与答案
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
目录
P36-6 (2)
P36-7 (2)
P36-8 (2)
P36-9 (3)
P36-10 (3)
P36-11 (3)
P64–7 (4)
P64–8 (5)
P64–12 (5)
P64–14 (7)
P81–1 (8)
P81–2 (9)
P81–3 (12)
P133–1 (12)
P133–2 (12)
P133–3 (14)
P134–5 (15)
P164–5 (19)
P164–7 (19)
P217–1 (19)
P217–3 (20)
P218–4 (20)
P218–5 (21)
P218–6 (22)
P218–7 (22)
P219–12 (22)
P270–9 (24)
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)
确定化:
最小化:
{,,,,,},{}
{,,,,,}{,,}{,,,,,}{,,,}{,,,,},{},{}{,,,,}{,,}
{,,,},{},{},{}
{,,,}{,01234560123451350123451246012345601234135012345601231010
0==== 30123124012345601101122332340123456101
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)
确定化: