/    /  Compiler Design-Constructing LR parsing tables

Constructing LR parsing tables

LR parsing is one type of bottom-up parsing. It stands for Left-right parsing.

 

The LR Parser is divided into 4 different sub parsers:

  • LR(0)
  • SLR(1)
  • LALR(1)
  • CLR(1) 

 

Algorithm for LR Parsing:

The following is the algorithm that is to be followed for creating a LR parsing table.

  1. We require a stack, input, output, parsing table. 
  2. All types of LR parsing, stack, input, output remain the same. The only thing that differs is the parsing table.
  3. The input buffer helps us to identify the end of the input, it contains the string that is supposed to be parsed which is followed by a $ Symbol.
  4. A stack is used to store a sequence of grammar symbols that have a $ symbol at the bottom of the stack.
  5. The parsing table requires a 2-D array 
  6. It has 2 Parts, that is the Action part along with the Go-to part.

 

Reference Link

Constructing LR parsing tables