19 lines
543 B
Rust
19 lines
543 B
Rust
use crate::spec::leaf_struct_spec::LeafStructBuildSpec;
|
|
use proc_macro2::TokenStream;
|
|
use quote::{format_ident, quote};
|
|
|
|
pub fn make_leaf_struct_ast_node_impl(spec: &LeafStructBuildSpec) -> TokenStream {
|
|
let type_ident = format_ident!("{}", spec.build());
|
|
quote! {
|
|
impl AstNode for #type_ident {
|
|
fn children(&self) -> Vec<AstNodeRef> {
|
|
vec![]
|
|
}
|
|
|
|
fn as_node_ref(&self) -> AstNodeRef {
|
|
AstNodeRef::#type_ident(&self)
|
|
}
|
|
}
|
|
}
|
|
}
|