Find the LR(1) table size for the following grammar. S → A | ab A → cAb | B B…
Find the LR(1) table size for the following grammar.
S → A | ab A → cAb | B B → a
Assume m x n is table size where m represent number of sets or states of DFA and n represents number of columns of the table.
Answer: B. 14 x 7 — Answer: 14 x 7 Reasoning: Terminals: a, b, c (3 terminals). Nonterminals: S, A, B (3 nonterminals). Include the end-of-input symbol $ (1). Therefore columns =…
- A.
10 x 7
- B.
14 x 7
- C.
12 x 7
- D.
13 x 7
Attempted by 19 students.
Show answer & explanation
Correct answer: B
Answer: 14 x 7
Reasoning:
Terminals: a, b, c (3 terminals).
Nonterminals: S, A, B (3 nonterminals).
Include the end-of-input symbol $ (1). Therefore columns = terminals + $ + nonterminals = 3 + 1 + 3 = 7.
Rows (states): Augment the grammar with S' → S and construct the LR(1) canonical collection (closures and gotos). This construction yields 14 distinct LR(1) item sets (states), numbered 0..13, so rows = 14.
Hence the LR(1) parsing table size is 14 x 7.