Reference. Adaptive LL(*) parsing: the power of dynamic analysis
Cite
Cited by (5)
flap: A Deterministic Parser with Fused Lexing yallop-2023-flap
Lexers and parsers are typically defined separately and connected by a token stream. This separate definition is important for modularity and reduces the potential for parsing ambiguity. However, materializing tokens as data structures and case-switching on tokens comes with a cost. We show how to fuse separately-defined lexers and parsers, drastically improving performance without compromising modularity or increasing ambiguity. We propose a deterministic variant of Greibach Normal Form that ensures deterministic parsing with a single token of lookahead and makes fusion strikingly simple, and prove that normalizing context free expressions into the deterministic normal form is semantics-preserving. Our staged parser combinator library, flap, provides a standard interface, but generates specialized token-free code that runs two to six times faster than ocamlyacc on a range of benchmarks.
Interval Parsing Grammars for File Format Parsing zhangIntervalParsingGrammars2023
File formats specify how data is encoded for persistent storage. They cannot be formalized as context-free grammars since their specifications include context-sensitive patterns such as the random access pattern and the type-length-value pattern. We propose a new grammar mechanism called Interval Parsing Grammars IPGs) for file format specifications. An IPG attaches to every nonterminal/terminal an interval, which specifies the range of input the nonterminal/terminal consumes. By connecting intervals and attributes, the context-sensitive patterns in file formats can be well handled. In this paper, we formalize IPGs’ syntax as well as its semantics, and its semantics naturally leads to a parser generator that generates a recursive-descent parser from an IPG. In general, IPGs are declarative, modular, and enable termination checking. We have used IPGs to specify a number of file formats including ZIP, ELF, GIF, PE, and part of PDF; we have also evaluated the performance of the generated parsers.
Verified ALL(*) Parsing with Semantic Actions and Dynamic Input Validation lasserCoStar2023
CoStar: A verified ALL(*) parser lasserCoStarVerifiedALL2021
Parsers are security-critical components of many software systems, and verified parsing therefore has a key role to play in secure software design. However, existing verified parsers for context-free grammars are limited in their expressiveness, termination properties, or performance characteristics. They are only compatible with a restricted class of grammars, they are not guaranteed to terminate on all inputs, or they are not designed to be performant on grammars for real-world programming languages and data formats. In this work, we present CoStar, a verified parser that addresses these limitations. The parser is implemented with the Coq Proof Assistant and is based on the ALL(*) parsing algorithm. CoStar is sound and complete for all non-left-recursive grammars; it produces a correct parse tree for its input whenever such a tree exists, and it correctly detects ambiguous inputs. CoStar also provides strong termination guarantees; it terminates without error on all inputs when applied to a non-left-recursive grammar. Finally, CoStar achieves linear-time performance on a range of unambiguous grammars for commonly used languages and data formats.
A Verified LL(1) Parser Generator lasserLL1_2019
An LL(1) parser is a recursive descent algorithm that uses a single token of lookahead to build a grammatical derivation for an input sequence. We present an LL(1) parser generator that, when applied to grammar G, produces an LL(1) parser for G if such a parser exists. We use the Coq Proof Assistant to verify that the generator and the parsers that it produces are sound and complete, and that they terminate on all inputs without using fuel parameters. As a case study, we extract the tool’s source code and use it to generate a JSON parser. The generated parser runs in linear time; it is two to four times slower than an unverified parser for the same grammar.
Cites 25 works (2 here)
With notes (2)
LL(*): the foundation of the ANTLR parser generator parr-2011-ll
An efficient context-free parsing algorithm Earley1970
A parsing algorithm which seems to be the most efficient general context-free algorithm known is described. It is similar to both Knuth’s LR(k) algorithm and the familiar top-down algorithm. It has a time bound proportional to n3 (where n is the length of the string being parsed) in general; it has an n2 bound for unambiguous grammars; and it runs in linear time on a large class of grammars, which seems to include most practical context-free programming language grammars. In an empirical comparison it appears to be superior to the top-down and bottom-up algorithms studied by Griffiths and Petrick.
External (23)
- The Definitive ANTLR 4 Reference (2013)
- DParser: GLR parser generator (2013)
- Semantics and algorithms for data-dependent grammars (2010)
- GLL Parsing (2010)
- Better extensibility through modular syntax (2006)
- Parsing expression grammars: a recognition-based syntactic foundation (2004)
- Elkhound: A Fast, Practical GLR Parser Generator (2004)
- Fundamentals of Digital Logic with Verilog Design (2003)
- Elkhound: A fast, practical GLR parser generator (Tech. rep., UC Berkeley) (2002)
- A faster Earley parser (1996)
- Adding semantic and syntactic predicates to LL(k): pred-LL(k) (1994)
- Efficient construction of LR( k ) states and tables (1991)
- GLR Parsing in Time O(n 3 ) (1991)
- LR recursive transition networks for Earley and Tomita parsing (1991)
- The computational complexity of GLR parsing (1991)
- Practical arbitrary lookahead LR parsing (1990)
- The top-down parsing of expressions (1986)
- Efficient Parsing for Natural Language (1986)
- Robust Locally Weighted Regression and Smoothing Scatterplots (1979)
- Introduction to Automata Theory, Languages, and Computation (1979)
- LL-regular grammars (1975)
- LR-regular grammars An extension of LR(k) grammars (1971)
- Transition network grammars for natural language analysis (1970)