package comby-kernel
Install
Dune Dependency
Authors
Maintainers
Sources
md5=ee6556d8bd9b25ed0445ebe23862e48a
sha512=e6386c8ce5ef14bbcab2b0ead5b1edc39375438f56330d5f02e81e467afe6623a7e299f97f26008d77bbc62850c6dc63a7cbe5b81671b5183ff3adeee5946bb3
doc/comby-kernel.vangstrom/Vangstrom/Unsafe/index.html
Module Vangstrom.Unsafe
Source
Unsafe Operations on Angstrom's Internal Buffer
These functions are considered unsafe as they expose the input buffer to client code without any protections against modification, or leaking references. They are exposed to support performance-sensitive parsers that want to avoid allocation at all costs. Client code should take care to write the input buffer callback functions such that they:
- do not modify the input buffer outside of the range
[off, off + len)
; - do not modify the input buffer inside of the range
[off, off + len)
if the parser might backtrack; and - do not return any direct or indirect references to the input buffer.
If the input buffer callback functions do not do any of these things, then the client may consider their use safe.
take n f
accepts exactly n
characters of input into the parser's internal buffer then calls f buffer ~off ~len
. buffer
is the parser's internal buffer. off
is the offset from the start of buffer
containing the requested content. len
is the length of the requested content. len
is guaranteed to be equal to n
.
take_while check f
accepts input into the parser's interal buffer as long as check
returns true
then calls f buffer ~off ~len
. buffer
is the parser's internal buffer. off
is the offset from the start of buffer
containing the requested content. len
is the length of the content matched by check
.
This parser does not fail. If check
returns false
on the first character, len
will be 0
.
take_while1 check f
accepts input into the parser's interal buffer as long as check
returns true
then calls f buffer ~off ~len
. buffer
is the parser's internal buffer. off
is the offset from the start of buffer
containing the requested content. len
is the length of the content matched by check
.
This parser requires that f
return true
for at least one character of input, and will fail otherwise.
take_till check f
accepts input into the parser's interal buffer as long as check
returns false
then calls f buffer ~off ~len
. buffer
is the parser's internal buffer. off
is the offset from the start of buffer
containing the requested content. len
is the length of the content matched by check
.
This parser does not fail. If check
returns true
on the first character, len
will be 0
.