Compiler Design and Construction - Old Questions

Question Answer Details

3.  What is shift reduce parsing technique? Show shift reduce parsing action for the string a*(a+a), given the grammar

        

6 marks
Asked in 2074

Answer

AI Generated Answer

AI is thinking...

Official Answer

The process of reducing the given input string into the starting symbol is called shift-reducing parsing.

A shift reduce parser uses a stack to hold the grammar symbol and an input buffer to hold the input string W. 

Sift reduce parsing performs the two actions: shift and reduce.

  • At the shift action, the current symbol in the input string is pushed to a stack.
  • At each reduction, the symbols will replaced by the non-terminals. The symbol is the right side of the production and non-terminal is the left side of the production.

Now,

Given grammar;

    

Input String: a*(a+a)

Shift reduce parsing action for given input string is shown below: