import { Position } from "./token.ts"; export type UnaryType = | "negate" | "log_not" | "bit_not" | "addressof" | "dereference"; export type BinaryType = | "add" | "subtract" | "log_and" | "log_or" | "bit_and" | "bit_or" | "bit_xor" | "equal" | "inequal" | "lt" | "gt" | "ltequal" | "gtequal"; export type AssignType = | "equal" | "add" | "subtract" | "and" | "or" | "xor"; export type ParsedExpr = & { pos: Position; } & ({ exprType: "error"; message: string } | { exprType: "unit"; } | { exprType: "id"; value: string; } | { exprType: "int"; value: number; } | { exprType: "if"; condition: ParsedExpr; truthy: ParsedExpr; falsy: ParsedExpr | null; } | { exprType: "block"; body: ParsedExpr[]; } | { exprType: "call"; subject: ParsedExpr; args: ParsedExpr[]; } | { exprType: "index"; subject: ParsedExpr; value: ParsedExpr; } | { exprType: "increment" | "decrement"; subject: ParsedExpr; } | { exprType: "unary"; unaryType: UnaryType; subject: ParsedExpr; } | { exprType: "binary"; binaryType: BinaryType; left: ParsedExpr; right: ParsedExpr; } | { exprType: "assign"; assignType: AssignType; subject: ParsedExpr; value: ParsedExpr; } | { exprType: "let"; param: ParsedParameter; value: ParsedExpr; } | { exprType: "fn"; subject: string; params: ParsedParameter[]; returnType: ParsedType | null; body: ParsedExpr; } | { exprType: "return"; value: ParsedExpr | null; } | { exprType: "loop"; body: ParsedExpr; } | { exprType: "while"; condition: ParsedExpr; body: ParsedExpr; } | { exprType: "break"; } | { exprType: "continue"; }); export type ParsedParameter = & { pos: Position; } & ({ paramType: "error"; message: string } | { paramType: "value"; subject: string; valueType: ParsedType | null; mutable: boolean; }); export type ParsedType = & { pos: Position } & ({ typeType: "error"; message: string } | { typeType: "unit"; } | { typeType: "id"; value: string; } | { typeType: "pointer"; subject: ParsedType; mutable: boolean; });