|
|
The input to the parser will sometimes not conform to the specifications. If no provision has been made to deal with errors, the processing halts when an error is detected. Instead of stopping all processing when an error is found, it is often more useful to continue scanning the input to find other syntax errors. Some of the problems associated with error handling are semantic ones. When an error is found, for example, it may be necessary to reclaim parse-tree storage, delete or alter symbol-table entries, or set switches to avoid generating any further output.
Error handling mechanisms can be provided as part of the input specifications. This permits the reentry of data after bad data has been seen, or the continuation of the input process after skipping over the bad data. This leads to the problem of where parser should resume parsing after an error. A general class of algorithms to do this involves discarding a number of tokens from the input string and attempting to adjust the parser so that input can continue.