Automated Ambiguity Detection in Layout-Sensitive Grammars
Jiangyi Liu, Fengmin Zhu, Fei He
摘要
Layout-sensitive grammars have been adopted in many modern programming languages. In a serious language design phase, the specified syntax-typically a grammar-must be unambiguous. Although checking ambiguity is undecidable for context-free grammars and (trivially also) layout-sensitive grammars, ambiguity detection, on the other hand, is possible and can benefit language designers from exposing potential design flaws.
In this paper, we tackle the ambiguity detection problem in layout-sensitive grammars. Inspired by a previous work on checking the bounded ambiguity of context-free grammars via SAT solving, we intensively extend their approach to support layout-sensitive grammars but via SMT solving to express the ordering and quantitative relations over line/column numbers. Our key novelty lies in a reachability condition, which takes the impact of layout constraints on ambiguity into careful account. With this condition in hand, we propose an equivalent ambiguity notion called local ambiguity for the convenience of SMT encoding. We translate local ambiguity into an SMT formula and developed a bounded ambiguity checker that automatically finds a shortest nonempty ambiguous sentence (if exists) for a user-input grammar. The soundness and completeness of our SMT encoding are mechanized in the Coq proof assistant. We conducted an evaluation on both grammar fragments and full grammars extracted from the language manuals of domain-specific languages like YAML as well as general-purpose languages like Python, which reveals the effectiveness of our approach. CCS Concepts: • Software and its engineering → Syntax; Parsers; • Theory of computation → Grammars and context-free languages; Constraint and logic programming.
问问这篇 Paper
智能体会读完全文。
Lune 把这篇 Paper 索引到了每一个公式,引用它的顶会 Paper 也一样。你提问,回答直接引用原文。
它引用的顶会 Paper2
相关 Paper
- Statically Resolvable AmbiguityViktor Palmkvist, Elias Castegren, Philipp Haller, David BromanPOPL 2023 · 被引用 1 次
- Solving String Constraints with Lengths by StabilizationYu-Fang Chen, David Chocholatý, Vojtech Havlena, Lukás Holík 等OOPSLA 2023 · 被引用 18 次
- Saggitarius: A DSL for Specifying Grammatical DomainsAnders Miltner, Devon Loehr, Arnold Mong, Kathleen Fisher 等OOPSLA 2023 · 被引用 1 次
- Solving String Split Constraints via Structural RelaxationRui Han, Ziheng Wang, Baoquan Cui, Yuhang Dong 等ISSTA 2026
- Diagramming Program Values by Spatial RefinementSiddhartha Prasad, Michael Tu, Karan Kashyap, Tim Nelson 等PLDI 2026
