Error Recovery - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Error Recovery

Description:

Unfortunately, error states can cause problems when semantic actions are ... Burke-Fisher Error Repair. Tries every possible single-token insertion, deletion, ... – PowerPoint PPT presentation

Number of Views:138
Avg rating:3.0/5.0
Slides: 9
Provided by: KimHaz
Category:
Tags: err | error | recovery

less

Transcript and Presenter's Notes

Title: Error Recovery


1
Error Recovery
  • CS 671
  • February 5, 2008

2
Previously
  • Top-Down Parsing, e.g. LL(1)
  • Bottom-Up Parsing, e.g. LR(1)
  • Next Question
  • What if the compiler finds a syntactic error?

3
Error Recovery
  • What if the compiler finds a syntactic error?
  • Ideally, report all errors, not just first
  • Approaches
  • Local error recovery Find synch point, resume
  • Global error recovery Change input, resume

4
Local Error Recovery
  • Informally, skip to next synchronizing token
  • Example
  • exp ? ID
  • exp ? exp exp
  • exp ? ( exps )
  • exps ? exp
  • exps ? exps exp
  • Skip to next SEMICOLON or RPAREN
  • Resume parsing
  • How? Introduce new terminal symbols and rules
  • exp ? ( error )
  • exps ? error exp

5
Caution
  • Unfortunately, error states can cause problems
    when semantic actions are attached (unless were
    careful). Consider
  • statements statements exp SEMICOLON
  • statements error SEMICOLON
  • / empty /
  • exp increment exp decrement
  • ID
  • increment LPAREN nestnest1
  • increment RPAREN nestnest-1

6
Global Error Repair
  • Another way to recover insert/delete tokens
    before the point of the error
  • let type a intArray 10 of 0 in
  • (real error type should be var)
  • Global repair Find smallest set of insertions or
    deletions that would convert string to a
    syntactically correct string (not always at error
    point)
  • Outcome type ? var (1 replacement)

7
Burke-Fisher Error Repair
  • Tries every possible single-token insertion,
    deletion, replacement up to K tokens before
    error.
  • Chooses Whichever replacement, etc. allows it
    to progress farthest after error
  • Realistic limit 4 tokens beyond error is good
    enough

error
K
8
Yacc Support for Error Correction
  • The value directive (used during insertions)
  • value ID (bogus)
  • value INT (1)
  • value STRING ()
  • Programmer specified substitutions
  • change EQ -gt ASSIGN
  • ASSIGN -gt EQ
  • SEMICOLON ELSE -gt ELSE
  • -gt RBRACE

Scope closer
Write a Comment
User Comments (0)
About PowerShow.com