420 releases

new 0.0.428 May 1, 2024
0.0.398 Mar 31, 2024
0.0.308 Dec 31, 2023
0.0.277 Nov 30, 2023
0.0.4 Nov 15, 2021

#29 in Parser tooling

Download history 135/week @ 2024-01-11 119/week @ 2024-01-18 67/week @ 2024-01-25 53/week @ 2024-02-01 63/week @ 2024-02-08 1940/week @ 2024-02-15 1415/week @ 2024-02-22 1276/week @ 2024-02-29 1383/week @ 2024-03-07 1865/week @ 2024-03-14 1060/week @ 2024-03-21 1259/week @ 2024-03-28 1159/week @ 2024-04-04 1096/week @ 2024-04-11 1235/week @ 2024-04-18 1195/week @ 2024-04-25

4,961 downloads per month
Used in 5 crates (4 directly)

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

~2.2–3MB
~55K SLoC