1
编译原理及实?/p>
2.1
设字母表
A={a}
,符号串
x=aaa
,写出下列符号串及其长度?/p>
x
0
,xx,x
5
以及
A
+
?/p>
A*
.
x
0
=(aaa)
0
=
ε
| x
0
|=0
xx=aaaaaa |xx|=6
x
5
=aaaaaaaaaaaaaaa | x
5
|=15
A
+
=A
1
?/p>
A
2
?/p>
?/p>
.
?/p>
A
n
∪?/p>
={a,aa,aaa,aaaa,aaaaa
?/p>
}
A*
=
A
0
?/p>
A
1
?/p>
A
2
?/p>
?/p>
.
?/p>
A
n
?/p>
?/p>
={
ε
,a,aa,aaa,aaaa,aaaaa
?/p>
}
2.2
令∑
={a
?/p>
b
?/p>
c}
,又?/p>
x=abc
?/p>
y=b
?/p>
z=aab
,写出如下符号串
及它们的长度?/p>
xy
?/p>
xyz
?/p>
?/p>
xy
?/p>
3
12
|=
(xy)3
|
cb
abcbabcbab
=
(abcb)3
=
(xy)3
7
|=
xyz
|
abcbaab
=
xyz
4
|=
xy
|
abcb
=
xy
2.3
设有文法
G[S]
?/p>
S
?/p>
=SS*|SS+|a
,写出符号串
aa+a*
规范推导?
并构造语法树?/p>
S => SS* => Sa* => SS+a* => Sa+a* => aa+a*