Computer Sciences > GATE 2025 SET-2 > Parsing
Given a Context-Free Grammar G as follows:
S→Aa|bAc|dc|bda
A→d
Which ONE of the following statements
A
G is neither LALR(1) nor SLR(1)
B
G is CLR(1), not LALR(1)
C
G is LALR(1), not SLR(1)
D
G is LALR(1), also SLR(1)

Correct : a

The correct answer is Option A - G is neither LALR(1) nor SLR(1).
The grammar is:
S → Aa | bAc | dc | bda
A → d
This is a classic example used to demonstrate the difference between SLR(1)/LALR(1) and CLR(1) parsers. Let''s understand why.
Why G is not SLR(1) or LALR(1):
A → d appears in two different production contexts - S → Aa (where A is followed by ''a'') and S → bAc (where A is followed by ''c''). So FOLLOW(A) = {a, c}.
In the SLR(1) parsing table, when the parser has ''d'' on top of the stack and sees a lookahead of ''a'' or ''c'', it must decide whether to reduce A → d or shift. Additionally, ''d'' also appears directly in S → dc and S → bda, creating a reduce-reduce conflict - the parser can''t determine with just one lookahead whether ''d'' should be reduced as A → d or kept as part of S → dc or S → bda. This conflict makes G not SLR(1).
LALR(1) merges states with the same LR(0) core, but since the conflict originates from overlapping FOLLOW sets and not from state merging, LALR(1) also fails to resolve it. G is not LALR(1) either.
Why G is CLR(1):
CLR(1) uses full LR(1) items with precise lookahead sets per state. In CLR(1), the state where A → d• is the item will have the lookahead precisely as {a} in one state and {c} in another - they are separate states and never merged. This precise distinction resolves the conflict completely, making G a valid CLR(1) grammar.
Key takeaway - whenever a grammar is CLR(1) but not LALR(1), it means LALR(1) state merging causes a conflict that CLR(1) avoids by keeping those states separate.

Similar Questions

Which one of the following is True at any valid state in shift-reduce parsing?
#76 MCQ
Which of the following statements about the parser is/are correct? I. Canonical LR is more powerful than SLR. II. SLR is more powerful than LALR. III. SLR is...
#161 MCQ
Consider the augmented grammar given below: S′ → S S → ⏐id L → L, S⏐S Let I0= CLOSURE ({[S′ → S]}). The number of items in the set GOTO (I0,
#620 Fill in the Blanks

Related Topics

LALR(1) SLR(1) CLR(1) GATE 2025 GATE CS 2025 Set-2 Q40 CFG parsing GATE grammar S Aa bAc dc bda bottom-up parsing GATE reduce-reduce conflict GATE LR parsing GATE FOLLOW set conflict compiler design GATE 2025 LR(1) items parsing

Unique Visitor Count

Total Unique Visitors

Loading......