## Posts Tagged ‘Parser’

## LR Parser

LR parser is a bottom-up parsing technique that can parse a large class of context-free grammars. The technique used by LR parser is LR(k) parsing where L stands for left-to-right scanning of the input, R means constructing a rightmost derivation in reverse, and k for the number of input symbols of lookahead that are used in making parsing decisions. When (k) is assumed to be 1, LR parsing is attractive for many reasons.

LR parsers can be constructed to recognize almost all programming language constructs for which context-free grammar can be written. They can find syntactic error as soon as it is possible to do so on a left-to-right scan of the input. LR parsing is the most general non-backtracking shift-reduce parsing method and can be implemented as efficiently as other shift-reduce methods. The class of grammars that can be parsed using LR methods is a proper superset of the class of grammars that can be parsed with predictive parsers.

### Disadvantage

The main drawback is that it needs a lot of work to construct an LR parser by hand for a programming language grammar. So one requires a LR parser generator.

**Related Articles**