nibble

Types

pub type DeadEnd(ctx) {
  DeadEnd(
    row: Int,
    col: Int,
    problem: Error,
    context: List(Located(ctx)),
  )
}

Constructors

  • DeadEnd(
      row: Int,
      col: Int,
      problem: Error,
      context: List(Located(ctx)),
    )
pub type Error {
  BadParser(String)
  Custom(String)
  EndOfInput
  Expected(String, got: String)
  Unexpected(String)
}

Constructors

  • BadParser(String)
  • Custom(String)
  • EndOfInput
  • Expected(String, got: String)
  • Unexpected(String)
pub type Located(ctx) {
  Located(row: Int, col: Int, context: ctx)
}

Constructors

  • Located(row: Int, col: Int, context: ctx)
pub type Loop(a, state) {
  Continue(state)
  Break(a)
}

Constructors

  • Continue(state)
  • Break(a)
pub opaque type Parser(a, ctx)

Functions

pub fn any() -> Parser(String, a)
pub fn backtrackable(parser: Parser(a, b)) -> Parser(a, b)
pub fn commit(to a: a) -> Parser(a, b)
pub fn drop(parse_a: Parser(a, b), parse_x: Parser(c, b)) -> Parser(
  a,
  b,
)
pub fn eof() -> Parser(Nil, a)
pub fn fail(message: String) -> Parser(a, b)
pub fn float() -> Parser(Float, a)
pub fn grapheme(str: String) -> Parser(Nil, a)
pub fn in(parser: Parser(a, b), context: b) -> Parser(a, b)
pub fn inspect(parser: Parser(a, b), message: String) -> Parser(
  a,
  b,
)

Run the given parser and then inspect it’s state.

pub fn int() -> Parser(Int, a)
pub fn keep(parse_f: Parser(fn(a) -> b, c), parse_a: Parser(a, c)) -> Parser(
  b,
  c,
)
pub fn lazy(parser: fn() -> Parser(a, b)) -> Parser(a, b)
pub fn loop(init: a, step: fn(a) -> Parser(Loop(b, a), c)) -> Parser(
  b,
  c,
)
pub fn many(parser: Parser(a, b), separator: Parser(c, b)) -> Parser(
  List(a),
  b,
)
pub fn map(parser: Parser(a, b), f: fn(a) -> c) -> Parser(c, b)
pub fn one_of(parsers: List(Parser(a, b))) -> Parser(a, b)
pub fn replace(parser: Parser(a, b), with b: c) -> Parser(c, b)
pub fn run(src: String, parser: Parser(a, b)) -> Result(
  a,
  List(DeadEnd(b)),
)
pub fn spaces() -> Parser(Nil, a)
pub fn string(str: String) -> Parser(Nil, a)
pub fn succeed(a: a) -> Parser(a, b)
pub fn take_if(predicate: fn(String) -> Bool, expecting: String) -> Parser(
  String,
  a,
)
pub fn take_if_and_while(predicate: fn(String) -> Bool, expecting: String) -> Parser(
  String,
  a,
)
pub fn take_until(predicate: fn(String) -> Bool) -> Parser(
  String,
  a,
)
pub fn take_while(predicate: fn(String) -> Bool) -> Parser(
  String,
  a,
)
pub fn then(parser: Parser(a, b), f: fn(a) -> Parser(c, b)) -> Parser(
  c,
  b,
)
pub fn whitespace() -> Parser(Nil, a)
Search Document