Chapter 4: Syntax Analysis

Panic mode

. Simplest and the most popular method

. Most tools provide for specifying panic mode recovery in the grammar

. When an error is detected

- Discard tokens one at a time until a set of tokens is found whose role is clear

- Skip to the next token that can be placed reliably in the parse tree

Let us discuss each of these methods one by one. Panic mode error recovery is the simplest and most commonly used method. On discovering the error, the parser discards input symbols one at a time until one of the designated set of synchronizing tokens is found. The synchronizing tokens are usually delimiters, such as semicolon or end , whose role in the source program is clear. The compiler designer must select the synchronizing tokens appropriate for the source language, of course.