Reference. Zippy LL(1) parsing with derivatives
Cite
Cited by (3)
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
CoStar: A verified ALL(*) parser lasserCoStarVerifiedALL2021
Cites 58 works (14 here)
With notes (14)
A typed, algebraic approach to parsing krishnaswami_typed_2019
A Verified LL(1) Parser Generator lasserLL1_2019
CakeML: A verified implementation of ML kumar_cakeml_2014
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.
Formal verification of a realistic compiler leroy_formal_2009
Applicative programming with effects mcbride-2008-applicative
Deterministic regular languages bruggemannkleinwood
Towards Kleene Algebra with recursion leis_towards_1992
An efficient context-free parsing algorithm Earley1970
On the translation of languages from left to right KNUTH1965607
Derivatives of Regular Expressions brzozowskiDerivativesRegularExpressions1964
External (44)
- Derivative grammars: a symbolic approach to parsing with derivatives (2019)
- Grammars written for ANTLR v4 (2019)
- Scalameter: Automate your performance testing today (2019)
- EverParse: Verified Secure Zero-Copy Parsers for Authenticated Message Formats (2019)
- Equations reloaded: high-level dependently-typed functional programming and proving in Coq (2019)
- Incident report on memory leak caused by Cloudflare parser bug (Cloudflare Blog) (2019)
- FastParse 2.1.3 (Li Haoyi) (2019)
- Scala Parser Combinators (LAMP EPFL and Lightbend) (2019)
- JSON Generator (Omanashvili) (2019)
- Logical Foundations (Software Foundations, vol. 1) (2018)
- On the complexity and performance of parsing with derivatives (2016)
- POSIX Lexing with Derivatives of Regular Expressions (Archive of Formal Proofs) (2016)
- Parsing with first-class derivatives (2016)
- Derivatives of Logical Formulas (Archive of Formal Proofs) (2015)
- Decision Procedures for MSO on Words Based on Derivatives of Regular Expressions (2014)
- The definitive ANTLR 4 reference (2013)
- TRX: A Formally Verified Parser Interpreter (2010)
- Invertible syntax descriptions (2010)
- GLL Parsing (2010)
- Propagation Networks: A Flexible and Expressive Substrate for Computation (2009)
- DCGs + Memoing = Packrat Parsing but Is It Worth It? (2008)
- Some Aspects of Parsing Expression Grammar (2008)
- Compilers: Principles, Techniques, and Tools (2nd edition) (2006)
- Parsing expression grammars (2004)
- Practical Packrat Parsing (Grimm, NYU technical report) (2004)
- Packrat parsing: simple, powerful, lazy, linear time, functional pearl (2002)
- Parsec: Direct style monadic parser combinators for the real world (2001)
- The Derivative of a Regular Type is its Type of One-Hole Contexts (2001)
- Generalised recursive descent parsing and follow-determinism (1998)
- The Zipper (1997)
- Monadic parser combinators (1996)
- Deterministic, error-correcting combinator parsers (1996)
- Functional parsers (1995)
- Higher-order functions for parsing (1992)
- How to replace failure by a list of successes (1985)
- The Definition and Implementation of a Computer Programming Language Based on Constraints (1980)
- Recursive Programming Techniques (1975)
- Deterministic techniques for efficient non-deterministic parsers (1974)
- The Theory of Parsing, Translation, and Compiling, Vol. 1: Parsing (1972)
- Programming languages and their compilers (1969)
- PRACTICAL TRANSLATORS FOR LR(K) LANGUAGES (1969)
- Syntax-Directed Transduction (1968)
- Recognition and parsing of context-free languages in time n^3 (1967)
- An Efficient Recognition and Syntax-Analysis Algorithm for Context-Free Languages (1966)