Chapter 4: Syntax Analysis

Error productions

. Add erroneous constructs as productions in the grammar

. Works only for most common mistakes which can be easily identified

. Essentially makes common errors as part of the grammar

. Complicates the grammar and does not work very well

If we have a good idea of the common errors that might be encountered, we can augment the grammar for the language at hand with productions that generate the erroneous constructs. We then use the grammar augmented by these error productions to construct a parser. If an error production is used by a parser, we can generate appropriate error diagnostics to indicate the error construct that has been recognized in the input. The main drawback of this approach is that it tends to complicate the grammar and thus does not work very well.