Expand description
rulex
To learn about the rulex language, please read the book.
The rulex macro can be found here.
Usage
This library can parse a rulex expression and generate a regex string:
use rulex::Rulex;
use rulex::options::{CompileOptions, RegexFlavor};
let options = CompileOptions { flavor: RegexFlavor::Java };
let regex: String = match Rulex::parse_and_compile("'test'", Default::default(), options) {
Ok(regex) => regex,
Err(_) => {
eprintln!("The input is not a valid rulex");
return;
}
};
You can get fancy error messages with miette
by enabling the diagnostics
feature:
use rulex::Rulex;
use rulex::options::{CompileOptions, RegexFlavor};
use rulex::error::Diagnostic;
pub fn compile(input: &str) -> miette::Result<String> {
let options = CompileOptions { flavor: RegexFlavor::Java };
let compiled: String = Rulex::parse_and_compile(input, Default::default(), options)
.map_err(|e| e.diagnostic(input))?;
Ok(compiled)
}
Modules
Structs
A parsed rulex expression, which might contain more sub-expressions.