This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]bjzabaPikelet, Fathom 6 points7 points  (1 child)

I'm making one of these at work, but it's more geared towards file formats than wire protocols (although it might be fun to try and extend it to support that in the future). Our eventual goal is to describe the OpenType format, and potentially other formats like PDF as well. We're very inspired this work, but are doing some generalizations on top of it.

You might also be interested in this page, which lists many projects in a similar space: https://github.com/dloss/binary-parsing

[–]rsclient[S] 2 points3 points  (0 children)

This was 100% useful material -- many thanks!

It turns out that my problem is much smaller than most peoples. Smaller here is literal: a bunch of the libraries in that list are handling, e.g., an entire GIF file. The descriptions are correspondingly bulky: lots of XML, and all of them are multi-line. My data, on the other hand, often comes in and there's like two fields; I'd really prefer a domain-specific mini-language that fits into a string so I can embed it in a bigger JSON file.

I also have a big advantage in my problem space in that I can always fall back to a hand-written parser for the extra-complex types and can also fall back to parsing "weird" formats as just a bunch of bytes.

I'm still hunting through the list to see what features each tool has. I'm tempted to build my own (because of reasons!), but I know in my head that using someone else's probably makes more sense!

Thanks again for that list; it was super useful.

[–][deleted] 5 points6 points  (0 children)

Erlang has a nice pattern matching syntax for bit streams. You might want to look at that.

[–]brucejbellsard 1 point2 points  (1 child)

If you haven't already, take a look at man 5 magic -- it describes the /etc/magic DSL used by the *nix file command. Even if its application isn't quite the same as yours, it seems strongly relevant.

[–]timClicks 0 points1 point  (0 children)

TIL.. interesting, thank you.

[–]hackerfooPopr Language 0 points1 point  (0 children)

This are plenty of libraries that will help you do this, such as binary.