#parser #combinator

nightly oni-comb-parser-rs

A Rust crate for parser combinators

4 releases

0.0.4 Nov 15, 2021
0.0.3 Nov 15, 2021
0.0.2 Nov 15, 2021
0.0.1 Nov 13, 2021

#138 in Parser tooling

21 downloads per month
Used in 3 crates

MIT/Apache

130KB
3.5K SLoC

oni-comb-parser-rs

Install to Cargo.toml

Add this to your Cargo.toml:

[dependencies]
oni-comb-parser-rs = "<<version>>"

Usage

use oni_comb_parser_rs::prelude::*;

fn main() {
  let input: &[u8; 14] = b"'hello world';";

  let parser: Parser<u8, &str> = surround(
    elm(b'\''),
    (seq(b"hello") + elm_space() + seq(b"world")).collect(),
    elm(b'\'') + elm(b';'),
  )
  .map_res(std::str::from_utf8);
  let result: &str = parser.parse(input).unwrap();

  println!("{}", result); // hello world
}

Influenced by the following parsers implementations.

Examples

Dependencies

~1–1.4MB
~40K SLoC

a