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:
ChunkCursor::peek_line— look at the next physical line without consuming it,ChunkCursor::merge— extend the current chunk to include that line,ChunkCursor::next— finish the current chunk and produce a cursor for the next one.
§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§
- Chunk
Cursor - 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.