aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-03-30 15:04:02 +0100
committerAkshay <[email protected]>2021-03-30 15:04:02 +0100
commit431fd02329e2cd663db0acda5b229bbe632c5338 (patch)
treeccabed68b5f653eb1aae9e715d6a4e162925ffc6 /src/app.rs
parent4afc8ffdfe7ca2976bbab9d59da4c2ae11902c2f (diff)
refactor to use Evaluator
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs14
1 files changed, 10 insertions, 4 deletions
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> {
281 let mut parser = Parser::new(Lexer::new(lisp_expr, 0)); 281 let mut parser = Parser::new(Lexer::new(lisp_expr, 0));
282 let res = parser.parse_single_expr(); 282 let res = parser.parse_single_expr();
283 match res { 283 match res {
284 Ok(expr) => match eval::eval(&expr, self) { 284 Ok(expr) => {
285 Ok(val) => self.message.set_info(format!("{}", val)), 285 let mut evaluator = eval::Evaluator {
286 Err(eval_err) => self.message.set_error(format!("{}", eval_err)), 286 app: self,
287 }, 287 context: Vec::new(),
288 };
289 match evaluator.eval(&expr) {
290 Ok(val) => self.message.set_info(format!("{}", val)),
291 Err(eval_err) => self.message.set_error(format!("{}", eval_err)),
292 }
293 }
288 Err(err) => self.message = handle_error(err, &lisp_expr, "repl"), 294 Err(err) => self.message = handle_error(err, &lisp_expr, "repl"),
289 } 295 }
290 self.command_box.hist_append(); 296 self.command_box.hist_append();