9.4 ERROR RECOVERY IN LR PARSING


9.3 RECOVERY FROM SYNTACTIC PHASE ERRORS

A parser detects an error when it has no legal move from its current configuration. The LL (1) and LR (1) parsers use the valid prefix property; therefore, they are capable of announcing an error as soon as they read an input that is not a valid continuation of the previous input's prefix. This is earliest time that a left-to-right parser can announce an error. But there are a variety of other types of parsers that do not necessarily have this property.

The advantages of using a parser with a valid-prefix-property capability is that it reports an error as soon as possible, and it minimizes the amount of erroneous output passed to subsequent phases of the compiler.

Panic Mode Recovery

Panic mode recovery is an error recovery method that can be used in any kind of parsing, because error recovery depends somewhat on the type of parsing technique used. In panic mode recovery, a parser discards input symbols until a statement delimiter , such as a semicolon or an end, is encountered . The parser then deletes stack entries until it finds an entry that will allow it to continue parsing, given the synchronizing token on the input. This method is simple to implement, and it never gets into an infinite loop.




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