Halfway done with evaluating tuples
This commit is contained in:
parent
c9625ffa77
commit
f68167f3a2
@ -26,7 +26,8 @@ enum FullyEvaluatedExpr {
|
|||||||
Bool(bool),
|
Bool(bool),
|
||||||
Custom {
|
Custom {
|
||||||
string_rep: Rc<String>,
|
string_rep: Rc<String>,
|
||||||
}
|
},
|
||||||
|
Tuple(Vec<FullyEvaluatedExpr>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ReplState {
|
impl ReplState {
|
||||||
@ -66,6 +67,7 @@ impl ReplState {
|
|||||||
Str(s) => Some(format!("\"{}\"", s)),
|
Str(s) => Some(format!("\"{}\"", s)),
|
||||||
Bool(b) => Some(format!("{}", b)),
|
Bool(b) => Some(format!("{}", b)),
|
||||||
Custom { string_rep } => Some(format!("{}", string_rep)),
|
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),
|
PrefixExp(op, expr) => self.eval_prefix_exp(op, expr),
|
||||||
BinExp(op, lhs, rhs) => self.eval_binexp(op, lhs, rhs),
|
BinExp(op, lhs, rhs) => self.eval_binexp(op, lhs, rhs),
|
||||||
Value(name, _) => self.eval_value(name),
|
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)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user