Closed ajusa closed 3 years ago
This could be implemented as a property which adds the passed node to the setter (_
refers to the element being assigned to the field).
createParser(pascalString):
u8: len
s {@hook: len = _.len}: str(len)
Implemented with v0.2.0.
From talking with sealmove on Discord. It would be nice to have a way to automatically bind/set an integer field based on the length of other fields. Many protocols send length and data together, so that the reader knows how many bytes to read before stopping/moving to the next field. For example with the PascalString example, I should only need to pass in the actual string itself, and have some way in the DSL to show that I want
len
to be the same length as thestr
I passed in.Ideally this would also be able to work with more complex examples.