Error Recovery Strategies | Ad-hoc
Again freestudy9 is presenting new post related to Error recovery Strategies | Ad-hoc. Similarly, we described the Ad-hoc method for it.
Panic mode: Error Recovery Strategies | Ad-hoc
- This strategy is used by most parsing methods. This is simple to implement.
- In this method on discovering the error, the parser discards input symbol one at the time. This process continued until one of a designated set of synchronizing tokens is found. Synchronizing tokens are delimiters such as semicolon or end. These tokens indicate the agonizing end of input statement.
- Thus in panic mode recovery a considerable amount of input skipped without checking it for additional errors.
- This method guarantees not to go in an infinite loop. If there is less number of errors in the same statement then this strategy is the best choice.
Phrase level recovery: Error Recovery Strategies | Ad-hoc
- So, In this method, on discovering an error parser performs local correction on remaining input.
- It can replace a prefix of remaining input by some string. This actually helps the parser to continue its job. The local correction can be replacing comma by a semicolon, deletion of semicolons or inserting a missing semicolon. This type of local correction decided by compiler designer.
- While doing the replacement a care should take for not going in an infinite loop.
- This method used in many error-repairing compilers.
Error production: Error Recovery Strategies | Ad-hoc
- If we have good knowledge of common errors that might be encountered, then we can augment the grammar for the corresponding language with error productions that generate the erroneous constructs.
- If error production used during parsing, we can generate an appropriate error message to indicate the erroneous construct that has recognized in the input. maintain, excuse
- Moreover, This method is extremely difficult to maintain because if we change grammar then it becomes necessary to change the corresponding productions.
Global correction: Error Recovery Strategies | Ad-hoc
- We often want such a compiler that makes very few changes in processing an incorrect input string.
- Given an incorrect input string x and grammar G, the algorithm will find a parse tree for a related string y, such that a number of insertions, deletions, and changes of token deletions require to transform x into y is as small as possible.
- Such methods increase time and space requirements at parsing time.
- Global production is thus simply a theoretical concept.