Syntactic Phase Errors (2)
Statement Mode Recovery
- In this method, when a parser encounters an error, it performs the necessary correction on the remaining input so that the rest of the input statement allows the parser to parse ahead.
- The corrections can be any of the above-mentioned errors.
- We need to be very careful while correcting the errors, so as to make sure it doesn’t enter into an infinite loop.
- It is difficult to handle situations where an actual error occurs before the point of declaration.
Error Production
- If the user has knowledge of common errors that can be encountered then, these errors can be incorporated by augmenting the grammar with error productions that generate erroneous constructs
- Suitable error messages can be generated and parsing can be continued when we use error production.
- The main disadvantage is that it is difficult to maintain.
Global Correction
- The parser examines the whole program and tries to find the closest match for it which is error-free.
- There are fewer insertions, deletions, and changes of tokens to recover from the erroneous input in the closet match program.
- This method is generally not used due to high Time and Space Complexity.
Reference Link
