More experimentation
This commit is contained in:
parent
bf7533cdbe
commit
9015cbee21
@ -10,12 +10,22 @@ use syn::{Expr, Lit, ExprLit};
|
|||||||
use syn::punctuated::Punctuated;
|
use syn::punctuated::Punctuated;
|
||||||
use syn::synom::Synom;
|
use syn::synom::Synom;
|
||||||
|
|
||||||
fn tok() -> String {
|
|
||||||
"ONE THING FROM A MACRO|".to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn pars() -> String {
|
fn get_string_args(input: Expr) -> Vec<String> {
|
||||||
"ANOTHER MACRO THING|".to_string()
|
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]
|
#[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();
|
let input: Expr = syn::parse(input).unwrap();
|
||||||
match input {
|
let stages = get_string_args(input);
|
||||||
Expr::Array(array) => {
|
let from_macro = format!("{:?}", stages);
|
||||||
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 output = quote! {
|
let output = quote! {
|
||||||
fn new_execute(&mut self, input: &str, _options: &EvalOptions) -> FinishedComputation {
|
fn new_execute(&mut self, input: &str, _options: &EvalOptions) -> FinishedComputation {
|
||||||
@ -107,6 +92,4 @@ mod tests {
|
|||||||
Outcome::from(req, responder);
|
Outcome::from(req, responder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@ -43,7 +43,7 @@ impl Schala {
|
|||||||
|
|
||||||
impl ProgrammingLanguageInterface for 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 {
|
fn get_language_name(&self) -> String {
|
||||||
"Schala".to_string()
|
"Schala".to_string()
|
||||||
|
Loading…
Reference in New Issue
Block a user