mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 00:45:04 +01:00
Change let
This commit is contained in:
parent
40543b501c
commit
7c2faaecb8
9 changed files with 200 additions and 100 deletions
20
src/ast.ts
20
src/ast.ts
|
|
@ -54,15 +54,18 @@ export type ExprEmpty = { kind: "empty" };
|
|||
|
||||
export type ExprLet = {
|
||||
kind: "let";
|
||||
name: string;
|
||||
name: Identifier;
|
||||
type?: Type;
|
||||
rhs: Expr;
|
||||
after: Expr;
|
||||
// IMPORTANT: This is (sadly) shared with ExprBlock.
|
||||
local?: LocalInfo,
|
||||
};
|
||||
|
||||
export type ExprBlock = {
|
||||
kind: "block";
|
||||
exprs: Expr[];
|
||||
// IMPORTANT: This is (sadly) shared with ExprLet.
|
||||
locals?: LocalInfo[];
|
||||
};
|
||||
|
||||
export type ExprLiteral = {
|
||||
|
|
@ -206,13 +209,15 @@ export type Type = TypeKind & {
|
|||
ty?: Ty;
|
||||
};
|
||||
|
||||
// name resolution stuff
|
||||
|
||||
export type Resolution =
|
||||
| {
|
||||
kind: "local";
|
||||
/**
|
||||
* The index of the local variable, from inside out.
|
||||
* ```
|
||||
* let a in let b in (a, b);
|
||||
* let a = 0; let b; (a, b);
|
||||
* ^ ^
|
||||
* 1 0
|
||||
* ```
|
||||
|
|
@ -246,6 +251,14 @@ export const BUILTINS = [
|
|||
|
||||
export type BuiltinName = (typeof BUILTINS)[number];
|
||||
|
||||
export type LocalInfo = {
|
||||
name: string;
|
||||
span: Span;
|
||||
ty?: Ty;
|
||||
};
|
||||
|
||||
// types
|
||||
|
||||
export type TyString = {
|
||||
kind: "string";
|
||||
};
|
||||
|
|
@ -397,7 +410,6 @@ export function superFoldExpr(expr: Expr, folder: Folder): Expr {
|
|||
name: expr.name,
|
||||
type: expr.type && folder.type(expr.type),
|
||||
rhs: folder.expr(expr.rhs),
|
||||
after: folder.expr(expr.after),
|
||||
};
|
||||
}
|
||||
case "block": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue