walkzzz/astrolabe/core does not have a README file

    ParseError

    pub(all) suberror ParseError {
    ParseError(Pos, Array[String], Bool, Array[String])
    } derive(Eq,
    Debug
    )

    • committed = true — backtracking is suppressed in alt
    impl Show for ParseError

    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::committed

    fn ParseError::committed(self : ParseError) -> Bool

    Return the commitment status.

    ParseError::context

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

    Return the context label (joined with " > ").

    ParseError::contexts

    fn ParseError::contexts(self : ParseError) -> Array[String]

    Return the context chain.

    ParseError::equal

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

    ParseError::expected

    fn ParseError::expected(self : ParseError) -> Array[String]

    Return the list of expected tokens.

    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::merge

    fn ParseError::merge(self : ParseError, other : ParseError) -> ParseError
    OR the committed flags, and keep the first error's context chain

    ParseError::not_equal

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

    ParseError::output

    fn ParseError::output(self : ParseError, logger : &Logger) -> Unit
    Add the derived to_string from Show.

    ParseError::pos

    fn ParseError::pos(self : ParseError) -> Pos

    Return the position where the error occurred.

    ParseError::to_string

    fn ParseError::to_string(self : ParseError) -> String
    Add the derived to_string from Show.

    ParseError::with_context

    fn ParseError::with_context(self : ParseError, ctx : String) -> ParseError

    Return a copy with ctx appended to the context chain.

    ParseHint

    pub extenum ParseHint {
    }

    Users can add custom variants via extenum ParseHint += { ... }.

    ParseHint::heavy

    fn ParseHint::heavy() -> ParseHint

    Convenience factory: Heavy hint.

    ParseHint::light

    fn ParseHint::light() -> ParseHint

    Convenience factory: Light hint.

    ParseHint::recovery

    fn ParseHint::recovery() -> ParseHint

    Convenience factory: Recovery hint.

    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.

    Parser::parse_full_raise

    fn[T] Parser::parse_full_raise(self : Parser[T], input : String) -> T raise ParseError

    Like parse_full, but converts Err to raise for use in try...catch.

    Parser::parse_raise

    fn[T] Parser::parse_raise(self : Parser[T], input : String) -> T raise ParseError

    Like parse, but converts Err to raise for use in try...catch.

    Parser::run_fn

    fn[T] Parser::run_fn(self : Parser[T]) -> ((State) -> ParseResult[T])
    ParserLike extension point.

    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

    palt

    fn[A] palt(run1 : (State) -> ParseResult[A], run2 : (State) -> ParseResult[A]) -> Parser[A]
    both branches fail (same semantics as alt).

    pbind

    fn[A, B] pbind(run : (State) -> ParseResult[A], f : (A) -> Parser[B]) -> Parser[B]
    committed.

    pmap

    fn[A, B] pmap(run : (State) -> ParseResult[A], f : (A) -> B) -> Parser[B]
    extension. Returns a concrete Parser[B]; failure semantics match map.

    poption

    fn[A] poption(run : (State) -> ParseResult[A], default : A) -> Parser[A]
    option).