pomsky-macro

Crates.iopomsky-macro
lib.rspomsky-macro
version0.11.0
sourcesrc
created_at2022-07-04 18:39:34.322057
updated_at2023-11-09 09:35:29.912138
descriptionMacro for converting pomsky expressions to regexes
homepagehttps://github.com/pomsky-lang/pomsky/blob/main/pomsky-macro
repositoryhttps://github.com/pomsky-lang/pomsky
max_upload_size
id619121
size10,440
Ludwig Stecher (Aloso)

documentation

https://docs.rs/pomsky-macro

README

pomsky-macro

This Rust procedural macro allows converting a pomsky expression to a regex string literal at compile time:

use pomsky_macro::pomsky;

const REGEX: &str = pomsky!("foo" | "bar"+ greedy);

This string can then used with the regex crate:

let my_regex = regex::Regex::new(REGEX).unwrap();

Diagnostics

Errors from pomsky are shown at compile time and are highlighted in your IDE. You can improve the diagnostics by enabling the diagnostics feature, which requires Rust Nightly.

Regex flavor

If you want to use a regex flavor other than Rust, you can specify it after a hashtag:

const REGEX: &str = pomsky!(
    #flavor = Pcre
    >> "test" %
);

License

Dual-licensed under the MIT license or the Apache 2.0 license.

Commit count: 395

cargo fmt