mirror of
https://github.com/Noratrieb/riverdelta.git
synced 2026-01-15 00:45:04 +01:00
generate more code
This commit is contained in:
parent
ccd8008731
commit
42bc96dbce
7 changed files with 306 additions and 51 deletions
20
src/ast.ts
20
src/ast.ts
|
|
@ -155,8 +155,8 @@ const BINARY_KIND_PREC_CLASS = new Map<BinaryKind, number>([
|
|||
|
||||
export function binaryExprPrecedenceClass(k: BinaryKind): number {
|
||||
const cls = BINARY_KIND_PREC_CLASS.get(k);
|
||||
if (!cls) {
|
||||
throw new Error(`Invalid binary kind: ${k}`);
|
||||
if (cls === undefined) {
|
||||
throw new Error(`Invalid binary kind: '${k}'`);
|
||||
}
|
||||
return cls;
|
||||
}
|
||||
|
|
@ -209,15 +209,27 @@ export type Resolution =
|
|||
}
|
||||
| {
|
||||
kind: "builtin";
|
||||
name: string;
|
||||
name: BuiltinName;
|
||||
};
|
||||
|
||||
export const BUILTINS = [
|
||||
"print",
|
||||
"String",
|
||||
"Int",
|
||||
"Bool",
|
||||
"true",
|
||||
"false",
|
||||
] as const;
|
||||
|
||||
export type BuiltinName = (typeof BUILTINS)[number];
|
||||
|
||||
export type TyString = {
|
||||
kind: "string";
|
||||
};
|
||||
|
||||
export type TyInt = {
|
||||
kind: "int";
|
||||
signed: boolean;
|
||||
};
|
||||
|
||||
export type TyBool = {
|
||||
|
|
@ -259,7 +271,7 @@ export function tyIsUnit(ty: Ty): ty is TyUnit {
|
|||
export const TY_UNIT: Ty = { kind: "tuple", elems: [] };
|
||||
export const TY_STRING: Ty = { kind: "string" };
|
||||
export const TY_BOOL: Ty = { kind: "bool" };
|
||||
export const TY_INT: Ty = { kind: "int" };
|
||||
export const TY_INT: Ty = { kind: "int", signed: false };
|
||||
|
||||
// folders
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue