keichi / binary-parser

A blazing-fast declarative parser builder for binary data
MIT License
864 stars 134 forks source link

Index parsing context variable #169

Closed Rzial closed 3 years ago

Rzial commented 3 years ago

This PR adds an $index variable for array parsing. I've only implemented this for the length parsing option. Also, this PR refactors the way context variables are added to a named parser to make it more easy to extend if needed.

keichi commented 3 years ago

Looks good! Just curious what is your use case for this?

Rzial commented 3 years ago

I have a file that follows the following structure:

image

To be able to parse objects you need to get the entry on the header. That entry defines the object size and the preceding padding and the entries are ordered on the same way that objects are.

keichi commented 3 years ago

I see that makes sense. Thanks!

keichi commented 3 years ago

I will release a new version including your recent contributions.