Interesting. I didn't know anyone had come up with a declarative language for binary files.
jchw•53m ago
There's actually more than one, though Kaitai probably has the most maturity of any of them.
Various hex editors have their own formats. 010 Editor has C-style binary templates, imhex has a binary pattern language as well. Okteta has Okteta Structure Definitions which can be declared using XML or with JS.
Kaitai Struct is the most complete system that has code generation for multiple programming languages and isn't tied to a hex editor or anything else for that matter. That said, I think there's still a ton of room for improvement and innovation. Kaitai has a lot of useful tooling, but I think as it is today it falls a bit short: the code gen is not at the same support level for all languages (most languages are fairly limited), and I think serialization is still mostly experimental. That and there's probably a lot you could do to still make it more expressive and powerful.
emddudley•11m ago
There's an old XML one called Data Format Description Language (DFDL).
pmarreck•27m ago
Is this able to represent any binary format? How do things like relative offsets work and such? (basically any non-rigid parts of the format)
frizlab•10m ago
It can represent an UTF-8 string, so it can probably represent anything.
dtagames•1h ago
jchw•53m ago
Various hex editors have their own formats. 010 Editor has C-style binary templates, imhex has a binary pattern language as well. Okteta has Okteta Structure Definitions which can be declared using XML or with JS.
Kaitai Struct is the most complete system that has code generation for multiple programming languages and isn't tied to a hex editor or anything else for that matter. That said, I think there's still a ton of room for improvement and innovation. Kaitai has a lot of useful tooling, but I think as it is today it falls a bit short: the code gen is not at the same support level for all languages (most languages are fairly limited), and I think serialization is still mostly experimental. That and there's probably a lot you could do to still make it more expressive and powerful.
emddudley•11m ago