jayce is a tokenizer 🌌
```rust use jayce::{duos, Tokenizer}; use regex::Regex;
const SOURCE: &str = "Excalibur = 5000$; // Your custom lang";
lazystatic::lazystatic! ( static ref DUOS: Vec<(&'static str, Regex)> = duos![ "price", r"^[0-9]+\$", "semicolon", r"^;", "operator", r"^=", "name", 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) }
next
possible Result
Ok(Some(token))
Match is foundOk(None)
End of sourceErr(error)
An error occurstokenize_all
possible Result
Ok(Vec<Tokens>)
Tokens are foundErr(error)
An error occurswhitespaces, comments and block comments are skipped for performance reasons
initialization in 1.83 nanoseconds
tokenization of 19 979 tokens in 3.5 milliseconds
6.0.4
is ~421%
faster than version4.0.1
7.0.2
is ~5%
faster than version7.0.1