Γ
4is not an LL(k) grammar
Given: Grammar Γ4.
P1: STM → VAR :=VAR|ID(IDLIST) P2 : VAR → ID|ID(IDLIST)
P3 : IDLIST → ID|ID,IDLIST
We show that Γ4 is not an LL(k) grammar for any k.
Proof:
Suppose Γ4 is an LL(k) grammar fork ∈ N. Consider the two derivations S ⇒∗lm VAR :=VAR ⇒∗lm ID(ID, . . .ID
! "# $
k
) := ID
and
S ⇒∗lm ID(IDLIST) ⇒∗lm ID(ID, . . .ID
! "# $
k
)
Ina Schaefer Context-Free Analysis 1
Γ
4is not an LL(k) grammar (2)
Let β =VAR := VAR,γ =ID(IDLIST),x = ID(ID, . . . ,ID
! "# $
k
) := ID and y = ID(ID, . . .ID
! "# $
k
).
Rewriting the derivations yields
S ⇒∗lm β ⇒∗lm x and
S ⇒∗lm γ ⇒∗lm y
Then prefix(k,x) =prefix(k,y), but β $=γ which contradicts the LL(k) property ofΓ4.
Ina Schaefer Context-Free Analysis 2