Fill four LL(1) parsing-table cells
Parsing & Syntax Analysis
![Question 40, GATE 2024: Grammar: S→AaAb | BbBa, A→cS | ε, B→dS | ε. Missing table cells are (1) M[S,c], (2) M[S,d], (3) M[A,b], (4) M[B,a]. Options: A AaAb,BbBa,ε,ε; B BbBa,AaAb,ε,ε; C AaAb,BbBa,blank,blank; D BbBa,AaAb,blank,blank (right sides for the relevant row nonterminal).](../../../assets/questions/CS-2024-S2-Q40-1.webp)
Answer & solution
Official answer: A
Step through it (2 parts)
Approach: Use FIRST for nonempty alternatives and FOLLOW for epsilon alternatives.
1. Derivation. FIRST(AaAb)={c, a}, while FIRST(BbBa)={d, b}. Thus the S-row c cell chooses S→AaAb and the d cell S→BbBa. A occurs before a and b in the first production, so FOLLOW(A)={a, b}; its epsilon production is entered for both lookaheads. Similarly FOLLOW(B)={b, a}, so B→epsilon goes in both a, b cells. Hence cells(1)–(4) are S→AaAb, S→BbBa, A→epsilon, B→epsilon, option A.
2. Explanation and checks. A can disappear, so AaAb can start with a; if A does not disappear it begins with c. The same reasoning yields b or d for BbBa. Each occurrence of A in the S production is followed immediately by a terminal, once a and once b, so both terminals enter FOLLOW(A). The two B occurrences similarly supply b and a. There is no need to put an epsilon production under every lookahead: only FOLLOW lookaheads receive it.

![Question 53, GATE 2012: Grammar: S→aAbB | bAaB | ε; A→S; B→S. S is the start symbol. The partial predictive table has columns a,b,$: S row=[E1,E2,S→ε]; A row=[A→S,A→S,error]; B row=[B→S,B→S,E3]. ε is empty and $ is the input-end marker.
Fill E1,E2,E3.
(A) E1={S→aAbB,A→S}; E2={S→bAaB,B→S}; E3={B→S}.
(B) E1={S→aAbB,S→ε}; E2={S→bAaB,S→ε}; E3={S→ε}.
(C) E1={S→aAbB,S→ε}; E2={S→bAaB,S→ε}; E3={B→S}.
(D) E1={A→S,S→ε}; E2={B→S,S→ε}; E3={B→S}.](../../../assets/questions/CS-2012-Q63-1.webp)
![Question 53, GATE 2012: Grammar: S→aAbB | bAaB | ε; A→S; B→S. S is the start symbol. The partial predictive table has columns a,b,$: S row=[E1,E2,S→ε]; A row=[A→S,A→S,error]; B row=[B→S,B→S,E3]. ε is empty and $ is the input-end marker.
Fill E1,E2,E3.
(A) E1={S→aAbB,A→S}; E2={S→bAaB,B→S}; E3={B→S}.
(B) E1={S→aAbB,S→ε}; E2={S→bAaB,S→ε}; E3={S→ε}.
(C) E1={S→aAbB,S→ε}; E2={S→bAaB,S→ε}; E3={B→S}.
(D) E1={A→S,S→ε}; E2={B→S,S→ε}; E3={B→S}.](../../../assets/questions/CS-2012-Q63-2.webp)
![Question 58, GATE 2006: For grammar S→FR, R→*S|ε, F→id, what are predictive-table entries M[S,id] and M[R,$], respectively?
Options:
(A) {S→FR}, {R→ε}
(B) {S→FR}, empty
(C) {S→FR}, {R→*S}
(D) {F→id}, {R→ε}](../../../assets/questions/CS-2006-Q58-1.webp)
![Question 58, GATE 2006: For grammar S→FR, R→*S|ε, F→id, what are predictive-table entries M[S,id] and M[R,$], respectively?
Options:
(A) {S→FR}, {R→ε}
(B) {S→FR}, empty
(C) {S→FR}, {R→*S}
(D) {F→id}, {R→ε}](../../../assets/questions/CS-2006-Q58-2.webp)
![Question 56, GATE 2003: For the grammar S→iEtSS′ | a; S′→eS | ε; E→b, consider the usual predictive parsing table M with end marker $. What are M[S′,e] and M[S′,$], respectively?
A. {S′→eS}, {S′→ε}
B. {S′→eS}, ∅
C. {S′→ε}, {S′→ε}
D. {S′→eS,S′→ε}, {S′→ε}](../../../assets/questions/CS-2003-Q56-1.webp)




