jayce is a tokenizer 🌌
```rust use jayce::{regexify, Tokenizer}; use regex::Regex;
const SOURCE: &str = "Excalibur = 5000$; // Your custom lang";
lazystatic::lazystatic! ( static ref DUOS: Vec<(&'static str, Regex)> = vec![ ("price", regexify!(r"^[0-9]+\$")), ("semicolon", regexify!(r"^;")), ("operator", regexify!(r"^=")), ("name", regexify!(r"^[a-zA-Z_]+")), ]; );
fn main() -> Result<(), Box
while let Some(token) = tokenizer.next()? {
println!("{:?}", token);
}
Ok(())
} ```
rust,ignore
Token { kind: "name", value: "Excalibur", pos: (1, 1) }
Token { kind: "operator", value: "=", pos: (1, 11) }
Token { kind: "price", value: "5000$", pos: (1, 13) }
Token { kind: "semicolon", value: ";", pos: (1, 18) }
functions available are next
and tokenize_all
the Result
has 3 variants
Ok(Some(token))
If a match is foundOk(None)
Reaching the source endsErr(error)
When nothing matcheswhitespaces, comments and block comments are skipped for performance reasons
initialization in 1.83 nanoseconds
tokenization of 19 979 tokens in 3.69 milliseconds
version 6.0.4 is
420.65%
faster than version 4.0.1