Make node production build fn.
This commit is contained in:
parent
de021789c1
commit
8aa4248e07
@ -1,8 +1,9 @@
|
||||
pub mod enum_build_fn;
|
||||
pub mod leaf_enum_build_fn;
|
||||
pub mod leaf_struct_build_fn;
|
||||
mod node_production_build_fn;
|
||||
pub mod polymorphic_build_build_fn;
|
||||
pub mod polymorphic_build_fn;
|
||||
pub mod polymorphic_enum_build_fn;
|
||||
pub mod production_build_fn;
|
||||
pub mod struct_build_fn;
|
||||
pub mod tree_enum_build_fn;
|
||||
|
||||
18
ast-generator/src/build_fn/node_production_build_fn.rs
Normal file
18
ast-generator/src/build_fn/node_production_build_fn.rs
Normal file
@ -0,0 +1,18 @@
|
||||
use crate::deserialize::util::make_build_pair;
|
||||
use crate::spec::node_production_spec::NodeProductionBuildSpec;
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::{format_ident, quote};
|
||||
|
||||
pub fn make_node_production_build_fn(spec: &NodeProductionBuildSpec) -> TokenStream {
|
||||
let build_fn_ident = format_ident!("{}", spec.with());
|
||||
let pair_ident = format_ident!("{}", make_build_pair(spec.name()));
|
||||
let return_type_ident = format_ident!("{}", spec.kind());
|
||||
let inner_build_fn_ident = format_ident!("{}", spec.with());
|
||||
|
||||
quote! {
|
||||
fn #build_fn_ident(#pair_ident: Pair<Rule>) -> #return_type_ident {
|
||||
let inner_pair = #pair_ident.into_inner().next().unwrap();
|
||||
#inner_build_fn_ident(inner_pair)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user