Consider the following statements: Statement I: LALR parser is more powerful…

2022

Consider the following statements:

Statement I: LALR parser is more powerful than canonical LR Parser.

Statement II: SLR parser is more powerful than LALR

Which of the following is correct ?

  1. A.

    Statement I true and Statement II false

  2. B.

    Statement I false and Statement II true

  3. C.

    Both Statement I and Statement II false

  4. D.

    Both Statement I and Statement II true

Attempted by 105 students.

Show answer & explanation

Correct answer: C

Answer: Both Statement I and Statement II are false.

  • Canonical LR(1) parsers are the most powerful among the three; they can recognize all grammars that LALR(1) and SLR(1) can, and some additional grammars.

  • LALR(1) is obtained by merging certain LR(1) states, which makes it less powerful than canonical LR(1) but typically more powerful than SLR(1).

  • SLR(1) uses LR(0) states with follow sets and is the weakest of the three; it cannot parse some grammars that LALR(1) can.

Therefore Statement I is false because LALR is not more powerful than canonical LR, and Statement II is false because SLR is not more powerful than LALR.

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

Explore the full course: Mppsc Assistant Professor