Alex Rivera | Logout

Name me a Binary Parser. A parser for binary data

Asked 2010-02-06T21:43:46.857
23

So, I'm getting this data. From the network socket, or out of a file. I'm cobbling together code that will interpret the data. Read some bytes, check some flags, and some bytes indicate how much data follows. Read in that much data, rinse, repeat.

This task reminds me much to parsing source code. I'm comfy with lex/yacc and antlr, but they're not up to this task. You can't specify bits and raw bytes as tokens (well, maybe you could, but I wouldn't know how), and you can't coax them into "read two bytes, make them into an unsigned 16bit integer, call it n, and then read n bytes.".

Then again, when the spec of the protocol/data format is defined in a systematic manner (not all of them are), there should be a systematic way to read in data that is formatted according to the protocol. Right?

There's gotta be a tool that does that.

Edit
Report

2 Answers

3

The Construct parser, written in Python, has done some interesting work in this field.

The project has had a number of authors, and periods of stagnation, but as of 2017 it seems to be more active again.

answered 2010-10-19T05:06:32.647
1
answered 2012-10-02T20:57:29.117

Your Answer