diff --git a/rust/src/evaluator.rs b/rust/src/evaluator.rs index 9dcfe3c..8e670e9 100644 --- a/rust/src/evaluator.rs +++ b/rust/src/evaluator.rs @@ -31,12 +31,17 @@ impl<'a> Env<'a> { panic!("Variable {} not in scope.", id) } } + pub fn set(&mut self, id: String, atom: Atom) { + self.values.insert(id, atom); + } } pub fn eval(ast: &parser::Stmt, env: &mut Env) { match &ast { parser::Stmt::ReplPrint(expr) => println!("{}", eval_expr(expr, env)), + parser::Stmt::Assignment(id, expr) => + env.set(id.clone(), eval_expr(expr, env)), _ => todo!(), } }