Syntax Error Recovery in Parsing Expression Grammars
S\'ergio Medeiros, Fabio Mascarenhas

TL;DR
This paper introduces a novel error recovery mechanism for Parsing Expression Grammars (PEGs) using labeled failures, enabling PEG parsers to better handle syntax errors and be more suitable for IDE integration.
Contribution
It proposes a conservative extension to PEGs with labeled failures that adds syntax error recovery capabilities, supported by an operational semantics and a practical implementation.
Findings
The extended PEG parser effectively recovers from syntax errors.
The PEG-based Lua parser outperforms ANTLR's error recovery in robustness.
The approach improves PEG parser usability in IDEs.
Abstract
Parsing Expression Grammars (PEGs) are a formalism used to describe top-down parsers with backtracking. As PEGs do not provide a good error recovery mechanism, PEG-based parsers usually do not recover from syntax errors in the input, or recover from syntax errors using ad-hoc, implementation-specific features. The lack of proper error recovery makes PEG parsers unsuitable for using with Integrated Development Environments (IDEs), which need to build syntactic trees even for incomplete, syntactically invalid programs. We propose a conservative extension, based on PEGs with labeled failures, that adds a syntax error recovery mechanism for PEGs. This extension associates recovery expressions to labels, where a label now not only reports a syntax error but also uses this recovery expression to reach a synchronization point in the input and resume parsing. We give an operational semantics…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
