From 044f534ac5ea9bf644df6bb1f33ff05aec01d14c Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 21 Jan 2016 01:16:01 -0800 Subject: [PATCH] Start implementing variable lookup --- src/eval.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/eval.rs b/src/eval.rs index 6bc9016..143718b 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -7,7 +7,9 @@ struct Varmap { impl Varmap { fn new() -> Varmap { - Varmap { map: HashMap::new() } + let mut map = HashMap::new(); + map.insert("a".to_string(), Expression::Number(10.0)); + Varmap { map: map } } fn add_binding(&mut self, var: String, value: Expression) { @@ -97,7 +99,10 @@ impl Evaluator { match expression { e@StringLiteral(_) => e, e@Number(_) => e, - Variable(var) => Number(20.0), + Variable(var) => { + let expr = self.varmap.lookup_binding(var).unwrap(); + expr.clone() + }, _ => unimplemented!(), }