keichi / binary-parser

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

Added parsing context variables #166

Closed Rzial closed 3 years ago

Rzial commented 3 years ago

Hi, I've made a local fork of this repo because I needed some features that are not currently available.

This PR adds a $parent and a $root variable while parsing each structure to be able to reference fields (or use them on callbacks). Context variables are available on .array(), .choice(), .nest() and .pointer() methods. This PR should close #10

You can find more documentation on the README.md

I've also corrected some methods signatures that are wrong

keichi commented 3 years ago

Thanks @Rzial! I will take a look.

keichi commented 3 years ago

The changes look good to me, but can you add tests for $parent and $root?

keichi commented 3 years ago

Looks good, thanks!