unit3 (1)
unit3 (1)
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
These errors are detected during the lexical analysis phase. Typical lexical errors are
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
These errors are detected during syntax analysis phase. Typical syntax errors are
Errors in structure
Missing operator
Misspelled keywords
Unbalanced parenthesis
Example : swicth(ch)
{
.......
.......
}
The keyword switch is incorrectly written as swicth. Hence, “Unidentified
keyword/identifier” error occurs.
Error recovery:
Semantic errors
These errors are detected during semantic analysis phase. Typical semantic errors are
Error recovery
If error “Undeclared Identifier” is encountered then, to recover from this a
symbol table entry for corresponding identifier is made.
If data types of two operands are incompatible then, automatic type conversion
is done by the compiler.