GATE | GATE-CS-2005 | Question 60
Consider the grammar
S → (S) | a
Let the number of states in SLR(1), LR(1) and LALR(1) parsers for the grammar be n1, n2 and n3 respectively. The following relationship holds good
(A) n1 < n2 < n3
(B) n1 = n3 < n2
(C) n1 = n2 = n3
(D) n1 ≥ n3 ≥ n2
Answer: (B)
Explanation: LALR(1) is formed by merging states of LR(1) ( also called CLR(1)), hence no of states in LALR(1) is less than no of states in LR(1), therefore n3 < n2. And SLR(1) and LALR(1) have same no of states, i.e ( n1 = n3).
Hence n1 = n3 < n2
Please Login to comment...