Skip to main content

Module chunks

Module chunks 

Source
Expand description

Physical-line / chunk management for the structural parser.

This layer sits below the grammar and the relation tree. Its only job is to walk the input one physical line at a time and group adjacent lines into a chunk: a single contiguous slice of the original input that may span several physical lines. A chunk is later handed to the grammar as one unit.

The layer is deliberately ignorant of syntax. It does not know what a continuation line (- ...) is, how indentation maps to depth, or that blank lines should be skipped. All of that is policy, owned by the caller. This layer only provides the mechanism:

§The cursor is the chunk

The cursor itself represents the current chunk: it tracks how much of the input the chunk has grown to cover and what remains after it. A chunk starts empty, so the first physical line is added through the same peek_line / merge path as every continuation line — there is no special case for the first line.

Because the only line you can merge is the one peek_line just returned, a chunk is always a span of contiguously consumed lines. That invariant is what keeps a chunk a single &str slice instead of a list of fragments.

Structs§

ChunkCursor
A forward cursor over the input that yields one chunk at a time.
Line
A single physical line peeked from a ChunkCursor, together with the offset needed to consume it.