Interval Parsing Grammars for File Format Parsing

被引:0
作者
Zhang, Jialun [1 ]
Morrisett, Greg [2 ]
Tan, Gang [1 ]
机构
[1] Penn State Univ, University Pk, PA 16802 USA
[2] Cornell Univ, Ithaca, NY USA
来源
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL | 2023年 / 7卷 / PLDI期
关键词
File Formats; Context-sensitive Grammars; LANGUAGE;
D O I
10.1145/3591264
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
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 contextsensitive 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.
引用
收藏
页数:23
相关论文
共 24 条
[1]  
Adobe, 2008, DOC MAN PORT DOC 493
[2]  
Back G, 2002, LECT NOTES COMPUT SC, V2487, P66
[3]  
Bangert Julian, 2014, Proceedings of the 11th USENIX Symposium on Operating Systems Design and Implementation (OSDI '14). OSDI '14, P615
[4]   Z3: An efficient SMT solver [J].
de Moura, Leonardo ;
Bjorner, Nikolaj .
TOOLS AND ALGORITHMS FOR THE CONSTRUCTION AND ANALYSIS OF SYSTEMS, 2008, 4963 :337-340
[5]  
ELF, 1995, EX LINK FORM ELF SPE
[6]   The next 700 data description languages [J].
Fisher, K ;
Mandelbaum, Y ;
Walker, D .
ACM SIGPLAN NOTICES, 2006, 41 (01) :2-15
[7]   PADS: A domain-specific language for processing ad hoc data [J].
Fisher, K ;
Gruber, R .
ACM SIGPLAN NOTICES, 2005, 40 (06) :295-304
[8]   Parsing expression grammars: A recognition-based syntactic foundation [J].
Ford, B .
ACM SIGPLAN NOTICES, 2004, 39 (01) :111-122
[9]   Generation of code for reading data from the declarative file format specifications written in language FlexT [J].
Hmelnov, Alexei ;
Mikhailov, Andrei .
2018 IVANNIKOV ISPRAS OPEN CONFERENCE (ISPRAS), 2018, :23-30
[10]   Abusing File Processing in Malware Detectors for Fun and Profit [J].
Jana, Suman ;
Shmatikov, Vitaly .
2012 IEEE SYMPOSIUM ON SECURITY AND PRIVACY (SP), 2012, :80-94