Professional Documents
Culture Documents
Solution:
1. The grammar is not left recursive.
2. FIRST( A) = {a, }
3. FIRST(B) = {b, }
4. FIRST sets of production alternatives
are disjoint.
5. No two production alternatives derives
.
6. FOLLOW( A) = {b, c}
7. FOLLOW(B) = {c}
8. When A , a and FOLLOW( A) are
disjoint.
9. When B , b and FOLLOW(B) are
disjoint.
10. Hence, the grammar is LL(1).
Page 2
ii. S ACB, A a | B | , B b | ,
Cc|
Page 3
Solution:
1. Here, B in A a | B | derives .
2. There is also an in the right side.
3. Hence, the grammar is not LL(1).
OR
1. FOLLOW( A) = {b, c} (from S ACB
and C )
2. Now, we have A a | B | , and B
begins with a terminal in
FOLLOW( A).
3. Hence, the grammar is not LL(1).
Page 4
iii. S X, X aX B A | bAX B | c, A a,
Ba|
Page 5
Solution:
1. FOLLOW(B) = {a, . . . } (from
X aX B A, and A a)
2. Now, we have B a | , and a begins
with a terminal in FOLLOW(B).
3. Hence, the grammar is not LL(1).
Page 6
iv. A C | , C CE, C , E
Page 7
Solution:
1. The grammar is left recursive
(C CE).
2. Hence, the grammar is not LL(1).
OR
1. A C CE
2. So, in A C | , we have two bodies
which derives .
3. Hence, the grammar is not LL(1).
Page 8
v. S S(S) |
Page 9
Solution:
1. The grammar is left recursive
(S S(S)).
2. Hence, the grammar is not LL(1).
Page 10