AndrasKovacs / flatparse

Fast parsing from bytestrings
MIT License
146 stars 12 forks source link

add skip, anyCString, address prims #23

Closed raehik closed 2 years ago

raehik commented 2 years ago

More binary primitives.

The Addr#-related primitives enable parsing structures like offset tables efficiently. We can "save" an Addr# via the withAddr# continuation, then use it in a lookahead together with an offset read from the input to jump around and parse arbitrary data elsewhere in the input. Some old code might explain better (function names are different): https://github.com/raehik/binrep/blob/180cd12c8fd773b0a99e5bb509432a2d0d11fae7/src/Binrep/Example/FileTable.hs#L81

TODO

raehik commented 2 years ago

snip, placed above

raehik commented 2 years ago

This will be a while while I fumble more primop compatibility helpers in.

raehik commented 2 years ago

This is ready - I'll write a few tests before merging, at least for C-strings and skips. The address stuff is harder to test and a lot less user-facing.

raehik commented 2 years ago

Fairly high confidence from the tests and these are very useful parsing primitives (I have been using them successfully via a fork). Merging!