A very substantial fraction of the time and efforts required to develop a program is devoted to the removal of errors. In order to simplify this task, a model to automatize the correction of syntax errors is developed. It is the first model which is both formal and fairly realistic to appear in the literature. The notion of error is defined and studied formally. Then, using this definition, a systematic error-correction process is modelled. This process makes local corrections over clusters of errors, using the context around the errors to determine the corrections and to insure that the different local corrections performed on the string do not interfere with one another. The error-correction process can be naturally embedded in many left-to-right syntax checking processes. It uses the recognizer both to detect errors and to find possible corrections. The process has two modes: a ``standard mode'''' used for syntax checking and an ``error-correction mode'''' used for determining the context of a cluster of errors and for finding all possible corrections of these errors. In the ``standard mode'''', the syntax is checked at the same speed as if no error-correction mechanism is implemented. Thus, for programs which contain no errors, no price is paid for the presence of this mechanism. The ``error-correction mode'''' consist of two phases: the backward move which locates the left context of the cluster, and the forward move which construct possible corrections and locates the right context of the cluster. This process seems the most natural way to perform left-to-right syntax checking and error correction. Some techniques for efficiently finding the range of the backward move are developed. The formal model is not practical when using the conventional context-free description of programming languages. In order to make it more practical, the notion of bracketed context-free language is introduced and proposed as a model for the syntax fo programming languages. Then, heuristic restrictions on the type of errors corrected are discussed. They may lead to a simpler process. In particular, assuming that brackets are corrected only when no other correction is possible, and that errors in deep levels of nesting (with respect to the point where the errors are detected) are neglected, it is shown how the process can be used to correct syntax errors in programming languages.
Cited By
- van den Bosch P (1992). A bibliography on syntax error handling in context free languages, ACM SIGPLAN Notices, 27:4, (77-86), Online publication date: 1-Apr-1992.
- Mickunas M and Modry J (1978). Automatic error recovery for LR parsers, Communications of the ACM, 21:6, (459-465), Online publication date: 1-Jun-1978.
- Tai K The recovery of parsing configurations for LR(1) parsers Proceedings of the 15th annual Southeast regional conference, (154-160)
- Wilcox T, Davis A and Tindall M (1976). The design and implementation of a table driven, interactive diagnostic programming system, Communications of the ACM, 19:11, (609-616), Online publication date: 1-Nov-1976.
- Graham S and Rhodes S (1975). Practical syntactic error recovery, Communications of the ACM, 18:11, (639-650), Online publication date: 1-Nov-1975.
- Conway R and Wilcox T (1973). Design and implementation of a diagnostic compiler for PL/I, Communications of the ACM, 16:3, (169-179), Online publication date: 1-Mar-1973.
Recommendations
Automatic correction of syntax-errors in programming languages
A formal model for automatic error-correction is presented. It considers clusters of errors, using a local context to determine the corrections. The process can be embedded in left-to-right recognizers. The recognizer is used for standard syntax ...
Locally minimum-distance correction of syntax errors in programming languages
ACM '80: Proceedings of the ACM 1980 annual conferenceA formal model for locally minimum-distance correction of syntax errors is presented. This model is based on the assumption that errors occur in clusters which are separated by at least k correct symbols. Even if the assumption fails, this model can ...
Stochastic Syntax-Directed Translation Schemata for Correction of Errors in Context-Free Languages
A formal method of correcting errors of changed, deleted, and inserted terminals in the strings of a context-free language is considered. Grammars generating strings containing these errors are first constructed from a known grammar for the language; ...