1.将以下文法消除左递归,并分析符号串 i*i+i
E -> E+T | T
T -> T*F | F
F -> (E) | i
答:E'->T
E'->T+...+T+T+T|&
T'->F
T'->F*F*F*F...|&
F->(E) | i
2.101页第7题(2)(3)
(2)A->aABe | a
B->Bb | d
答:A'->a
A'->a*B*e*
B'->d
B'->db*
(3) S->Aa | b
A->SB
B->ab
答:S->SBa | b
B->ab
S'->b
S'->B*a*
B'->ab
求FIRST集
S->Ap
A->a |ε
A->cA
A->aA
解:First(Ap)={a,c,p}
First(a)={a}
First(&)={&}
Frist(cA)={c}
Frist(aA)={a}
求FIRST集
S->Ap
S->Bq
A->a
A->cA
B->b
B->dB
解:First(S1) = First(Ap)={a,c}
First(S2) = First(Bp)={b,d}
First(a)={a}
First(cA)={c}
First(b)={b}
First(dB)={d}
First(A)={a,c}
First(B)={b,d}