Site icon i2tutorials

Compiler Design-LR Parsers- Part 2

LR Parsers- Part 2

 

Rules for LR Parser

The following are the rules for an LR Parser:

  1. The first closed set is added as the first item from the given grammar rules.
  2. If an object is present in the closure of the form A → α, β, ץ, where the next symbol after the symbol is a non-terminal, add the symbol’s production rules where the dot precedes the first item.
  3. For new items added under (B) repeat steps (B) and (C).

 

LR Parser Algorithm:

LR Parser algorithm is the same as for all the other parsers, the only thing which differs is the parsing table for each parser.

 

The following are the components an LR Parser Algorithm consists:

  1. Input Buffer: It ends with the $ symbol and contains the given string
  2. Stack: For the LR Parser to take the parsing decisions, the combination of state symbol and current input symbol is required and  used to refer to the parsing table 

 

 

Reference Link

LR Parsers- Part 2

Exit mobile version