Pages

Thursday, January 03, 2013

LALR Parser - Look-Ahead LR Parser

Introduction
In computer science, an LALR parser or Look-Ahead LR parser is a simplified version of a Canonical LR parser. It was invented by Frank DeRemer in his 1969 PhD. dissertation "Practical Translators for LR(k) languages" in order to address the practical difficulties of that time of implementing Canonical LR parsers. The simplification that takes place results in a parser with significantly reduced memory requirements but decreased language recognition power. However, this power is enough for many real computer languages including Java. Usually this happens with the addition of some hand-written code that extends the power of the parser.
LALR parsers are automatically generated by compiler compilers such as Yacc and GNU Bison.
As with other types of LR parser, an LALR parser is quite efficient at finding the single correct bottom-up parse in a single left-to-right scan over the input stream, because it doesn't need to use backtracking. Being a look-ahead parser by definition, it always uses a look-ahead, with LALR(1) being the most common case.