Errors[This slide adapted from one
by John Werth.]
Several kinds of errors are possible:
- Lexical: x := y ~ z
The character ~ is not allowed in Pascal.
- Syntactic: x := y z
There is no operator between y and z.
- Semantic: x := y mod 3.14
The operator mod requires integer arguments.
The seriousness of errors can vary:
- Diagnostic: not necessarily an error, but might be:
x == 3.14 may not be a meaningful comparison.
- Error: definitely an error; code generation will be aborted,
but compilation may continue.
- Fatal error: so bad that the compiler must stop immediately.
Cascading errors occur when one real
error causes many reported errors,
e.g. forgetting to declare a variable can cause an error at each use.