Site icon i2tutorials

Compiler Design-LR Parser

LR Parser

 

A  LR parser is Generally used by computer programming language compilers and other associated tools. It is a bottom-up parser for context-free grammar because it attempts to reduce the top-level grammar productions because it starts building from the leaves, reads input from left to right, and gives right-most derivation. These are also the most powerful parser of all the other deterministic parsers.

 

LR Parser Description

L – Left-to-right scanning

R – Rightmost derivation in reverse

 

Refers to the “look ahead” input symbols used in parser decision making. It reduces the sequence of tokens to the left. 

 

When we look from above the derivation order extends first to non-terminal.

  1. We are reducing the rule by S’ → S$ when the stack is empty.
  2. We can retrieve the rules that are already present in the stack using a “.” in the rule representation.
  3. A dotted line represents how far the RHS has been represented. Or it is the production rule.
  4. Closing an item is used to see what production rules can be used to expand the current structure.

 

It is calculated as mentioned in the next part.

 

 

 

Reference Link

LR Parser

Exit mobile version