A shift reduce parser suffers from

2014

A shift reduce parser suffers from

  1. A.

    shift reduce conflict only

  2. B.

    reduce reduce conflict only 

  3. C.

    both shift reduce conflict and reduce reduce conflict

  4. D.

    shift handle and reduce handle conflicts 

Attempted by 172 students.

Show answer & explanation

Correct answer: C

Answer: A shift-reduce parser can suffer both shift-reduce conflicts and reduce-reduce conflicts.

  • Shift-reduce conflict: occurs when the parser can either shift the next input token onto the stack or reduce using a production at the same parser state (a common example source is the dangling-else ambiguity).

  • Reduce-reduce conflict: occurs when two different reductions are possible at the same parser state and the parser cannot decide which production to reduce by.

  • Resolution strategies: add lookahead (use LR(1)/LALR(1)), rewrite the grammar to remove ambiguity, or declare operator precedence and associativity to guide conflict resolution.

Explore the full course: Mppsc Assistant Professor