Statically Resolvable Ambiguity
Viktor Palmkvist, Elias Castegren, Philipp Haller, David Broman
Abstract
Traditionally, a grammar defining the syntax of a programming language is typically both context free and unambiguous. However, recent work suggests that an attractive alternative is to use ambiguous grammars,thus postponing the task of resolving the ambiguity to the end user. If all programs accepted by an ambiguous grammar can be rewritten unambiguously, then the parser for the grammar is said to be resolvably ambiguous. Guaranteeing resolvable ambiguity statically---for all programs---is hard, where previous work only solves it partially using techniques based on property-based testing. In this paper, we present the first efficient, practical, and proven correct solution to the statically resolvable ambiguity problem. Our approach introduces several key ideas, including splittable productions, operator sequences, and the concept of a grouper that works in tandem with a standard parser. We prove static resolvability using a Coq mechanization and demonstrate its efficiency and practical applicability by implementing and integrating resolvable ambiguity into an essential part of the standard OCaml parser.
Ask about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Related papers
- Automated Ambiguity Detection in Layout-Sensitive GrammarsJiangyi Liu, Fengmin Zhu, Fei HeOOPSLA 2023 · 2 citations
- flap: A Deterministic Parser with Fused LexingJeremy Yallop, Ningning Xie, Neel KrishnaswamiPLDI 2023 · 10 citations
- Type Inference LogicsDenis Carnier, François Pottier, Steven KeuchelOOPSLA 2024 · 3 citations
- A derivative-based parser generator for visibly Pushdown grammarsXiaodong Jia, Ashish Kumar, Gang TanOOPSLA 2021 · 7 citations
- SQUAB: Evaluating LLM robustness to Ambiguous and Unanswerable Questions in Semantic ParsingSimone Papicchio, Luca Cagliero, Paolo PapottiEMNLP 2025
