From 81368179bbcc3f23baf1d7feb726751bc8f1825e Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 9 May 2018 03:38:02 -0700 Subject: [PATCH] More boilerplate --- schala-lang/src/eval.rs | 24 ++++++++++++++++++++++-- schala-lang/src/lib.rs | 6 +++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/schala-lang/src/eval.rs b/schala-lang/src/eval.rs index b74797b..47818ef 100644 --- a/schala-lang/src/eval.rs +++ b/schala-lang/src/eval.rs @@ -320,7 +320,27 @@ impl<'a> State<'a> { /* BELOW HERE NEW STUFF */ impl<'a> State<'a> { - pub fn evaluate_new(&mut self, input: ReducedAST) -> Result { - Ok("not done".to_string()) + pub fn evaluate_new(&mut self, ast: ReducedAST) -> Vec> { + use ast_reducing::*; + + let mut acc = vec![]; + for statement in ast.0 { + match self.eval_statement_new(statement) { + Ok(output) => { + if let Some(fully_evaluated) = output { + acc.push(Ok(fully_evaluated/*.to_string()*/)); + } + }, + Err(error) => { + acc.push(Err(format!("Eval error: {}", error))); + return acc; + }, + } + } + acc + } + + fn eval_statement_new(&mut self, stmt: ::ast_reducing::Stmt) -> Result, String> { + Ok(Some(format!("stmt - {:?}", stmt))) } } diff --git a/schala-lang/src/lib.rs b/schala-lang/src/lib.rs index be25ded..c67e47d 100644 --- a/schala-lang/src/lib.rs +++ b/schala-lang/src/lib.rs @@ -102,7 +102,11 @@ fn ast_reducing(handle: &mut Schala, input: parsing::AST, comp: Option<&mut Unfi fn eval(handle: &mut Schala, input: TempASTReduction, _comp: Option<&mut UnfinishedComputation>) -> Result { let new_input = input.0; - let _new_eval_output = handle.state.evaluate_new(new_input); + let new_eval_output = handle.state.evaluate_new(new_input); + match new_eval_output[0] { + Ok(ref s) => println!("NEW OUTPUT> {}", s), + Err(ref e) => println!("NEW ERR> {}", e), + } /* old-style eval */ let input = input.1;