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