The document discusses error handling and recovery in compiler design, outlining the processes of error detection, reporting, and recovery while maintaining program performance. It categorizes errors into run-time and compile-time types, detailing various errors and methods of recovery such as panic mode, statement mode, error productions, and global correction. Ultimately, it emphasizes the importance of parsers in identifying and managing errors to ensure effective program execution.
Overview of error handling and recovery tasks in compiler design. Highlights the detection, reporting, and strategy implementation to manage errors.
Describes different types of errors: run-time and compile-time errors, including sub-classifications like lexical, syntactical, semantical, and logical errors.
Discusses the approach to reporting errors through examples, emphasizing the goal of error detection in programming.
Explains various techniques for error recovery including panic mode, statement mode, error productions, and global correction approaches.
Focuses on recovery strategies for semantic errors, such as handling undeclared identifiers and incompatible data types.
Summarizes the importance of error detection and recovery in parsers, outlining types of errors and recovery methods discussed.
Closing slide expressing gratitude to the audience.
INTRODUCTION The tasks ofthe Error Handling process are to detect each error, report it to the user, and then make some recover strategy and implement them to handle error. During this whole process processing time of program should not be slow. An Error is the blank entries in the symbol table.
3.
TYPES OF ERROR Typesor Sources of Error : 1. Run-time error - It is an error which takes place during the execution of a program, and usually happens because of adverse system parameters or invalid input data. 2. Compile-time error - It rises at compile time, before execution of the program.
4.
Classification of Compile-timeerror ● Lexical : name of some identifier typed incorrectly ● Syntactical : missing semicolon or unbalanced parenthesis ● Semantical : incompatible value assignment ● Logical : code not reachable, infinite loop
PANIC MODE ● Thisis the easiest way of error-recovery. ● It prevents the parser from developing infinite loops while recovering error. ● When a parser encounters an error anywhere in the statement, it ignores the rest of the statement by not processing input from erroneous input to delimiter, such as semicolon. ● Example: E->int|E+E|(E)|error int|(error)
8.
STATEMENT MODE ● Whena parser encounters an error, it tries to take corrective measures so that the rest of inputs of statement allow the parser to parse ahead. ● Parser designers have to be careful here because one wrong correction may lead to an infinite loop. ● For example, inserting a missing semicolon.
9.
ERROR PRODUCTIONS ● Somecommon errors are known to the compiler designers that may occur in the code. ● Augmented grammars can also be used, as productions that generate erroneous constructs when these errors are encountered. ● Example: write 5x instead of 5*x
10.
GLOBAL CORRECTION ● Theparser considers the program in hand as a whole and tries to figure out what the program is intended to do and tries to find out a closest match for it, which is error-free. ● Its aim is to make as few changes as possible while converting an incorrect input string to a valid string. ● This strategy is costly to implement.
11.
ERROR RECOVERY ERROR RECOVERYFOR SEMANTIC TYPE OF ERRORS “Undeclared Identifier” ● 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.
12.
“ ” CONCLUSION A parser shouldbe able to detect and report any error in the program. It is expected that when an error is encountered, the parser should be able to handle it and carry on parsing the rest of the input. So, we saw how many types of errors may occur and also how to recover those errors with clear examples.