Reference. Interval Parsing Grammars for File Format Parsing
File formats specify how data is encoded for persistent storage. They cannot be formalized as context-free grammars since their specifications include context-sensitive patterns such as the random access pattern and the type-length-value pattern. We propose a new grammar mechanism called Interval Parsing Grammars IPGs) for file format specifications. An IPG attaches to every nonterminal/terminal an interval, which specifies the range of input the nonterminal/terminal consumes. By connecting intervals and attributes, the context-sensitive patterns in file formats can be well handled. In this paper, we formalize IPGs’ syntax as well as its semantics, and its semantics naturally leads to a parser generator that generates a recursive-descent parser from an IPG. In general, IPGs are declarative, modular, and enable termination checking. We have used IPGs to specify a number of file formats including ZIP, ELF, GIF, PE, and part of PDF; we have also evaluated the performance of the generated parsers.
Cite
Cites 24 works (3 here)
With notes (3)
Adaptive LL(*) parsing: the power of dynamic analysis parr-2014-adaptive
The next 700 data description languages fisher-2006-the
PADS: a domain-specific language for processing ad hoc data fisher-2005-pads
External (21)
- DISV: Domain Independent Semantic Validation of Data Files (2023)
- Interval Parsing Grammars for File Format Parsing (artifact) (2023)
- Parsing PEGs with Length Fields in Software and Hardware (2021)
- Research Report: The Parsley Data Format Definition Language (2020)
- EverParse: Verified Secure Zero-Copy Parsers for Authenticated Message Formats (2019)
- Generation of Code for Reading Data from the Declarative File Format Specifications Written in Language FlexT (2018)
- Scalable Vector Graphics (SVG) 2 (W3C) (2018)
- Kaitai Struct User Guide (2015)
- Nail: a practical tool for parsing and generating data formats (2014)
- Abusing File Processing in Malware Detectors for Fun and Profit (2012)
- Grammar-Based Specification and Parsing of Binary File Formats (2012)
- Semantics and algorithms for data-dependent grammars (2010)
- Z3: An Efficient SMT Solver (2008)
- Document management — Portable Document Format — Part 1: PDF 1.7 (Adobe) (2008)
- Parsing Expression Grammars: A Recognition-based Syntactic Foundation (2004)
- DataScript- A Specification and Scripting Language for Binary Data (2002)
- Monadic Parsing in Haskell (1998)
- Executable and Linking Format (ELF) Specification, Version 1.2 (1995)
- Compilers: Principles, Techniques, and Tools (1986)
- Finding All the Elementary Circuits of a Directed Graph (1975)
- Semantics of context-free languages (1968)