/    /  Compiler Design-Shift Reduce Parser

Shift Reduce Parser

 

The shift-down parser constructs a Parse tree in a similar manner as that of the bottom-up Parser. 

 

It constructs the parse tree from the bottom also called the leaves to the top also called the root.

The Shift-Down Parser needs some basic data Structures:

  • It requires a buffer to store the input Strings.
  • And a stack to access and store the production rules.

 

Basic Operations in Shift Reduce Parser

 

  • Shift: It moves symbols from the input buffer to the stack
  • Reduce: If the handle appears on the top of the stack then, its reduction by using appropriate production rules is done.
  • Accept: If the input buffer is empty and contains only the start symbol, then this action is called the Parser. The parsing is successful when the accept action is achieved.
  • Error: When neither of the shift, reduce or the accept actions can be performed, then this action is called Error.

 

 

Reference Link

Shift Reduce Parser