Reference. CoStar: A verified ALL(*) parser
Cite
Backlinks
Cited by (2)
Intrinsic Verification of Parsers and Formal Grammar Theory in Dependent Lambek Calculus intrinsic-verification-of-parsers
We present Dependent Lambek Calculus (Lambek), a domain-specific dependent type theory for verified parsing and formal grammar theory. In Lambek, linear types are used as a syntax for formal grammars, and parsers can be written as linear terms. The linear typing restriction provides a form of intrinsic verification that a parser yields only valid parse trees for the input string. We demonstrate the expressivity of this system by showing that the combination of inductive linear types and dependency on non-linear data can be used to encode commonly used grammar formalisms such as regular and context-free grammars as well as traces of various types of automata. Using these encodings, we define parsers for regular expressions using deterministic automata, as well as examples of verified parsers of context-free grammars.
We present a denotational semantics of our type theory that interprets the linear types as functions from strings to sets of abstract parse trees and terms as parse transformers. Based on this denotational semantics, we have made a prototype implementation of Lambek using a shallow embedding in the Agda proof assistant. All of our examples parsers have been implemented in this prototype implementation.
Verified ALL(*) Parsing with Semantic Actions and Dynamic Input Validation lasserCoStar2023
Cites 36 works (9 here)
With notes (9)
Zippy LL(1) parsing with derivatives EdelmannZippy2020
A Verified LL(1) Parser Generator lasserLL1_2019
Certified Normalization of Context-Free Grammars firsovCertifiedNormalizationContextFree2015
Adaptive LL(*) parsing: the power of dynamic analysis parr-2014-adaptive
Validating LR(1) Parsers jourdanValidatingLRParsers2012
Parsing with derivatives: A functional pearl mightParsingDerivativesFunctional2011
We present a functional approach to parsing unrestricted context-free grammars based on Brzozowski’s derivative of regular expressions. If we consider context-free grammars as recursive regular expressions, Brzozowski’s equational theory extends without modification to context-free grammars (and it generalizes to parser combinators). The supporting actors in this story are three concepts familiar to functional programmers - laziness, memoization and fixed points; these allow Brzozowski’s original equations to be transliterated into purely functional code in about 30 lines spread over three functions.
Yet, this almost impossibly brief implementation has a drawback: its performance is sour - in both theory and practice. The culprit? Each derivative can double the size of a grammar, and with it, the cost of the next derivative.
Fortunately, much of the new structure inflicted by the derivative is either dead on arrival, or it dies after the very next derivative. To eliminate it, we once again exploit laziness and memoization to transliterate an equational theory that prunes such debris into working code. Thanks to this compaction, parsing times become reasonable in practice.
We equip the functional programmer with two equational theories that, when combined, make for an abbreviated understanding and implementation of a system for parsing context-free languages.
LL(*): the foundation of the ANTLR parser generator parr-2011-ll
Total parser combinators danielssonTotalParserCombinators2010
A monadic parser combinator library which guarantees termination of parsing, while still allowing many forms of left recursion, is described. The library’s interface is similar to those of many other parser combinator libraries, with two important differences: one is that the interface clearly specifies which parts of the constructed parsers may be infinite, and which parts have to be finite, using dependent types and a combination of induction and coinduction; and the other is that the parser type is unusually informative.
The library comes with a formal semantics, using which it is proved that the parser combinators are as expressive as possible. The implementation is supported by a machine-checked correctness proof.
PADS: a domain-specific language for processing ad hoc data fisher-2005-pads
External (27)
- CoStar parser implementation, correctness proofs, and performance evaluation (2021)
- GitHub repository for the CoStar development and evaluation framework (2021)
- A verified packrat parser interpreter for parsing expression grammars (2020)
- The Coq Proof Assistant (version 8.11) (2020)
- Windows has a new wormable vulnerability and there's no patch in sight (Ars Technica) (2020)
- Critical PPP Daemon Flaw Opens Most Linux Systems to Remote Hackers (The Hacker News) (2020)
- CVE-2020-8597 (2020)
- Failure to patch two-month-old bug led to massive Equifax breach (Ars Technica) (2017)
- Cloudflare: Cloudflare Reverse Proxies are Dumping Uninitialized Memory (Project Zero issue 1139) (2017)
- CVE-2017-5638 (2017)
- On the complexity and performance of parsing with derivatives (2016)
- Reachability and error diagnosis in LR(1) parsers (2016)
- CVE-2016-0101 (2016)
- Certified CYK parsing of context-free languages (2014)
- ANTLR4 Grammar for Python 3 (2014)
- Simple, Functional, Sound and Complete Parsing for All Context-Free Grammars (2011)
- TRX: A Formally Verified Parser Interpreter (2010)
- GLL Parsing (2010)
- Open American National Corpus (2010)
- Verified, Executable Parsing (2009)
- Certified Web Services in Ynot (2009)
- Parsing expression grammars: a recognition-based syntactic foundation (2004)
- Generating LR syntax error messages from examples (2003)
- Packrat parsing: simple, powerful, lazy, linear time (2002)
- Robust Locally Weighted Regression and Smoothing Scatterplots (1979)
- Transition network grammars for natural language analysis (1970)
- Syntax-Directed Transduction (1968)