Module Stream.Leftmost_longest

Non-overlapping leftmost-longest matches — the find_leftmost_longest selection, streamed.

This selection needs lookahead: a match may only be reported once no longer match starting at or before it can still arrive. Because no match exceeds the longest pattern, that lookahead is bounded: a match is reported by the first Leftmost_longest.feed whose input reaches one longest-pattern length past the match's start, and the state buffers at most that window of candidates. Call Leftmost_longest.flush at end of input for the rest.

The state retains at most one candidate per start in that window, but no input bytes. feed does not materialise or sort all overlapping matches.

type state
val start : t -> state
val feed : t -> state -> string -> state * match_ list

The matches selected so far, in order, with absolute offsets.

val flush : state -> match_ list

The remaining matches at end of input. The stream is finished: do not feed the state again.

val pos : state -> int

Total bytes fed so far.