#parser #combinator

oni-comb-parser-rs

A Rust crate for parser combinators

114 releases

new 0.0.121 Jun 9, 2023
0.0.112 May 31, 2023
0.0.51 Mar 31, 2023
0.0.19 Nov 17, 2022
0.0.4 Nov 15, 2021

#50 in Parser tooling

Download history 53/week @ 2023-02-17 81/week @ 2023-02-24 182/week @ 2023-03-03 171/week @ 2023-03-10 195/week @ 2023-03-17 232/week @ 2023-03-24 235/week @ 2023-03-31 319/week @ 2023-04-07 291/week @ 2023-04-14 260/week @ 2023-04-21 218/week @ 2023-04-28 403/week @ 2023-05-05 219/week @ 2023-05-12 271/week @ 2023-05-19 358/week @ 2023-05-26 344/week @ 2023-06-02

1,223 downloads per month
Used in 3 crates

MIT/Apache

160KB
3.5K SLoC

oni-comb-parser-rs

A Rust crate for LL(k) parser combinators.

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

Alternative parsers

Dependencies

~1–1.5MB
~40K SLoC