Published August 22, 2025
| Version oopsla25
Software
Open
Artifact for 'Static Inference of Regular Grammars for Ad Hoc Parsers'
Description
This artifact is the complete source code repository of Panini, our prototype system for inferring regular grammars for ad hoc parsers, as it was at the time of our OOPSLA'25 paper (Git tag oopsla25). This includes an extensive benchmark suite comparing Panini to other state-of-the-art grammar inference approaches, supporting the claims made in § 6 of our paper.
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 lambda 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.
Files
mcschroeder/panini-oopsla25.zip
Files
(17.2 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:e1de2e343cae449c0b1ba3ceee21ba71
|
17.2 MB | Preview Download |
Additional details
Related works
- Is supplement to
- Software: https://github.com/mcschroeder/panini/tree/oopsla25 (URL)
Software
- Repository URL
- https://github.com/mcschroeder/panini
- Programming language
- Haskell