mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Add List.for_each!
This commit is contained in:
parent
99d4758d81
commit
adfa93d77e
15 changed files with 517 additions and 1 deletions
|
|
@ -2396,6 +2396,12 @@ pub const Expr = union(enum) {
|
|||
region: TokenizedRegion,
|
||||
},
|
||||
block: Block,
|
||||
for_expr: struct {
|
||||
patt: Pattern.Idx,
|
||||
expr: Expr.Idx,
|
||||
body: Expr.Idx,
|
||||
region: TokenizedRegion,
|
||||
},
|
||||
malformed: struct {
|
||||
reason: Diagnostic.Tag,
|
||||
region: TokenizedRegion,
|
||||
|
|
@ -2444,6 +2450,7 @@ pub const Expr = union(enum) {
|
|||
.block => |e| e.region,
|
||||
.record_builder => |e| e.region,
|
||||
.ellipsis => |e| e.region,
|
||||
.for_expr => |e| e.region,
|
||||
.malformed => |e| e.region,
|
||||
.string_part => |e| e.region,
|
||||
.single_quote => |e| e.region,
|
||||
|
|
@ -2774,6 +2781,23 @@ pub const Expr = union(enum) {
|
|||
// Push child expression
|
||||
try ast.store.getExpr(a.expr).pushToSExprTree(gpa, env, ast, tree);
|
||||
|
||||
try tree.endNode(begin, attrs);
|
||||
},
|
||||
.for_expr => |f| {
|
||||
const begin = tree.beginNode();
|
||||
try tree.pushStaticAtom("e-for");
|
||||
try ast.appendRegionInfoToSexprTree(env, tree, f.region);
|
||||
const attrs = tree.beginNode();
|
||||
|
||||
// Push pattern
|
||||
try ast.store.getPattern(f.patt).pushToSExprTree(gpa, env, ast, tree);
|
||||
|
||||
// Push list expression
|
||||
try ast.store.getExpr(f.expr).pushToSExprTree(gpa, env, ast, tree);
|
||||
|
||||
// Push body expression
|
||||
try ast.store.getExpr(f.body).pushToSExprTree(gpa, env, ast, tree);
|
||||
|
||||
try tree.endNode(begin, attrs);
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue