a := z * (x + y) ; Semantic Error Recovery Represents the input - - PowerPoint PPT Presentation

a z x y semantic error recovery
SMART_READER_LITE
LIVE PREVIEW

a := z * (x + y) ; Semantic Error Recovery Represents the input - - PowerPoint PPT Presentation

a := z * (x + y) ; Semantic Error Recovery Represents the input params to the current routine Check 2 exprs (oops--int expr y...int required here) addop + semError (int reqd) NO codegen -- instead expr x...bool return the following


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 2 exprs (oops--int required here) semError (int reqd) NO codegen -- instead return the following

  • expr. errorentry

to get

We complain if we see a new error.

Represents the input params to the current routine

slide-2
SLIDE 2

2

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

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

MultExpr

  • expr. errorentry

Check 2 exprs (previous error) semError (int reqd) NO codegen -- instead return 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

ParallelAssign 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, - silently return error (b) Check for current errors (illegal types...) if seen, - complain and return error (c) Otherwise, do the right thing.

Note: We only return an expression error if the function normally returns an expr. If not, 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. You can also build two layers (or more) of procedures: The high level procs call the low level ones. You can build an equal method into the type descriptors to help with this. 1. 2.