From f68167f3a2a867223d1f595bf225c09274a04b1c Mon Sep 17 00:00:00 2001 From: greg Date: Mon, 23 Oct 2017 00:22:25 -0700 Subject: [PATCH] Halfway done with evaluating tuples --- src/schala_lang/eval.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/schala_lang/eval.rs b/src/schala_lang/eval.rs index 776d820..536b370 100644 --- a/src/schala_lang/eval.rs +++ b/src/schala_lang/eval.rs @@ -26,7 +26,8 @@ enum FullyEvaluatedExpr { Bool(bool), Custom { string_rep: Rc, - } + }, + Tuple(Vec), } impl ReplState { @@ -66,6 +67,7 @@ impl ReplState { Str(s) => Some(format!("\"{}\"", s)), Bool(b) => Some(format!("{}", b)), Custom { string_rep } => Some(format!("{}", string_rep)), + Tuple(_items) => Some(format!("(tuple to be defined later)")), } }) }, @@ -112,7 +114,17 @@ impl ReplState { PrefixExp(op, expr) => self.eval_prefix_exp(op, expr), BinExp(op, lhs, rhs) => self.eval_binexp(op, lhs, rhs), Value(name, _) => self.eval_value(name), - _ => Err(format!("Unimplemented")), + TupleLiteral(expressions) => { + let mut evals = Vec::new(); + for expr in expressions { + match self.eval_expr(expr) { + Ok(fully_evaluated) => evals.push(fully_evaluated), + error => return error, + } + } + Ok(Tuple(evals)) + } + x => Err(format!("Unimplemented thing {:?}", x)), } }