ere_macros/lib.rs
1use ere_core;
2use proc_macro::TokenStream;
3
4extern crate proc_macro;
5
6/// This is the primary entrypoint to the `ere` crate.
7/// Checks and compiles a regular expression into a [`Regex<N>`](`ere_core::Regex<N>`).
8///
9/// This compilation happens during build using proc macros,
10/// resulting in rust code equivalent to your regex.
11/// This code can then by further optimized by rustc when compiled directly into the binary.
12///
13/// The generic `const N: usize` will be the number of capture groups present in the regular expression
14/// (including capture group 0 which is the entire matched text).
15/// You will need to properly specify this in the generics for the regex (default if unspecified is 1).
16/// When using [`Regex<N>::exec`](`ere_core::Regex<N>::exec`), this is the length of the captures returned.
17///
18/// ```
19/// use ere_core::Regex; // usually `ere::Regex`
20/// use ere_macros::compile_regex; // usually `ere::compile_regex`
21///
22/// const MY_REGEX: Regex<2> = compile_regex!("a(b?)c");
23/// ```
24#[proc_macro]
25pub fn compile_regex(stream: TokenStream) -> TokenStream {
26 return ere_core::__compile_regex(stream);
27}