GATE / CS ARCHIVE

GATE CSE 2026 SET 1 / QUESTION 28

LL(1) grammar properties

Compiler Design · Parsing & Syntax Analysis · Full GATE CSE 2026 Set 1 paper

GATE 2026 Set 1, Q28 1 mark · MSQ
Report issue

Parsing & Syntax Analysis

Question 28, GATE 2026: Assess four claims: A LL(1) parsers backtrack; B an LL(1) grammar must be left-recursive; C an LL(1) grammar must be left-factored; D LL(1) parsers are more powerful than SLR parsers. The official choice is C, with a retained qualification about literal syntactic left factoring.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C

Our answer: Official scoring answer C; literal necessity claim is overbroad (see discrepancy).

Givens and goal

Assess four claims: A LL(1) parsers backtrack; B an LL(1) grammar must be left-recursive; C an LL(1) grammar must be left-factored; D LL(1) parsers are more powerful than SLR parsers. The official choice is C, with a retained qualification about literal syntactic left factoring.

Approach

Apply predictive-table conditions rather than treating grammar-transformation advice as an unrestricted necessity theorem.

Step-by-step solution

1. LL(1) selects a production from the next input token using a predictive parsing table. It does not use trial-and-error backtracking, so A is false.
2. Left recursion prevents ordinary predictive top-down parsing; it is something to remove, not a requirement for LL(1). Hence B is false.
3. Left factoring is a standard transformation for removing shared prefixes that obstruct predictive selection. This explains the intended textbook answer C, but syntactic left factoring is not literally necessary for every LL(1) grammar. Left factoring is also not sufficient: FIRST/FIRST or FIRST/FOLLOW conflicts can remain.
4. LL(1) does not have greater grammar-recognition power than SLR parsing. Thus D is false.

Discrepancy / interpretation issue: A reduced, productive counterexample is S → A a | A b, A → ε. The two S alternatives share the syntactic prefix A, so the grammar is not literally left-factored. Nevertheless FIRST(Aa)={a} and FIRST(Ab)={b}; the predictive table selects the two S productions in different columns. For A, its sole epsilon production is selected on FOLLOW(A)={a,b}. There are no conflicts, so the grammar is LL(1). Thus the exact general necessity claim in C is false under the standard syntactic definition of left-factored form. C remains the official scoring answer, but its literal necessity claim requires the qualification above. The issue is not restricted to unreachable or unproductive grammar alternatives.

Review: This counterexample was supplied during independent peer review and checked against FIRST/FOLLOW construction.

Predictive-table check for the counterexample

    Nonterminal   lookahead a      lookahead b
    S             S→Aa             S→Ab
    A             A→ε              A→ε

Each table cell contains at most one production, despite the common written prefix A. For the “more powerful” claim, note also that SLR parsing can handle standard left-recursive grammars such as E→E+a | a, which this predictive LL(1) form cannot parse without transformation. Do not replace the LL(1) table condition with either “left-recursive” or “left-factored” as a complete characterization.

Original paper, page 21 · Answer key