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 7Answer: 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 =…

  1. A.

    10 x 7

  2. B.

    14 x 7

  3. C.

    12 x 7

  4. 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.

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…