Shift-Reduce parsers perform the following:

2014

Shift-Reduce parsers perform the following:

  1. A.

    Shift step that advances in the input stream by K (K > 1) symbols and Reduce step that applies a completed grammar rule to some recent parse trees, joining them together as one tree with a new root symbol

  2. B.

    Shift step that advances in the input stream by one symbol and Reduce step that applies a completed grammar rule to some recent parse trees, joining them together as one tree with a new root symbol

  3. C.

    Shift step that advances in the input stream by K (K = 2) symbols and Reduce step that applies a completed grammar rule to form a single tree

  4. D.

    Shift step that does not advance in the input stream and Reduce step that applies a completed grammar rule to form a single tree

Attempted by 64 students.

Show answer & explanation

Correct answer: B

Shift-Reduce parsers process input symbols sequentially using two main operations. During the shift phase, the parser advances the input stream by one symbol at a time. The reduce operation combines existing parse trees into a single tree with a new root symbol, following standard compiler theory definitions.

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

Explore the full course: Mppsc Assistant Professor