7 releases

0.2.2 Mar 17, 2020
0.2.1 Mar 16, 2020
0.1.3 Mar 16, 2020

#192 in Parser tooling

MIT license

15KB
478 lines

kombi Foo

An Iterator-based Parser Combinator Library for Rust.

Included batteries:

  • Parser trait
    • Implementation for &str
    • Implementation for char
    • Implementation for <T, Iter: Iterator + Clone> Fn(Iter) -> Option<(Iter, T)>
  • () to ensure that there is nothing left to parse
  • Many for repeated occurrences
  • Maybe for optionals (e.g. ' '.maybe() to allow, but not require, a space)
  • NaturalNumber for whole numbers between 0 and u128::max_value()
  • Or for choosing between two Parsers
  • Then for chaining multiple Parsers together
  • Transform for transforming the output of a Parser into another value.
("true".or("True"))
.or("false".or("False"))
.transform(|x|match x {
    Either::A(_) => true,
    Either::B(_) => false,
})
.parse_str("false!")? == ("!", false)

No runtime deps