DeepAI AI Chat
Log In Sign Up

A Verified Packrat Parser Interpreter for Parsing Expression Grammars

01/13/2020
by   Clement Blaudeau, et al.
Ecole Polytechnique
SRI International
0

Parsing expression grammars (PEGs) offer a natural opportunity for building verified parser interpreters based on higher-order parsing combinators. PEGs are expressive, unambiguous, and efficient to parse in a top-down recursive descent style. We use the rich type system of the PVS specification language and verification system to formalize the metatheory of PEGs and define a reference implementation of a recursive parser interpreter for PEGs. In order to ensure termination of parsing, we define a notion of a well-formed grammar. Rather than relying on an inductive definition of parsing, we use abstract syntax trees that represent the computational trace of the parser to provide an effective proof certificate for correct parsing and ensure that parsing properties including soundness and completeness are maintained. The correctness properties are embedded in the types of the operations so that the proofs can be easily constructed from local proof obligations. Building on the reference parser interpreter, we define a packrat parser interpreter as well as an extension that is capable of semantic interpretation. Both these parser interpreters are proved equivalent to the reference one. All of the parsers are executable. The proofs are formalized in mathematical terms so that similar parser interpreters can be defined in any specification language with a type system similar to PVS.

READ FULL TEXT

page 5

page 9

page 10

page 11

page 12

page 13

page 14

04/06/2018

Chart Parsing Multimodal Grammars

The short note describes the chart parser for multimodal type-logical gr...
05/13/2023

Morpheus: Automated Safety Verification of Data-dependent Parser Combinator Programs

Parser combinators are a well-known mechanism used for the compositional...
05/08/2023

Idris TyRE: a dependently typed regex parser

Regular expressions – regexes – are widely used not only for validating,...
04/10/2023

Interval Parsing Grammars for File Format Parsing

File formats specify how data is encoded for persistent storage. They ca...
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...
09/09/2021

A Derivative-based Parser Generator for Visibly Pushdown Grammars

In this paper, we present a derivative-based, functional recognizer and ...
11/19/2014

Type-Driven Incremental Semantic Parsing with Polymorphism

Semantic parsing has made significant progress, but most current semanti...