1.將以下文法消除左遞迴,求first集、follow集,select集,並分析符號串 i*i+i
e -> e+t | t
t -> t*f | f
f -> (e) | i
消除左遞迴:
e→te'
e'→+te'|ε
t→ft'
t'→*ft'|ε
f→(e)|i
first集:
first(te')=
first(+te')=
first(ε)=
first(ft')=
first(*ft')=
first((e))=
first(i)=
follow集:
follow(e)=
follow(e')=
follow(t)=
follow(t')=
follow(f)=
select集:
select(e→te')=first(te')=
select(e'→+te')=first(+te')=
select(e'→ε)=(first(ε)-)∪follow(e')=
select(t→ft')=first(ft')=
select(t'→*ft')=first(*ft')=
select(t'→ε)=(first(ε)-)∪follow(t')=
select(f→(e))=first((e))=
select(f→i)=first(i)=
分析符號串i*i+i:
答案:
2.p101練習7(2)(3)
a → aabe|a
b → bb|d
提取左公因子:
a→aa'
a'→abe|ε
消除左遞迴:
b→db'
b'→bb'|ε
first集:
first(aa')=
first(abe)=
first(ε)=
first(db')=
first(bb')=
follow集:
follow(a)=
follow(a')=
follow(b)=
follow(b')=
select集:
select(a→aa')=first(aa')=
select(a'→abe)=first(abe)=
select(a'→ε)=(first(ε)-)∪follow(a')=
select(b→db')=first(db')=
select(b'→bb')=first(bb')=
select(b'→ε)=(first(ε)-)∪follow(b')=
s → aa|b
a → sb
b → ab
代入:s→sba|b
消除左遞迴:
s →bs'
s'→bas'|ε
b→ab
first集:
first(sba)=
first(b)=
first(bs')=
first(bas)=
first(ε)=
first(ab)=
follow集:
follow(s)=
follow(s')=
follow(b)=
select集:
select(s→sba)=first(sba)=
select(s→b)=first(b)=
select(s→bs')=first(bs')=
select(s'→bas')=first(bas')=
select(s'→ε)=(first(ε)-)∪follow(s')=
select(b→ab)=first(ab)=
求以下文法的first集、follow集
s -> ap
a -> a |ε
a -> ca
a -> aa
first(a)=
first(ε)=
first(ca)=
first(aa)=
first(ap)=
follow(s)=
follow(a)=
select(s→ap)=fiest(ap)=
select(a→a)=first(a)=
select(a→ε)=(first(ε)-)∪follow(a)=
select(a→ca)=first(ca)=
select(a→aa)=first(aa)=
s -> ap
s -> bq
a -> a
a -> ca
b -> b
b -> db
first(a)=
first(ca)=
first(b)=
first(db)=
first(ap)=
first(bq)=
follow(s)=
follow(a)=
follow(b)=
select(s→ap)=fiest(ap)=
select(s→bq)=first(a)=
select(a→a)=first(a)=
select(a→ca)=first(ca)=
select(b→b)=first(b)=
select(b→db)=first(db)=
第十次作業 消除左遞迴
1.將以下文法消除左遞迴,求first集 follow集,並分析符號串 i i i e e t t t t f f f e i 消除左遞迴 e te e te t ft t ft f e i first集 first e first i first first ft first ft first t...
第十次作業
linux網路服務 osi七層模型 物理層 傳輸介質,組網 資料鏈路層 mac位址定址,資料成幀,資料檢測,重發apr 網路層 將網路位址轉化為實體地址,網路位址定址,路由 ip協議 傳輸層 提供端對端的資料交換,連線,埠 會話層 提供點對點的連線 表示層 資料格式化 應用層 應用程式,服務 tcp...
第十次作業
1.將以下文法消除左遞迴,分析符號串 i i i e e t t t t f f f e i 解 文法改寫 e te e te t ft t ft f e i first集 first e first e first t first t first f follow集 follow e follow...