a := z * (x + y) ; Semantic Error Recovery Check ST & ST-2 - - PowerPoint PPT Presentation

a z x y semantic error recovery
SMART_READER_LITE
LIVE PREVIEW

a := z * (x + y) ; Semantic Error Recovery Check ST & ST-2 - - PowerPoint PPT Presentation

a := z * (x + y) ; Semantic Error Recovery Check ST & ST-2 (oops) expr y...int semError (int reqd) addop + NO codegen -- instead ST := ST - 2 and insert expr x...bool the following expr. errorentry to get mulop * expr z...int


slide-1
SLIDE 1

1

Semantic Error Recovery a := z * (x + y) • ;

expr a ... int expr y...int addop + expr x...bool mulop * expr z...int

AddExpr Check ST & ST-2 (oops) semError (int reqd) NO codegen -- instead ST := ST - 2 and insert the following

  • expr. errorentry to get

We complain if we see a new error.

slide-2
SLIDE 2

2

Semantic Error Recovery a := z * (x + y) • ;

expr a ... int mulop * expr z...int

MultExpr

  • expr. errorentry

Check ST & ST-2 (previous error) semError (int reqd) NO codegen -- instead ST := ST - 2 and insert the following

  • expr. errorentry to get

We don’t complain if we see an

  • ld error, but we propagate it if

possible.

slide-3
SLIDE 3

3

Semantic Error Recovery a := z * (x + y) • ;

expr a ... int

Assign Check ST & ST-1 (previous error) semError (int reqd) NO codegen -- instead ST := ST - 2

  • expr. errorentry

We don’t leave a special entry because the genStore protocol doesn’t leave any entries at all.

slide-4
SLIDE 4

4

Semantic Error Recovery Rules: (a) Check for previous errors (special entry) if seen, tear down & propagate - silently (b) Check for current errors (illegal types...) if seen, tear down & propagate - complaining (c) Otherwise, do the right thing.

Note: When tearing down, propagate any error to some remaining entry. If none remain the evidence of the error disappears from the run.

slide-5
SLIDE 5

5

Notes: (a) Only one error message is issued. (b) All other action routines have a normal input protocol - except for the special entry. (c) Eventually the error entry disappears and you are back to normal processing. Semantic Error Recovery

slide-6
SLIDE 6

6

Semantic Error Recovery Hint: Build procedures to do this checking. Otherwise your logic will get convoluted. Pass entry numbers to these procedures. You can also build two layers (or more) of procedures: genAdd calls “okForArithmetic” which calls procedures at a lower layer. “okForArithmetic” can be reused in genMult, and the lower layer procedures can be used by several of the first layer procedures. 1. 2. 3.