Static Inference of Regular Grammars for Ad Hoc Parsers
Michael Schröder, Jürgen Cito
摘要
Parsing—the process of structuring a linear representation according to a given grammar—is a fundamental activity in software engineering. While formal language theory has provided theoretical foundations for parsing, the most common kind of parsers used in practice are written ad hoc. They use common string operations without explicitly defining an input grammar. These ad hoc parsers are often intertwined with application logic and can result in subtle semantic bugs. Grammars, which are complete formal descriptions of input languages, can enhance program comprehension, facilitate testing and debugging, and provide formal guarantees for parsing code. But writing grammars—e.g., in the form of regular expressions—can be tedious and error-prone. Inspired by the success of type inference in programming languages, we propose a general approach for static inference of regular input string grammars from unannotated ad hoc parser source code. We use refinement type inference to synthesize logical and string constraints that represent regular parsing operations, which we then interpret with an abstract semantics into regular expressions. Our contributions include a core calculus ?? Σ for representing ad hoc parsers, a formulation of (regular) grammar inference as refinement inference, an abstract interpretation framework for solving string refinement variables, and a set of abstract domains for efficiently representing the constraints encountered during regular ad hoc parsing. We implement our approach in the Panini system and evaluate its efficacy on a benchmark of 204 Python ad hoc parsers. Compared with state-of-the-art approaches, Panini produces better grammars (100 % precision, 93 % average recall) in less time (0.82 ± 2.85 s) without prior knowledge of the input space.
问问这篇 Paper
智能体会读完全文。
Lune 把这篇 Paper 索引到了最后一个公式,引用它的顶会 Paper 也一样。你提问,回答直接引用原文。
它引用的顶会 Paper13
- Mining input grammars from dynamic control flowRahul Gopinath, Björn Mathis, Andreas ZellerFSE 2020 · 被引用 60 次
- Symbolic Boolean derivatives for efficiently solving extended regular expression constraintsCaleb Stanford, Margus Veanes, Nikolaj S. BjørnerPLDI 2021 · 被引用 38 次
- An SMT Solver for Regular Expressions and Linear Arithmetic over String LengthMurphy Berzish, Mitja Kulczynski, Federico Mora, Florin Manea 等CAV 2021 · 被引用 37 次
- Z3str4: A Multi-armed String SolverFederico Mora, Murphy Berzish, Mitja Kulczynski, Dirk Nowotka 等FM 2021 · 被引用 30 次
- Learning Highly Recursive Input GrammarsNeil Kulkarni, Caroline Lemieux, Koushik SenASE 2021 · 被引用 24 次
相关 Paper
- One down, 699 to go: or, synthesising compositional desugaringsSándor Bartha, James Cheney, Vaishak BelleOOPSLA 2021 · 被引用 2 次
- Intrinsic Verification of Parsers and Formal Grammar Theory in Dependent Lambek CalculusSteven Schaefer, Nathan Varner, Pedro Henrique Azevedo de Amorim, Max S. NewPLDI 2025
- Incremental Context-free Grammar Inference in Black Box SettingsFeifei Li, Xiao Chen, Xi Xiao, Xiaoyu Sun 等ASE 2024 · 被引用 1 次
- Context-Free Grammar Inference for Complex Programming Languages in Black Box SettingsFeifei Li, Xiao Chen, Xiaoyu Sun, Xi Xiao 等ICSE 2026
- Inferring and Applying Type ChangesAmeya Ketkar, Oleg Smirnov, Nikolaos Tsantalis, Danny Dig 等ICSE 2022 · 被引用 17 次
