Kaitai project is happy to announce release of new major version of Kaitai Struct, declarative markup language to describe various binary data structures — binary file formats, network stream packets, etc.
The basic idea of Kaitai Struct is that a
particular format can be described using
Kaitai Struct language (in a .ksy
file), which then can be compiled
using ksc
into source files in
one of the supported programming
languages. These modules will include a
generated code for a parser that can read
described data structure from a file / stream
and provide access to its contents in a nice,
easy-to-comprehend API.
.dot
format)type
based on value of expression (instead of tons of if
s)doc
to annotate fields - will generate docstrings relevant to language (i.e. JavaDoc, JSDoc, YARD/RDoc, etc)repeat-until
allows repetition of a field until a condition is met_io.eof
returns boolean value - whether the end of stream was reached or not_io.pos
returns current position in the stream_io.size
returns size of the streamSEQ_FIELDS
helper const array that allows clear separation of sequence attributes vs instance without guessworklower_underscore_case
pattern (that would be converted to language-specific style on ouput)_parse
method renamed to _read
process*
methods are now staticposition
in runtime is renamed to pos
(to conform to general KS API spec)RuntimeConfig
for configuration instead of individual optionsif
on a sequence attribute now makes it automatically boxed (to allow it to be null
)int
vs long
incompatibilities%
) operation now behaves exactly the same in all languages, always returning positive result (as opposed to remainder operation %
in languages like C++ or Java)