Back to Search Start Over

flap: A Deterministic Parser with Fused Lexing

Authors :
Yallop, Jeremy
Xie, Ningning
Krishnaswami, Neel
Yallop, J [0009-0002-1650-6340]
Xie, N [0000-0002-5961-1493]
Krishnaswami, N [0000-0003-2838-5865]
Apollo - University of Cambridge Repository
Publication Year :
2023
Publisher :
arXiv, 2023.

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.<br />Comment: PLDI 2023 with appendix

Details

Database :
OpenAIRE
Accession number :
edsair.doi.dedup.....5ad3bfee71e99f9115973044adaf4b50
Full Text :
https://doi.org/10.48550/arxiv.2304.05276