5.7 EXAMPLES


5.6 WHY LR PARSING IS ATTRACTIVE

There are several reasons why LR parsers are attractive:

  1. An LR parser can be constructed to recognize virtually all programming language constructs for which a CFG can be written.

  2. The LR parsing method is the most general, nonbacktracking shift-reduce method known. Yet it can be implemented as efficiently as any other method.

  3. The class of grammars that can be parsed by using the LR method is a proper superset of the class of grammars that can be parsed with a predictive parser.

  4. The LR parser can quickly detect a syntactic error via the left-to-right scanning of input.

The main drawback of the LR method is that it is too much work to construct an LR parser by hand for a typical programming language grammar. But fortunately, many LR parser generators are available that automatically generate the required LR parser.




Algorithms for Compiler Design
Algorithms for Compiler Design (Electrical and Computer Engineering Series)
ISBN: 1584501006
EAN: 2147483647
Year: 2005
Pages: 108
Authors: O G Kakde

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net