Natural and Flexible Error Recovery for Generated Parsers Maartje - - PowerPoint PPT Presentation

natural and flexible error
SMART_READER_LITE
LIVE PREVIEW

Natural and Flexible Error Recovery for Generated Parsers Maartje - - PowerPoint PPT Presentation

Natural and Flexible Error Recovery for Generated Parsers Maartje de Jonge Emma Nilsson-Nyman Lennart Kats Eelco Visser Error Recovery Error Location Failure Location Error location Failure location Error Recovery Traditional


slide-1
SLIDE 1

Natural and Flexible Error Recovery for Generated Parsers

Maartje de Jonge Emma Nilsson-Nyman Lennart Kats Eelco Visser

slide-2
SLIDE 2
slide-3
SLIDE 3

Error Recovery

  • Error Location
  • Failure Location

Failure location Error location

slide-4
SLIDE 4

Error Recovery

  • Traditional approaches

– Panic mode

slide-5
SLIDE 5

Error Recovery

  • Traditional approaches

– Panic mode – Delete / insert tokens

}

slide-6
SLIDE 6

Error Recovery

  • Traditional approaches

– Panic mode – Delete / insert tokens – Recover productions

slide-7
SLIDE 7

Error Recovery

  • Traditional approaches

– Panic mode – Delete / insert tokens – Recover productions

  • Issues

– Poor quality – Language dependency

slide-8
SLIDE 8

Error Recovery

  • Requirements

– High quality – Language independent – SGLR

slide-9
SLIDE 9
slide-10
SLIDE 10

Fine-Grained Repair

  • Error recovery for SGLR (OOPSLA 2009)

– Extend grammar with recover productions

  • Insert special characters
  • Delete special characters and words

– Derive recover rules from grammar – Adapt parse algorithm to parse recover options

slide-11
SLIDE 11

Fine-Grained Repair

  • Recover productions

introduce ambiguities

  • Ambiguities create a

search space of alternate parses

  • Problem: find the best

parse alternative

Figure: Alternate interpretations

  • f “ i = f ( x + 1 ;”
slide-12
SLIDE 12

Fine-Grained Repair

  • Parallel Parsing

– Bad performance if applied

  • n large regions
  • Backtracking

– Good performance in regular cases – Bad performance in worst- case scenarios

Figure: Search space for recover rule: insert ‘)’

slide-13
SLIDE 13

Failure location Error location

Figure: Backtracking over a large region

slide-14
SLIDE 14

Figure: Parsing SQL as Java

Remove: ‘<’, Remove: password Expected: ‘;’ Expected: ‘;’ Remove: ‘${’, Remove: ‘}‘, Expected: ‘;’ Remove: ‘|>’

slide-15
SLIDE 15

Figure: Clever but unnatural recovery

Remove:‘/’

slide-16
SLIDE 16

Problems with Fine-Grained Recovery

  • Performance problems

– Large area of text is inspected – Many recover actions are required

  • Quality problems

– ‘Clever’ solutions

Solution in SLE Paper

  • Technique for selecting erroneous region

– Restricts area of text that is inspected – Fallback recovery: skip erroneous region

slide-17
SLIDE 17

Failure location Error location

Figure: Backtracking on a small region improves performance

Expected: ‘*/’

slide-18
SLIDE 18

Figure: Fallback recovery solves problematic errors

Fragment can not be parsed

slide-19
SLIDE 19

Figure: Restricting backtracking to erroneous region avoids unnatural recoveries

Insert:‘);’

slide-20
SLIDE 20

How to select the erroneous region?

slide-21
SLIDE 21

}

Bridge Parsing

Figure: Scope recovery by indentation

slide-22
SLIDE 22

Idea

Figure: Region selection by indentation

slide-23
SLIDE 23

Idea

Figure: Regions are independent blocks

slide-24
SLIDE 24

Idea

Figure: Regions are independent blocks

slide-25
SLIDE 25

Idea

  • Issues

– Assumption on use of indentation – Assumption on structure of language

slide-26
SLIDE 26

Region Selection

  • Select a candidate region
  • Check if the candidate contains the error
  • Repeat till the erroneous region is found
slide-27
SLIDE 27

Region Selection

  • Parser fails because of

unexpected token

  • Select current region
  • Reset parser to prior

position

  • Skip the selected region

and resume parsing

  • Parsing continues, so

the erroneous region is detected

slide-28
SLIDE 28

Region Selection

  • Current
  • Previous

– Child regions

  • Siblings
  • Parent
  • Grand parent

Parse failure

slide-29
SLIDE 29

Region Selection

slide-30
SLIDE 30

Final Solution

  • Select erroneous region
  • Try Bridge Parsing
  • Try Fine Grained Repair
  • Skip region
slide-31
SLIDE 31

Evaluation

  • Testset

– Missing tokens (65 tests) – Wrongly inserted tokens (8 tests) – Others (3 tests)

slide-32
SLIDE 32

Evaluation

  • Criteria

– Excellent: Same as recovery by a human being – Good: Reasonable recovery without spurious errors – Poor: Poor recovery creating spurious errors

slide-33
SLIDE 33

Evaluation

  • Contribution of

techniques

– Region -> Fine Grained – Bridge Parsing -> Region -> Fine Grained – Region -> Bridge Parsing + Fine Grained

0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% Poor Good Excellent

slide-34
SLIDE 34

Evaluation

  • Comparison with JDT

– JDT – Region -> Bridge Parsing + Fine-Grained

0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 100% Poor Good Excellent

slide-35
SLIDE 35

Evaluation

  • Language User

– Quality – Performance

  • Language Developer

– Language independent – Flexible – Transparent

slide-36
SLIDE 36

Summary

  • Region Selection

– Selects erroneous region by using indentation – Used as a preprocessor for a correcting technique, or as fallback recovery – Can be implemented for all parsing algorithms

  • Bridge Parsing

– Scope recovery based on indentation – Works for all parsing algorithms

  • Fine-Grained Repair

– Inserting and deleting special tokens – Extends grammar with recover productions – Requires (S)GLR parsing

slide-37
SLIDE 37

More Information

Permissive Grammars Project:

strategoxt.org/Stratego/PermissiveGrammars

Email & Homepage:

m.dejonge@tudelft.nl swerl.tudelft.nl/bin/view/Main/MaartjeDeJonge

slide-38
SLIDE 38
slide-39
SLIDE 39

Braces

Figure: Same indentation pattern, different regions Figure: Different notations for braces

slide-40
SLIDE 40

Robustness

slide-41
SLIDE 41

Dependent blocks

slide-42
SLIDE 42
slide-43
SLIDE 43

Recovery Rules

  • Java recovery module

– Insertions – Deletions

slide-44
SLIDE 44

Generalized Parsing