internal/parser

Types

pub type Current {
  Current(line: String, pos: String, indent: Int)
}

Constructors

  • Current(line: String, pos: String, indent: Int)
pub type ParseState {
  ParseState(
    line_splitter: splitter.Splitter,
    start: String,
    current: Current,
    prev_line: String,
    rest: String,
  )
}

Constructors

Values

pub fn advance_line(state: ParseState) -> ParseState
pub fn at_eof(state: ParseState) -> Bool
pub fn drop_3_spaces(state: ParseState) -> ParseState

Moves to the first non-indent character on the current line (no more than count indent stops, expanding tabs as we go)

pub fn merge_until_unescaped_end_bracket(
  state: ParseState,
  cont: fn(ParseState) -> a,
) -> a

This is an ugly hack until I’ve rewritten the parser to be more flexible. This scans forward from the current position across lines until we find a ], skipping any ] and any maching pair of [ and ], joining lines together

pub fn new_state(start: String) -> ParseState
pub fn next_line_if_blank(
  state: ParseState,
  cont: fn(ParseState) -> a,
) -> a
pub fn next_line_is_blank(state: ParseState) -> Bool
pub fn next_nonspace(
  state: ParseState,
  cont: fn(ParseState) -> a,
) -> a
pub fn try_drop(
  state: ParseState,
  ch: String,
  cont: fn(ParseState) -> a,
) -> a
pub fn try_pop(
  state: ParseState,
  ch: String,
  orelse: fn() -> a,
  cont: fn(ParseState) -> a,
) -> a
pub fn update_pos(state: ParseState, pos: String) -> ParseState
Search Document