Syntax Error Recovery in Parsing Expression Grammars

06/28/2018
by   Sérgio Medeiros, et al.
0

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 of PEGs with this recovery mechanism, and use an implementation based on such semantics to build a robust parser for the Lua language. We evaluate the effectiveness of this parser, alone and in comparison with a Lua parser with automatic error recovery generated by ANTLR, a popular parser generator.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
05/06/2019

A Semi-Automatic Approach for Syntax Error Reporting and Recovery in Parsing Expression Grammars

Error recovery is an essential feature for a parser that should be plugg...
research
05/13/2020

Pika parsing: reformulating packrat parsing as a dynamic programming algorithm solves the left recursion and error recovery problems

A recursive descent parser is built from a set of mutually-recursive fun...
research
01/13/2020

A Verified Packrat Parser Interpreter for Parsing Expression Grammars

Parsing expression grammars (PEGs) offer a natural opportunity for build...
research
11/15/2022

CSynGEC: Incorporating Constituent-based Syntax for Grammatical Error Correction with a Tailored GEC-Oriented Parser

Recently, Zhang et al. (2022) propose a syntax-aware grammatical error c...
research
12/18/2018

CPEG: A Typed Tree Construction from Parsing Expression Grammars with Regex-Like Captures

CPEG is an extended parsing expression grammar with regex-like capture a...
research
04/10/2023

Interval Parsing Grammars for File Format Parsing

File formats specify how data is encoded for persistent storage. They ca...
research
07/08/2019

parboiled2: a macro-based approach for effective generators of parsing expressions grammars in Scala

In today's computerized world, parsing is ubiquitous. Developers parse l...

Please sign up or login with your details

Forgot password? Click here to reset