mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Add lists
This commit is contained in:
parent
46750ae6ca
commit
8985b4bec7
9 changed files with 200 additions and 12 deletions
14
src/expr.rs
14
src/expr.rs
|
@ -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 {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue