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, ..Default::default() };
let (regex, _warnings) = match Expr::parse_and_compile("'test'", 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, ..Default::default() };
let (compiled, _warnings) = Expr::parse_and_compile(input, 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.
Compilation warnings
Structs
A parsed pomsky expression, which might contain more sub-expressions.
An error than can occur only during parsing
A warning.