1.将以下文法消除左递归,分析符号串 i*i+i 。
并分别求FIRST集、FOLLOW集,和SELECT集
E -> E+T | T
T -> T*F | F
F -> (E) | i
2.P101练习7(2)(3)文法改写,并分别求FIRST集、FOLLOW集,和SELECT集
3.求以下文法的FIRST集、FOLLOW集和SELECT集。
S->Ap
A->a |ε
A->cA
A->aA
S->Ap
S->Bq
A->a
A->cA
B->b
B->dB
(1)FIRST集:
FIRST(S)={a,c,p}
FIRST(A)={a}
FIRST(A)={c}
FIRST(A)={a}
FOLLOW集:
FOLLOW(S)={#}
FOLLOW(A)={p}
SELECT集:
SELECT(S->Ap)={a,c,p}
SELECT(A->a)={a}
SELECT(A->ε)={p}
SELECT(A->cA)={c}
SELECT(A->aA)={a}
(2)FIRST集:
FIRST(S)={a,c}
FIRST(S)={b,d}
FIRST(A)={a}
FIRST(A)={c}
FIRST(B)={b}
FIRST(B)={d}
FOLLOW集:
FOLLOW(S)={#}
FOLLOW(A)={p}
FOLLOW(B)={q}
SELECT集:
S->Ap
S->Bq
A->a
A->cA
B->b
B->dB
SELECT()={}
SELECT(S->Ap)={a,c}
SELECT(S->Bq)={b,d}
SELECT(A->a)={a}
SELECT(A->cA)={c}
SELECT(B->b)={b}
SELECT(B->dB)={d}