GATE Daily

Tuesday27 October 2026

Past sets27 Oct 2026Compilers

Bottom-up parsing: GATE CS question with solution

Q.7

Consider the context-free grammar with start symbol , non-terminals and terminals :

Which ONE of the following statements is TRUE?

One try. It counts in your 27 Oct 2026 set.
Show solution
RememberSLR decides reductions with FOLLOW sets, which pool every context; LR(1) lookaheads keep contexts apart. LALR merges only states with identical LR(0) cores, so if no two LR(1) states share a core, LALR(1) equals CLR(1).

Solution MCQ · 2 marks · −⅔ if wrong

Answer: (B) G is LALR(1) but not SLR(1)

Method. Build only the states that can conflict, then test with FOLLOW (SLR) and with LR(1) lookaheads (CLR/LALR).

Augment with . The LR(0) state contains , , , , . On :

Two complete items in one state: a reduce-reduce conflict unless the lookaheads separate them.

SLR(1). (from and ), . On the parser could reduce by either rule: conflict, so not SLR(1).

CLR(1). In the LR(1) start state the items are and , so is , : no conflict. After , the item is and its -successor is , alone in its state. No other state has a conflict, so is CLR(1).

LALR(1). LALR merges states with the same LR(0) core. The core and the core are different, so nothing merges and the LALR table equals the CLR table: LALR(1).

The trap. SLR uses the whole FOLLOW set of a non-terminal, which mixes contexts: follows only after , never in the state reached directly on . Seeing "two states with " and concluding LALR will merge them is the opposite slip; merging needs identical item cores, not one shared item.

What was tested. Why LR(1) lookaheads are finer than FOLLOW sets, and exactly when LALR merging happens, applied to the containment SLR(1) LALR(1) CLR(1).

Copied. Paste it into the new chat.Too long to send. Copy the question and solution by hand.