Add lists

This commit is contained in:
Richard Feldman 2019-08-28 00:04:08 -04:00
parent 46750ae6ca
commit 8985b4bec7
9 changed files with 200 additions and 12 deletions

View file

@ -11,6 +11,8 @@ pub enum Expr {
EmptyStr,
Str(String),
Char(char),
List(Vec<Located<Expr>>),
EmptyList,
// Lookups
Var(Ident),
@ -113,7 +115,15 @@ impl Expr {
let transformed = transform(self);
match transformed {
Int(_) | Frac(_, _) | Approx(_) | EmptyStr | Str(_) | Char(_) | Var(_) | EmptyRecord | InterpolatedStr(_, _) => transformed,
Int(_) | Frac(_, _) | Approx(_) | EmptyStr | Str(_) | Char(_) | Var(_) | EmptyRecord | InterpolatedStr(_, _) | EmptyList => transformed,
List(elems) => {
let new_elems =
elems.into_iter()
.map(|loc_elem| loc_elem.with_value(loc_elem.value.walk(transform)))
.collect();
List(new_elems)
}
Assign(assignments, loc_ret) => {
Assign(
assignments.into_iter().map(|(pattern, loc_expr)|
@ -161,4 +171,4 @@ impl Expr {
}
}
}
}
}