toon_codec/decode/scanner
Line scanner and cursor for TOON decoding.
This module provides functions to scan input text into parsed lines with depth information, and a cursor type for traversing those lines. Scan input into a list of parsed lines with depth information.
Each line is analyzed for indentation, depth is calculated, and blank lines are tracked.
Arguments
input- The TOON format string to scanindent_size- Number of spaces per indentation levelstrict- Whether to enforce strict indentation rules Parse a single line to extract depth and content. Count leading spaces in a string. Calculate indentation depth from leading spaces. Opaque type for traversing parsed lines. Create a new cursor from parsed lines. Peek at the current line without advancing. Advance the cursor to the next line. Check if the cursor is at the end (no more lines). Get the current position of the cursor. Get the total number of lines. Peek ahead at a line N positions from current. Get all remaining lines from the current position.
Types
pub opaque type LineCursor
Values
pub fn cursor_advance(cursor: LineCursor) -> LineCursor
pub fn cursor_at_end(cursor: LineCursor) -> Bool
pub fn cursor_length(cursor: LineCursor) -> Int
pub fn cursor_new(lines: List(types.ParsedLine)) -> LineCursor
pub fn cursor_peek(
cursor: LineCursor,
) -> option.Option(types.ParsedLine)
pub fn cursor_peek_ahead(
cursor: LineCursor,
offset: Int,
) -> option.Option(types.ParsedLine)
pub fn cursor_position(cursor: LineCursor) -> Int
pub fn cursor_remaining_lines(
cursor: LineCursor,
) -> List(types.ParsedLine)
pub fn scan_lines(
input: String,
indent_size: Int,
strict: Bool,
) -> Result(List(types.ParsedLine), error.ToonError)