Add support for tuple literals

This commit is contained in:
nora 2023-07-30 21:49:18 +02:00
parent 0c996eb9bc
commit b64c02cf4a
6 changed files with 82 additions and 35 deletions

View file

@ -146,6 +146,11 @@ export type ExprStructLiteral = {
fields: [Identifier, Expr][];
};
export type TupleLiteral = {
kind: "tupleLiteral";
fields: Expr[];
};
export type ExprKind =
| ExprEmpty
| ExprLet
@ -159,7 +164,8 @@ export type ExprKind =
| ExprIf
| ExprLoop
| ExprBreak
| ExprStructLiteral;
| ExprStructLiteral
| TupleLiteral;
export type Expr = ExprKind & {
span: Span;
@ -567,6 +573,13 @@ export function superFoldExpr(expr: Expr, folder: Folder): Expr {
fields: expr.fields.map(([name, expr]) => [name, folder.expr(expr)]),
};
}
case "tupleLiteral": {
return {
...expr,
kind: "tupleLiteral",
fields: expr.fields.map(folder.expr.bind(folder)),
};
}
}
}