Error Handling
Error Handling
➢Detection
➢Reporting
➢Recovery
➢Classification of Errors
i. Lexical Phase Errors
These errors are detected during the lexical analysis phase. Typical lexical errors are
Exceeding length of identifier or numeric constants.
Appearance of illegal characters
Unmatched string
Example 1 : printf("Geeksforgeeks");$
This is a lexical error since an illegal character $ appears at the end of statement.
Example 2 : This is a comment */
This is a lexical error since end of comment is present but beginning is not present.
Error recovery:
Panic Mode Recovery
In this method, successive characters from the input are removed one at a time until a
designated set of synchronizing tokens is found.
Synchronizing tokens are delimiters such as; or }
Advantage is that it is easy to implement and guarantees not to go to infinite loop
Disadvantage is that a considerable amount of input is skipped without checking it for
additional errors