pest_generator/
macros.rs
1macro_rules! insert_builtin {
11 ($builtin: expr, $name: ident, $pattern: expr) => {
12 $builtin.push((stringify!($name), generate_rule!($name, $pattern)));
13 };
14}
15
16#[cfg(feature = "std")]
17macro_rules! generate_rule {
18 ($name: ident, $pattern: expr) => {
19 quote! {
20 #[inline]
21 #[allow(dead_code, non_snake_case, unused_variables)]
22 pub fn $name(state: ::std::boxed::Box<::pest::ParserState<'_, Rule>>) -> ::pest::ParseResult<::std::boxed::Box<::pest::ParserState<'_, Rule>>> {
23 $pattern
24 }
25 }
26 }
27}
28
29#[cfg(not(feature = "std"))]
30macro_rules! generate_rule {
31 ($name: ident, $pattern: expr) => {
32 quote! {
33 #[inline]
34 #[allow(dead_code, non_snake_case, unused_variables)]
35 pub fn $name(state: ::alloc::boxed::Box<::pest::ParserState<'_, Rule>>) -> ::pest::ParseResult<::alloc::boxed::Box<::pest::ParserState<'_, Rule>>> {
36 $pattern
37 }
38 }
39 }
40}