oak_runtime

Module stream

Source
Expand description

Collection of traits for retrieving and manipulating a stream. They are used by implementation of parsing expressions.

A stream produces a sequence of items (characters, bytes, etc.) while retaining information on the underlying data traversed. For example, a couple (File, Iterator<char>) could represent a stream of characters from a file.

Traitsยง

  • Produces a code snippet of size len_hint or less starting from the current position in the stream.
  • Consumes prefix if it fully matches from the current position in the stream. If it does not match, the stream is not altered and false is returned.
  • Returns true if an item can be read from the stream with Iterator::next.
  • Produces a textual representation of the current position in the stream. For example, it can be 2:5 if the position is at line 2 and column 5.
  • Transforms a value into a stream of type Output.