Kaitai Struct: declarative binary format parsing language
kaitai.io
kaitai.io
For other people who might not look as far, it seems that the main advantage of this over other solutions (PB, Cap'n Proto, Flatbuffers, etc.) is that you can describe types that don't originate in the Kaitai ecosystem, and come out with code that can correctly read and manipulate those datatypes.
One slightly unfortunate item -- I don't see anything about using the generated code in a zero-copy situation. The docs are not very detailed on the point of the generated API, so perhaps this capability is present and just not documented in an easy-to-find way. This is not fatal, it's just a slightly less than optimal state of affairs.
Reading the stream API ([1]), it seems this is correct. There is nothing like Cap'n Proto-like direct-access semantics, nor even anything on the level of ZeroCopyInputStream [2].
[1]: https://github.com/kaitai-io/kaitai_struct_cpp_stl_runtime/b...
[2]: https://developers.google.com/protocol-buffers/docs/referenc...
https://www.gnu.org/software/emacs/manual/html_node/elisp/Bi...
I wrote a set of OCaml macros to do the same thing: https://people.redhat.com/rjones/bitstring/html/Bitstring.ht...
Their registry hive module looked correct and extremely simple. Was also impressed with the ISO support to parse/extract files. All in all, seems like a very solid option for parsing binary files.
[0] https://www.itu.int/en/ITU-T/asn1/Documents/ECN_Introduction...
[1] http://web1.see.asso.fr/erts2012/Site/0P2RUC89/7C-4.pdf
Edited to add the second link