More boilerplate
This commit is contained in:
parent
30128d7d34
commit
81368179bb
@ -320,7 +320,27 @@ impl<'a> State<'a> {
|
|||||||
/* BELOW HERE NEW STUFF */
|
/* BELOW HERE NEW STUFF */
|
||||||
|
|
||||||
impl<'a> State<'a> {
|
impl<'a> State<'a> {
|
||||||
pub fn evaluate_new(&mut self, input: ReducedAST) -> Result<String, String> {
|
pub fn evaluate_new(&mut self, ast: ReducedAST) -> Vec<Result<String, String>> {
|
||||||
Ok("not done".to_string())
|
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<Option<String>, String> {
|
||||||
|
Ok(Some(format!("stmt - {:?}", stmt)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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<String, String> {
|
fn eval(handle: &mut Schala, input: TempASTReduction, _comp: Option<&mut UnfinishedComputation>) -> Result<String, String> {
|
||||||
|
|
||||||
let new_input = input.0;
|
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 */
|
/* old-style eval */
|
||||||
let input = input.1;
|
let input = input.1;
|
||||||
|
Loading…
Reference in New Issue
Block a user