hitori crate hitori documentation

Hitori is a generic regular expressions library. It works by creating series of if-statements for each expression at compile-time. Capturing is done through the traits.

Example

```rust struct Let { max: u32, }

[hitori::implexpr(andexpr_mut)]

[hitori::anddefine(capturemut, capture_ranges)]

impl, Idx: Clone> Expr for Let { const PATTERN: _ = ( |ch| ch == 'l', |ch| ch == 'e', |ch| ch == 't', char::iswhitespace, #[hitori::capture(var)] (char::isalphabetic), char::iswhitespace, |ch| ch == '=', char::iswhitespace, #[hitori::capture(val)] ( |ch: char| ch.todigit(10).map(|d| d < self.max).unwrapordefault(), |ch| ch == '.' || ch == ',', |ch: char| ch.isdigit(10), ), |ch| ch == ';' ); }

let text = "... let x = 5.1; ...";

let mut capture = LetCaptureRanges::default(); let found = hitori::string::find(Let { max: 6 }, &mut capture, text) .unwrap() .unwrap(); asserteq!(&text[found], "let x = 5.1;"); asserteq!(&text[capture.var.unwrap()], "x"); assert_eq!(&text[capture.val.unwrap()], "5.1");

let notfound = hitori::string::findnocapture(Let { max: 4 }, text); asserteq!(not_found, None); ```

See more code samples along with the traits, impls and struct they expand to in examples.

Crate features

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.