Flap: A Deterministic Parser with Fused Lexing

3Citations
Citations of this article
9Readers
Mendeley users who have this article in their library.

Abstract

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.

Cite

CITATION STYLE

APA

Yallop, J., Xie, N., & Krishnaswami, N. (2023). Flap: A Deterministic Parser with Fused Lexing. Proceedings of the ACM on Programming Languages, 7. https://doi.org/10.1145/3591269

Register to see more suggestions

Mendeley helps you to discover research relevant for your work.

Already have an account?

Save time finding and organizing research with Mendeley

Sign up for free