From 3d023a6704bcdf25558ce78743d9abfeadab32b8 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 9 Dec 2017 19:08:01 -0800 Subject: [PATCH] Rukka - Variables --- src/rukka_lang/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/rukka_lang/mod.rs b/src/rukka_lang/mod.rs index 464a2dc..a4cea06 100644 --- a/src/rukka_lang/mod.rs +++ b/src/rukka_lang/mod.rs @@ -56,7 +56,15 @@ impl EvaluatorState { fn eval(&mut self, expr: Sexp) -> Result { use self::Sexp::*; Ok(match expr { - SymbolAtom(sym) => unimplemented!(), + SymbolAtom(ref sym) => { + match self.vars.get(sym) { + Some(ref sexp) => { + let q: &Sexp = sexp; //WTF? if I delete this line, the copy doesn't work?? + q.clone() //TODO make this not involve a clone + }, + None => return Err(format!("Variable {} not bound", sym)), + } + }, expr @ StringAtom(_) => expr, expr @ NumberAtom(_) => expr, True => True, @@ -135,7 +143,7 @@ enum Token { } //TODO make this notion of Eq more sophisticated -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] enum Sexp { SymbolAtom(String), StringAtom(String),