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.
- We require a stack, input, output, parsing table.
- All types of LR parsing, stack, input, output remain the same. The only thing that differs is the parsing table.
- 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.
- A stack is used to store a sequence of grammar symbols that have a $ symbol at the bottom of the stack.
- The parsing table requires a 2-D array
- It has 2 Parts, that is the Action part along with the Go-to part.
Constructing LR parsing tables