Error Handling in Compilers

Table of Contents

Error Kind Example Handled by
Lexical   Lexer
Syntax   Parser
Semantic   Type checker
Correctness   User

1. Error Recovery

1.1. Panic Mode

When an error is detected, parser discards tokens until one with clear role is found and then starts parsing from here.

1.2. Error Productions

The idea is to speficy known common mistakes in the grammar. But it has the disadvantage that it complicates the grammar.

1.3. Error Corrections

To find a correct “nearby” program by trying token insertions and deletions, and exhaustive search.

Date: 2026-06-13 Sat