Lesson 5.3

Cards (13)

  • Error Handling
    The tasks are to detect each error, report it to the user, make a recovery strategy, and implement it to handle the error. The processing time of the program should not be slow
  • Error Handler
    • Error Detection, Error Report, Error Recovery
  • Types of Error
    • Logic errors
    • Run-time errors
    • Compile-time errors
  • Logic errors occur when programs operate incorrectly but do not terminate abnormally. Unexpected or undesired outputs may result from a logic error
  • A run-time error occurs during the execution of a program due to adverse system parameters or invalid input data
  • Compile-time errors arise before the execution of the program, such as syntax errors or missing file references
  • Classification of Compile-time error
    • Lexical
    • Syntactical
    • Semantical
    • Logical
  • Error Recovery
    The basic requirement for the compiler is to stop, issue a message, and cease compilation
  • Common Recovery Methods
    • Panic mode recovery
    • Phase level recovery
    • Error productions
    • Global correction
  • Panic mode recovery is the easiest way of error recovery, preventing infinite loops while recovering errors
  • Phase level recovery involves local correction on the remaining input to continue parsing
  • Error productions can be used to generate error messages during parsing and continue the process
  • Global correction involves analyzing the whole program to find the closest match for erroneous input