From 431fd02329e2cd663db0acda5b229bbe632c5338 Mon Sep 17 00:00:00 2001 From: Akshay Date: Tue, 30 Mar 2021 19:34:02 +0530 Subject: refactor to use Evaluator --- src/app.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/app.rs b/src/app.rs index fb6e9df..29a292f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -281,10 +281,16 @@ impl<'ctx, 'file> AppState<'ctx, 'file> { let mut parser = Parser::new(Lexer::new(lisp_expr, 0)); let res = parser.parse_single_expr(); match res { - Ok(expr) => match eval::eval(&expr, self) { - Ok(val) => self.message.set_info(format!("{}", val)), - Err(eval_err) => self.message.set_error(format!("{}", eval_err)), - }, + Ok(expr) => { + let mut evaluator = eval::Evaluator { + app: self, + context: Vec::new(), + }; + match evaluator.eval(&expr) { + Ok(val) => self.message.set_info(format!("{}", val)), + Err(eval_err) => self.message.set_error(format!("{}", eval_err)), + } + } Err(err) => self.message = handle_error(err, &lisp_expr, "repl"), } self.command_box.hist_append(); -- cgit v1.2.3