Electrical Engineering
      and Computer Sciences

Electrical Engineering and Computer Sciences

COLLEGE OF ENGINEERING

UC Berkeley

Static Semantics and Compiler Error Recovery

Robert Paul Corbett

EECS Department
University of California, Berkeley
Technical Report No. UCB/CSD-85-251
June 1985

http://www.eecs.berkeley.edu/Pubs/TechRpts/1985/CSD-85-251.pdf

Good error recovery for compilers depends on accurate diagnosis of errors. When an error is misdiagnosed, the error message issued for it is apt to be misleading. Worse, the error recovery system may leave the compiler in a configuration that will cause spurious errors to be reported later. This dissertation presents new error recovery techniques for compilers that generally diagnose errors more accurately than earlier techniques.

The major innovation embodied in the new error recovery techniques is the use of general static semantic information to help detect and diagnose syntactic errors. There are usually many possible ways of recovering from an error. Testing if a potential recovery leads to semantic problems later involves executing the semantic actions associated with that recovery. If a potential recovery is rejected, the semantic actions that were performed while testing it must have no apparent effect on later compilation. Thus, it must be possible to undo the effects of semantic actions. For conventional compilers, the mechanisms needed to reverse the effects of semantic actions are too slow to be practical. A new compiler organization that permits semantic actions to be undone efficiently is presented. This new organization is suited for compiling languages, such as C, Pascal, and Ada, that require declarations to precede uses.

Two further ways of improving the performance of error recovery systems are considered. Error recovery systems sometimes fail to accurately diagnose an error because the parser has performed reductions based on erroneous input. A variety of techniques for avoiding the adverse effects of such reductions are presented and compared. Also, a new panic mode algorithm for use with LR parsers is presented.

The new error recovery techniques have been applied in an error checking program for Pascal. The recoveries produced by that program are shown to compare favorably with those produced by two well known error recovery systems. Finally, some drawbacks of the new techniques and some directions for future work are discussed.

Advisor: Susan L. Graham


BibTeX citation:

@phdthesis{Corbett:CSD-85-251,
    Author = {Corbett, Robert Paul},
    Title = {Static Semantics and Compiler Error Recovery},
    School = {EECS Department, University of California, Berkeley},
    Year = {1985},
    Month = {Jun},
    URL = {http://www.eecs.berkeley.edu/Pubs/TechRpts/1985/5514.html},
    Number = {UCB/CSD-85-251},
    Abstract = {Good error recovery for compilers depends on accurate diagnosis of errors. When an error is misdiagnosed, the error message issued for it is apt to be misleading. Worse, the error recovery system may leave the compiler in a configuration that will cause spurious errors to be reported later. This dissertation presents new error recovery techniques for compilers that generally diagnose errors more accurately than earlier techniques.  <p>  The major innovation embodied in the new error recovery techniques is the use of general static semantic information to help detect and diagnose syntactic errors. There are usually many possible ways of recovering from an error. Testing if a potential recovery leads to semantic problems later involves executing the semantic actions associated with that recovery. If a potential recovery is rejected, the semantic actions that were performed while testing it must have no apparent effect on later compilation. Thus, it must be possible to undo the effects of semantic actions. For conventional compilers, the mechanisms needed to reverse the effects of semantic actions are too slow to be practical. A new compiler organization that permits semantic actions to be undone efficiently is presented. This new organization is suited for compiling languages, such as C, Pascal, and Ada, that require declarations to precede uses.  <p>  Two further ways of improving the performance of error recovery systems are considered. Error recovery systems sometimes fail to accurately diagnose an error because the parser has performed reductions based on erroneous input. A variety of techniques for avoiding the adverse effects of such reductions are presented and compared. Also, a new panic mode algorithm for use with LR parsers is presented.  <p>  The new error recovery techniques have been applied in an error checking program for Pascal. The recoveries produced by that program are shown to compare favorably with those produced by two well known error recovery systems. Finally, some drawbacks of the new techniques and some directions for future work are discussed.}
}

EndNote citation:

%0 Thesis
%A Corbett, Robert Paul
%T Static Semantics and Compiler Error Recovery
%I EECS Department, University of California, Berkeley
%D 1985
%@ UCB/CSD-85-251
%U http://www.eecs.berkeley.edu/Pubs/TechRpts/1985/5514.html
%F Corbett:CSD-85-251