diff options
author | Akshay <[email protected]> | 2021-03-30 15:04:02 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-03-30 15:04:02 +0100 |
commit | 431fd02329e2cd663db0acda5b229bbe632c5338 (patch) | |
tree | ccabed68b5f653eb1aae9e715d6a4e162925ffc6 /src | |
parent | 4afc8ffdfe7ca2976bbab9d59da4c2ae11902c2f (diff) |
refactor to use Evaluator
Diffstat (limited to 'src')
-rw-r--r-- | src/app.rs | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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(); |