Expand description
Pomsky
To learn about the pomsky language, please read the book.
The pomsky macro can be found here.
Usage
This library can parse a pomsky expression and generate a regex string:
use pomsky::Expr;
use pomsky::options::{CompileOptions, RegexFlavor};
let options = CompileOptions { flavor: RegexFlavor::Java };
let (regex, _warnings) = match Expr::parse_and_compile("'test'", Default::default(), options) {
Ok(regex) => regex,
Err(_) => {
eprintln!("The input is not a valid pomsky expression");
return;
}
};You can get fancy error messages with miette
by enabling the diagnostics feature:
use pomsky::Expr;
use pomsky::options::{CompileOptions, RegexFlavor};
use pomsky::error::Diagnostic;
pub fn compile(input: &str) -> miette::Result<String> {
let options = CompileOptions { flavor: RegexFlavor::Java };
let (compiled, _warnings) = Expr::parse_and_compile(input, Default::default(), options)
.map_err(|e| e.diagnostic(input))?;
Ok(compiled)
}Modules
Contains different kinds of errors emitted by Pomsky.
Contains pomsky features that can be individually enabled and disabled.
Contains parser and compiler options passed to pomsky.
Provides warnings that are shown to the user (in addition to the output)
Structs
A parsed pomsky expression, which might contain more sub-expressions.