module

Mica::Core::ByteInput

Buffered input for a format's scanner, included into the scanner class so the hot loops read the buffer through instance variables with no extra indirection.

The input is either a Bytes read in place or a stream (IO, possibly a Transcoder) read into one growable buffer. The scanner keeps everything from @mark (the start of the current token) and from @pin (when set) in the buffer; fill compacts the bytes before them and doubles the buffer only when one token needs it, up to the token limit. Offsets held across a fill must therefore be relative to @mark.

Positions: @base_offset + @pos is the offset of the current byte in the bytes the scanner sees; source_offset_at maps it to an offset in the original input (here: plus any skipped prefix such as a byte order mark; TextInput adds transcoded input).

This module is byte-oriented and knows nothing about characters, so binary formats (CBOR) include it alone. Text formats include TextInput (which includes this module) and LineTracking. The including type implements the hooks below.

Constants

INITIAL_BUFFER_SIZE = 64 * 1024

Initial size of the stream buffer.

TOKEN_SLACK = 64 * 1024

Bytes beyond the token limit the buffer may hold for markup around a token (delimiters, names, quotes).