Automate language name

This commit is contained in:
greg 2018-05-02 16:06:28 -07:00
parent c6f038a307
commit c0746028f4

View File

@ -20,7 +20,7 @@ pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream
let attrs = &ast.attrs; let attrs = &ast.attrs;
let language_name: Option<String> = attrs.iter().map(|attr| attr.interpret_meta()).find(|meta| { let extracted_lang_name: Option<String> = attrs.iter().map(|attr| attr.interpret_meta()).find(|meta| {
match meta { match meta {
&Some(syn::Meta::NameValue(syn::MetaNameValue { ident, .. })) if ident.as_ref() == "LanguageName" => true, &Some(syn::Meta::NameValue(syn::MetaNameValue { ident, .. })) if ident.as_ref() == "LanguageName" => true,
_ => false _ => false
@ -32,6 +32,8 @@ pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream
} }
}); });
let language_name = extracted_lang_name.unwrap();
println!("LANG NAME: {:?}", language_name); println!("LANG NAME: {:?}", language_name);
/* /*
@ -54,11 +56,11 @@ pub fn derive_programming_language_interface(input: TokenStream) -> TokenStream
let tokens = quote! { let tokens = quote! {
impl ProgrammingLanguageInterface for #name { impl ProgrammingLanguageInterface for #name {
fn get_language_name(&self) -> String { fn get_language_name(&self) -> String {
"Schala".to_string() #language_name.to_string()
} }
fn get_source_file_suffix(&self) -> String { fn get_source_file_suffix(&self) -> String {
format!("schala") #language_name.to_string()
} }
fn execute_pipeline(&mut self, input: &str, options: &EvalOptions) -> FinishedComputation { fn execute_pipeline(&mut self, input: &str, options: &EvalOptions) -> FinishedComputation {
let mut chain = pass_chain![self, options; let mut chain = pass_chain![self, options;