Crates.io | oni-comb-parser-rs |
lib.rs | oni-comb-parser-rs |
version | 0.0.612 |
source | src |
created_at | 2021-11-13 01:07:37.849451 |
updated_at | 2024-11-11 00:25:51.365031 |
description | A Rust crate for parser combinators |
homepage | |
repository | https://github.com/j5ik2o/oni-comb-rs |
max_upload_size | |
id | 481233 |
size | 238,772 |
A Rust crate for LL(k) parser combinators.
Add this to your Cargo.toml
:
[dependencies]
oni-comb-parser-rs = "<<version>>"
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
}