News for hackers. Stuff that matters.
Re:Kaitai Struct: A new way to develop parsers for binary st... by gabiruh on Thursday March 17, 2022 @08:19PM (#30717307)
I like Perl's Data::ParseBinary (https://metacpan.org/pod/Data::ParseBinary)

    my $s = Struct("foo",
        UBInt8("a"),
        UBInt16("b"),
        Struct("bar",
            UBInt8("a"),
            UBInt16("b"),
        )
    );
    my $data = $s->parse("ABBabb");
    # $data is { a => 65, b => 16962, bar => { a => 97, b => 25186 } }
Re:Kaitai Struct: A new way to develop parsers for binary st... by matheusmoreira on Thursday March 17, 2022 @08:35PM (#30717407)
How does it handle length-prefixed data?

  length u32
  data   u32[length]
This is a huge problem for traditional parsers since the input modifies the grammar dynamically.
Re:Kaitai Struct: A new way to develop parsers for binary st... by boardwaalk on Thursday March 17, 2022 @08:45PM (#30717466)
Re:Kaitai Struct: A new way to develop parsers for binary st... by matheusmoreira on Thursday March 17, 2022 @08:55PM (#30717533)
I see, you can pass in a function that computes the length. I wonder if a declarative or formal solution will ever exist.