Shift-Reduce parsers perform the following:
2014
Shift-Reduce parsers perform the following:
- 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
- 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
- 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
- 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.