A practical method for syntactic error diagnosis and recovery

  • Authors:
  • Michael Burke;Gerald A. Fisher, Jr.

  • Affiliations:
  • Courant Institute, New York University, 251 Mercer Street, New York, New York;Courant Institute, New York University, 251 Mercer Street, New York, New York

  • Venue:
  • SIGPLAN '82 Proceedings of the 1982 SIGPLAN symposium on Compiler construction
  • Year:
  • 1982

Quantified Score

Hi-index 0.00

Visualization

Abstract

Our goal is to develop a practical syntactic error recovery method applicable within the general framework of viable prefix parsing. Our method represents an attempt to accurately diagnose and report all syntax errors without reporting errors that are not actually present. Successful recovery depends upon accurate diagnosis of errors together with sensible “correction” or alteration of the text to put the parse back on track. The issuing of accurate and helpful diagnostics is achieved by indicating the nature of the recovery made for each error encountered. The error recovery is prior to and independent of any semantic analysis of the program. However, the method does not exclude the invocation of semantic actions while parsing or preclude the use of semantic information for error recovery. The method assumes a framework in which an LR or LL parser, driven by the tables produced by a parser generator, maintains an input symbol buffer, state or prediction stack, and parse stack. The input symbol buffer contains part or all of the sequence of remaining input tokens, including the current token. The LR state stack is analogous to the LL prediction stack; except when restricting our attention to the LL case, prediction stack shall serve as a generic term indicating the LR state or LL prediction stack. The parse stack contains the symbols of the right hand sides that have not yet been reduced.