justlex-rs
Configurable lexer with no dependencies in Rust.
The entire implementation lives in a single .rs file. This means that
you can copy-paste it in your project and modify it as you like,
keeping your dependency tree clean. You can easily add custom
Punctuation or Keywords by modifying the file directly.
Check out the examples in the examples directory.
- Author: Giovanni Santini
- Mail: giovanni.santini@proton.me
- License: MIT
Example
// Some input string
let example_input = Stringfrom;
// Setup the lexer
let mut lexer = default;
lexer.set_input;
// Iterate over the tokens
for token in lexer
Will output:
Received token Punct(Hash)
Received token Symbol("include")
Received token Punct(Less)
Received token Symbol("stdio")
Received token Punct(Dot)
Received token Symbol("h")
Received token Punct(Greater)
...
Usage
Run an example:
cargo run --example basic_usage
Run the tests:
cargo test
Run lint:
cargo clippy