From 9015cbee2111a21ef7a34e1d23b91c2b971132b2 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 28 Apr 2018 15:35:04 -0700 Subject: [PATCH] More experimentation --- schala-codegen/src/lib.rs | 51 +++++++++++++-------------------------- schala-lang/src/lib.rs | 2 +- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/schala-codegen/src/lib.rs b/schala-codegen/src/lib.rs index 943a06b..a64a29b 100644 --- a/schala-codegen/src/lib.rs +++ b/schala-codegen/src/lib.rs @@ -10,12 +10,22 @@ use syn::{Expr, Lit, ExprLit}; use syn::punctuated::Punctuated; use syn::synom::Synom; -fn tok() -> String { - "ONE THING FROM A MACRO|".to_string() -} -fn pars() -> String { - "ANOTHER MACRO THING|".to_string() +fn get_string_args(input: Expr) -> Vec { + let mut contained_strings = Vec::new(); + match input { + Expr::Array(array) => { + for item in array.elems { + if let Expr::Lit(ExprLit { lit: Lit::Str(s), ..}) = item { + contained_strings.push(s.value()); + } else { + panic!("Non-string-literal input to compiler_pass_sequence"); + } + } + }, + _ => panic!("Non-array input to compiler_pass_sequence"), + } + contained_strings } #[proc_macro] @@ -30,34 +40,9 @@ pub fn compiler_pass_sequence(input: TokenStream) -> TokenStream { } */ - - let mut contained_strings = Vec::new(); - let input: Expr = syn::parse(input).unwrap(); - match input { - Expr::Array(array) => { - for item in array.elems { - if let Expr::Lit(ExprLit { lit: Lit::Str(s), ..}) = item { - contained_strings.push(s.value()); - } else { - panic!("BAD INPUT"); - } - } - }, - _ => panic!("BAD INPUT"), - } - - - let mut from_macro = String::new(); - for item in contained_strings { - if item == "tok" { - from_macro.push_str(tok().as_ref()); - } - if item == "pars" { - from_macro.push_str(pars().as_ref()); - } - } - + let stages = get_string_args(input); + let from_macro = format!("{:?}", stages); let output = quote! { fn new_execute(&mut self, input: &str, _options: &EvalOptions) -> FinishedComputation { @@ -107,6 +92,4 @@ mod tests { Outcome::from(req, responder); } - - */ diff --git a/schala-lang/src/lib.rs b/schala-lang/src/lib.rs index 978ba00..1f6af72 100644 --- a/schala-lang/src/lib.rs +++ b/schala-lang/src/lib.rs @@ -43,7 +43,7 @@ impl Schala { impl ProgrammingLanguageInterface for Schala { - schala_codegen::compiler_pass_sequence!(["tok"]); + schala_codegen::compiler_pass_sequence!(["tokenize", "parse", "yolo"]); fn get_language_name(&self) -> String { "Schala".to_string()