adze-macro 0.8.0

Procedural macros for Rust Sitter
Documentation
---
source: macro/src/lib.rs
expression: "rustfmt_code(&expand_grammar(parse_quote!\n{\n    #[adze::grammar(\"test\")] mod grammar\n    {\n        #[adze::language] pub struct Identifier\n        { #[adze::leaf(pattern = r\"[a-zA-Z_]\\w*\")] name: String, }\n    }\n})? .to_token_stream().to_string())"
---
mod grammar {
    pub struct Identifier {
        name: String,
    }
    impl ::adze::Extract<Identifier> for Identifier {
        type LeafFn = ();
        const GRAMMAR_NAME: &'static str = "test";
        #[allow(non_snake_case)]
        fn extract(
            node: Option<&::adze::pure_parser::ParsedNode>,
            source: &[u8],
            last_idx: usize,
            _leaf_fn: Option<&Self::LeafFn>,
        ) -> Self {
            let node = node.expect("Extract called with None node for struct");
            ::adze::__private::extract_struct_or_variant(node, move |cursor, last_idx| Identifier {
                name: {
                    ::adze::__private::extract_field::<String, _>(
                        cursor, source, last_idx, "name", None,
                    )
                },
            })
        }
    }
    include!(concat!(
        env!("OUT_DIR"),
        "/grammar_",
        "test",
        "/parser_",
        "test",
        ".rs"
    ));
    pub fn language() -> &'static ::adze::pure_parser::TSLanguage {
        &LANGUAGE
    }
    pub const LANGUAGE_REF: &'static ::adze::pure_parser::TSLanguage = &LANGUAGE;
    #[doc = r" Parse an input string according to the grammar. Returns either any parsing errors that happened, or a"]
    #[doc = "[`Identifier`]"]
    #[doc = r" instance containing the parsed structured data."]
    pub fn parse(input: &str) -> core::result::Result<Identifier, Vec<::adze::errors::ParseError>> {
        ::adze::__private::parse::<Identifier>(input, || language())
    }
}