Skip to content

add h_bytes combinator

Sven M. Hallberg requested to merge pesco/hammer:h_bytes into master

adds a combinator h_bytes(n), to consume n bytes of input and return (a copy of) them as a TT_BYTES. do we want it? packrat only for now.

the reason i wanted this was to replace the similar p_take(n,env) in the pdf parser. the latter uses a pointer to the input file from the environment and can't be used on decoded stream data. the latter would be needed to split object streams up into objects in the proper fashion.

NB: returns a copy of the data rather than a no-copy slice of the original input to be compatible with incremental parsing. after h_parse_chunk() returns, the input buffer could be freed/reused, invalidating any references into it.

comments welcome!

Edited by Sven M. Hallberg

Merge request reports