i
cludestdlibhi
cludestdiohi
cludestri
gh
i
tcou
t0
分解的产生式的个数
i
t
umber
所有终结符和非终结符的总数
charstart
开始符号
chartermi
50
终结符号
char
o
_ter50
非终结符号
charv50
所有符号
charleft50
左部
charright5050
右部
charfirst5050follow5050
各产生式右部的FIRST和左部的
FOLLOW集合
charfirst15050
所有单个符号的FIRST集合
charselect5050
各单个产生式的SELECT集合
charf50F50
记录各符号的FIRST和FOLLOW是否已求过
charempty20
记录可直接推出的符号
charTEMP50
求FOLLOW时存放某一符号串的FIRST集合
i
tvalidity1
表示输入文法是否有效
i
tll1
表示输入文法是否为LL1文法
i
tM2020
分析表
charchoose
用户输入时使用
charempt20
求_emp时使用
charfo20
求FOLLOW集合时使用
判断一个字符是否在指定字符串中
f
i
ti
charccharp
i
ti
ifstrle
p0
retur
0
fori0i
ifpic
retur
1
若在,返回
ifistrle
p
retur
0
若不在,返回
得到一个不是非终结符的符号
charc
charcA
whilei
c
o
_ter1
c
retur
c
分解含有左递归的产生式
voidrecurcharpoi
t
完整的产生式在poi
t中
i
tjm0
3k
chartemp20ch
fchc
得到一个非终结符
kstrle
o
_ter
o
_terkch
o
_terk10
forj0jstrle
poi
t1j
ifpoi
t
poi
t0
如果‘’后的首符号和左部相同
forj
1jstrle
poi
t1j
whilepoi
tjpoi
tj0
tempmpoi
tj
leftcou
tch
memcpyrightcou
ttempm
rightcou
tmch
rightcou
tm10
m0
cou
t
ifpoi
tj
j1
break
else
如果‘’后的首符号和左部不同
leftcou
tch
rightcou
t0
rightcou
t10
cou
t
fforj
jstrle
poi
t1j
ifpoi
tjtempmpoi
tj
else
leftcou
tpoi
t0memcpyrightcou
ttempmrightcou
tmchrightcou
tm10pri
tf