HackerPapers

arXiv:2304.05276cs.PL

flap: A Deterministic Parser with Fused Lexing

Jeremy Yallop, Ningning Xie, Neel Krishnaswami

Early discovery. Linked by one identifiable commenter. This paper is outside the main ranking; a mention is not an endorsement.

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.

arXiv comments
PLDI 2023 with appendix
Journal reference
DOI
doi:10.1145/3591269
Subjects
cs.PLProgramming Languages

On Hacker News

Linked by 1 identifiable commenter in 1 comment across 1 thread, from May 2023 to May 2023. Found in 2 HN submissions from Apr 2023 to Jun 2026. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments1 thread

    • There is an extended version on arXiv: https://arxiv.org/abs/2304.05276. Also, the artifact (Docker image + some guides, CC BY 4.0) for the OCaml library: https://zenodo.org/record/7824835. Edit: The opam file actually says the license is MIT. I'd be more inclined to believe…

      e4m2View on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.