1. Panic mode
2. Phrase level recovery
3. Error production
4. Global correction
- This strategy is used by most parsing methods. This is simple to implement.
- In this method on discovering error, the parser discards input symbol one at time. This process is continued until one of a designated set of synchronizing tokens is found. Synchronizing tokens are delimiters such as semicolon or end. These tokens indicate an end of input statement.
- Thus in panic mode recovery a considerable amount of input checking it for additional errors.
- This method guarantees not to go in infinite loop. is skipped without
- If there is less number of errors in the same statement then this strategy is best choice.
2. Phrase level recovery
- 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 parser to continue its job.
- The local correction can be replacing comma by semicolon, deletion of semicolons or inserting missing semicolon. This type of local correction is decided by compiler designer.
- While doing the replacement a care should be taken for not going in an infinite loop.
- This method is used in many error-repairing compilers.
3. Error production
- 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 is used during parsing, we can generate appropriate error message to indicate the erroneous construct that has been recognized in the input.
- This method is extremely difficult to maintain, because if we change grammar then it becomes necessary to change the corresponding productions.
4. Global correction
- 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 number of insertions, deletions and changes of token 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.