walkzzz/astrolabe/core does not have a README file

    ParseError

    pub(all) struct ParseError {
    pos : Pos
    expected : Array[String]
    committed : Bool
    context : String
    } derive(Eq,
    Debug
    )

    • committed = true — backtracking is suppressed in alt

    ParseError::at

    fn ParseError::at(pos~ : Pos, expected~ : String) -> ParseError

    Convenience factory for the common case: single expected token, no context, uncommitted.

    ParseError::commit

    fn ParseError::commit(self : ParseError) -> ParseError

    Return a copy with committed = true, used for sequence-commit semantics.

    ParseError::equal

    fn ParseError::equal(ParseError, ParseError) -> Bool

    ParseError::format

    fn ParseError::format(self : ParseError) -> String

    The context line is omitted when empty.

    ParseError::format_with_input

    fn ParseError::format_with_input(self : ParseError, input : String) -> String

    up to 20 characters before and after the error position.

    ParseError::not_equal

    fn ParseError::not_equal(x : ParseError, y : ParseError) -> Bool

    ParseResult

    pub(all) enum ParseResult[T] {
    Success(T, State)
    Failure(ParseError)
    }

    • Failure(error) — failed; error carries position and commitment for alt

    Parser

    pub(all) struct Parser[T] {
    run : (State) -> ParseResult[T]
    }

    into larger parsers without exposing the internal State machinery.

    Parser::of

    fn[T] Parser::of(f : (State) -> ParseResult[T]) -> Parser[T]

    Wrap a raw function into a Parser[T] — the universal extension point.

    Parser::parse

    fn[T] Parser::parse(self : Parser[T], input : String) -> Result[T, ParseError]

    Use parse_full when you need to ensure the entire input is consumed.

    Parser::parse_full

    fn[T] Parser::parse_full(self : Parser[T], input : String) -> Result[T, ParseError]

    If the parser succeeds without reaching EOF, returns an Err.

    Pos

    pub(all) struct Pos {
    line : Int
    column : Int
    offset : Int
    } derive(Eq,
    Debug
    )

    • offset — 0 起始的字节偏移

    Pos::advance

    fn Pos::advance(self : Pos, ch : Char) -> Pos

    Returns a new Pos; the original is not mutated.

    Pos::equal

    fn Pos::equal(Pos, Pos) -> Bool

    Pos::initial

    fn Pos::initial() -> Pos

    Create the initial position (line 1, column 1, offset 0).

    Pos::not_equal

    fn Pos::not_equal(x : Pos, y : Pos) -> Bool

    Pos::to_repr

    State

    pub(all) struct State {
    input : String
    offset : Int
    pos : Pos
    } derive(
    Debug
    )

    • pos — 当前可读位置(行、列、偏移)

    State::advance_by

    fn State::advance_by(self : State, n : Int) -> Unit

    Caller must ensure n <= remaining().

    State::advance_one

    fn State::advance_one(self : State) -> Unit

    No-op when already at EOF.

    State::is_eof

    fn State::is_eof(self : State) -> Bool

    True when the cursor has reached or passed the end of input.

    State::new

    fn State::new(input : String) -> State

    Create a fresh State positioned at the start of input.

    State::peek

    fn State::peek(self : State) -> Char?

    Returns Some(ch) if not at EOF, None otherwise.

    State::remaining

    fn State::remaining(self : State) -> Int

    Number of characters remaining from the current offset to end-of-input.

    State::slice

    fn State::slice(self : State, start : Int, end : Int) -> String

    Does not modify the cursor. Used internally to read matched input.

    State::to_repr

    Source Files