| 1 |
Usually it is not acceptable to have a program terminate on a parse |
| 2 |
error. For example, a compiler should recover sufficiently to parse the rest |
| 3 |
of the input file and check it for errors; a calculator should accept another |
| 4 |
expression. Such errors violate the grammar for which the parser was |
| 5 |
constructed and are called em(syntactic errors). Other types of errors are |
| 6 |
called em(semantical errors): here the intended em(meaning) of the language is |
| 7 |
not observed. For example, a division by too small a numeric constant (e.g., |
| 8 |
0) may be detected by the parser em(compile time). In general, what em(can) be |
| 9 |
detected compile time should not left for the run-time to detect, and so the |
| 10 |
parser should flag an error when it detects a division by a very small |
| 11 |
numerical constant. B()'s parsers may detect both syntactic em(and) |
| 12 |
semantical errors. Syntactical errors are detected automatically, while |
| 13 |
the parser performs its parsing-job, semantical errors must explicitly be |
| 14 |
defined when the grammar is constructed. The following sections cover the way |
| 15 |
B()'s parser may handle syntactic errors and semantical errors, respectively. |