natural and flexible error
play

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


  1. Natural and Flexible Error Recovery for Generated Parsers Maartje de Jonge Emma Nilsson-Nyman Lennart Kats Eelco Visser

  2. Error Recovery • Error Location • Failure Location Error location Failure location

  3. Error Recovery • Traditional approaches – Panic mode

  4. Error Recovery • Traditional approaches – Panic mode – Delete / insert tokens }

  5. Error Recovery • Traditional approaches – Panic mode – Delete / insert tokens – Recover productions

  6. Error Recovery • Traditional approaches – Panic mode – Delete / insert tokens – Recover productions • Issues – Poor quality – Language dependency

  7. Error Recovery • Requirements – High quality – Language independent – SGLR

  8. 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

  9. Fine-Grained Repair • Recover productions introduce ambiguities • Ambiguities create a search space of alternate parses • Problem: find the best parse alternative Figure: Alternate interpretations of “ i = f ( x + 1 ;”

  10. Fine-Grained Repair • Parallel Parsing – Bad performance if applied on large regions • Backtracking – Good performance in Figure: Search space for recover regular cases rule: insert ‘)’ – Bad performance in worst- case scenarios

  11. Error location Failure location Figure: Backtracking over a large region

  12. Remove: ‘<’, Remove: password Expected: ‘;’ Expected: ‘;’ Remove: ‘${’, Remove: ‘}‘, Expected: ‘;’ Remove: ‘|>’ Figure: Parsing SQL as Java

  13. Remove:‘/’ Figure: Clever but unnatural recovery

  14. 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

  15. Expected: ‘*/’ Error location Failure location Figure: Backtracking on a small region improves performance

  16. Fragment can not be parsed Figure: Fallback recovery solves problematic errors

  17. Insert:‘);’ Figure: Restricting backtracking to erroneous region avoids unnatural recoveries

  18. How to select the erroneous region?

  19. Bridge Parsing } Figure: Scope recovery by indentation

  20. Idea Figure: Region selection by indentation

  21. Idea Figure: Regions are independent blocks

  22. Idea Figure: Regions are independent blocks

  23. Idea • Issues – Assumption on use of indentation – Assumption on structure of language

  24. Region Selection • Select a candidate region • Check if the candidate contains the error • Repeat till the erroneous region is found

  25. 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

  26. Region Selection • Current • Previous – Child regions • Siblings • Parent • Grand parent Parse failure • …

  27. Region Selection

  28. Final Solution • Select erroneous region • Try Bridge Parsing • Try Fine Grained Repair • Skip region

  29. Evaluation • Testset – Missing tokens (65 tests) – Wrongly inserted tokens (8 tests) – Others (3 tests)

  30. Evaluation • Criteria – Excellent: Same as recovery by a human being – Good: Reasonable recovery without spurious errors – Poor: Poor recovery creating spurious errors

  31. Evaluation • Contribution of 100% 90% techniques 80% 70% – Region -> Fine Grained 60% – Bridge Parsing -> Region -> 50% Fine Grained 40% Poor 30% – Region -> Bridge Parsing + Good 20% Fine Grained 10% Excellent 0%

  32. Evaluation • Comparison with JDT 100% 90% – JDT 80% – Region -> Bridge Parsing + 70% 60% Fine-Grained 50% 40% Poor 30% Good 20% Excellent 10% 0%

  33. Evaluation • Language User – Quality – Performance • Language Developer – Language independent – Flexible – Transparent

  34. 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

  35. More Information Permissive Grammars Project: strategoxt.org/Stratego/PermissiveGrammars Email & Homepage: m.dejonge@tudelft.nl swerl.tudelft.nl/bin/view/Main/MaartjeDeJonge

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

  37. Robustness

  38. Dependent blocks

  39. Recovery Rules • Java recovery module – Insertions – Deletions

  40. Generalized Parsing

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend