atto

Robust and extensible parser-combinators for Gleam.

fn number() {
  use digits <- do(atto.match("[1-9][0-9]*"))
  let assert Ok(n) = int.from_string(digits)
  n
}

fn number_list() {
  atto.between(
    atto.token("["),
    atto.sep(number, by: atto.token(",")),
    atto.token("]"),
  )
}

atto.run(number_list, text.new("[1,23,5]", Nil))
// -> Ok([1, 23, 5])

Features

Resources

Search Document