<div class="csl-bib-body">
<div class="csl-entry">Schröder, M., & Cito, J. (2025). Static inference of regular grammars for ad hoc parsers. <i>Proceedings of the ACM on Programming Languages</i>, <i>9</i>(OOPSLA2), 276:1-276:31. https://doi.org/10.1145/3763054</div>
</div>
-
dc.identifier.uri
http://hdl.handle.net/20.500.12708/221009
-
dc.description.abstract
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.
en
dc.description.sponsorship
FWF - Österr. Wissenschaftsfonds
-
dc.language.iso
en
-
dc.publisher
Association for Computing Machinery (ACM)
-
dc.relation.ispartof
Proceedings of the ACM on Programming Languages
-
dc.rights.uri
http://creativecommons.org/licenses/by/4.0/
-
dc.subject
ad hoc parsers
en
dc.subject
regular grammars
en
dc.subject
refinement types
en
dc.subject
abstract interpretation
en
dc.title
Static inference of regular grammars for ad hoc parsers