//Following is the macro expansion of: #[pax_primitive("./pax-std-primitives", crate::{{pascal_identifier}}Instance)]
{{original_tokens}}
#[cfg(feature = "parser")]
impl {{pascal_identifier}} {
    pub fn parse_to_manifest(mut ctx: ManifestContext) -> (ManifestContext, String) {
        let source_id = "primitive::{{pascal_identifier}}";
        match ctx.visited_source_ids.get(&source_id as &str) {
            None => {
                //First time visiting this file/source — parse the relevant contents
                //then recurse through child nodes, unrolled here in the macro as
                //parsed from the template
                ctx.visited_source_ids.insert(source_id.to_string());
                let PASCAL_IDENTIFIER = "{{pascal_identifier}}";
                ctx.template_map.insert(PASCAL_IDENTIFIER.to_string(), source_id.to_string());
                let template_map= ctx.template_map.clone();

                let mut property_definitions = vec![];

                // Populate `PropertyDefinition`s
                {% for ctpd in compile_time_property_definitions %}
                    //Here we bridge from pure static analysis into some dynamic analysis via `parser`, in order
                    //to fully qualify module paths for scoped atomic types.

                    //For each compile-time property definition, populate a full (parse-time) PropertyDefinition:
                    //1. name | from template args
                    //2. (full original type: punt) | from template args (via macro)
                    //3. unique, fully qualified dependencies (HashSet, perhaps) | AT PARSE-TIME: from imperative calls to `get_fully_qualified_path`
                    //4. (default value?  punt)


                    let mut fully_qualified_dependencies = vec![];
                    let mut dep_to_fqd_map = std::collections::HashMap::new();
                    {% for scoped_resolvable_type in ctpd.scoped_resolvable_types %}
                        let fqd = {{scoped_resolvable_type}}::get_fully_qualified_path("{{scoped_resolvable_type}}");
                        dep_to_fqd_map.insert("{{scoped_resolvable_type}}",fqd.clone());

                        fully_qualified_dependencies.push(
                            fqd
                        );
                    {% endfor %}


                    let mut fully_qualified_type = "{{ctpd.original_type}}".to_string();
                    //break original_type into tokens; map each token through dep_to_fqd
                    vec!["<", ">", "(", ")", ","].iter().for_each(|delim| {
                        //split by delim; pass each part through dep_to_fqd map; re-splice with same delims
                        fully_qualified_type = fully_qualified_type.split(delim).map(|part|{
                            if let Some(more_qualified) = dep_to_fqd_map.get(&part) {
                                more_qualified
                            } else {
                                //if we can't further-qualify this segment, return the original segment
                                part
                            }
                        }).collect::<Vec<_>>().join(delim);
                    });

                    property_definitions.push(pax_compiler_api::PropertyDefinition {
                        name: "{{ctpd.field_name}}".to_string(),
                        original_type: "{{ctpd.original_type}}".to_string(),
                        fully_qualified_dependencies,
                        fully_qualified_type,
                    });
                {% endfor %}
                ctx.all_property_definitions.insert(source_id.to_string(), property_definitions.clone());

                let comp_def = pax_compiler_api::get_primitive_definition(PASCAL_IDENTIFIER, module_path!(), &source_id, &property_definitions);
                ctx.component_definitions
                    .push(comp_def);
                (ctx, source_id.to_string())
            },
            _ => (ctx, source_id.to_string()), //early return; this file has already been parsed
        }
    }
}