Skip to main content

L47:Error Detection And Recovery, Lexical Phase Error and Recovery in Hindi by University Academy

L47:Error Detection And Recovery, Lexical Phase Error and Recovery in Hindi by University Academy
L47:Error Detection And Recovery, Lexical Phase Error and Recovery in Hindi by University Academy

Error detection and Recovery in Compiler

In this phase of compilation, all possible errors made by the user are detected and reported to the user in form of error messages. This process of locating errors and reporting it to user is called Error Handling process.
Functions of Error handler
  • Detection
  • Reporting
  • Recovery

Classification of Errors

Compile time errors are of three types:-
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 an 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
 
NewsletterFor latest information