Consider the following grammar G: S → A | B A → a | c B → b | c Where {S, A,…

2018

Consider the following grammar G:

S → A | B
A → a | c
B → b | c

Where {S, A, B} is the set of non-terminals and {a, b, c} is the set of terminals.

Which of the following statement(s) is/are correct?

S₁: LR(1) can parse all strings that are generated using grammar G.

S₂: LL(1) can parse all strings that are generated using grammar G.

Choose the correct answer:

  1. A.

    Only S₁

  2. B.

    Only S₂

  3. C.

    Both S₁ and S₂

  4. D.

    Neither S₁ nor S₂

Attempted by 45 students.

Show answer & explanation

Correct answer: D

The grammar is ambiguous because string 'c' can be derived from both A and B. This creates a FIRST(A) ∩ FIRST(B) conflict, preventing LL(1) parsing.

Additionally, LR(1) parsers cannot handle ambiguous grammars deterministically. Thus, both statements S₁ and S₂ are false.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor