export type Program = Array // Declarations export type Decl = VarDecl export type VarDecl = ADecl<"var", { type: Type, }> type ADecl = { type: "decl", decl_type: Ty, attrs: Array, name: string, args: Args, } // Statements export type Stmt = LabelStmt | GotoStmt | AssignStmt export type LabelStmt = AStmt<"label", { name: string, }> export type GotoStmt = AStmt<"goto", { name: string, }> export type AssignStmt = AStmt<"assign", { name: string, expr: Expr, }> type AStmt = { type: "stmt", stmt_type: Ty, args: Args, } // Expressions export type Expr = BinaryExpr | UnaryExpr | BasicExpr type BinaryExpr = { type: "binary", op: BinaryOp, left: Expr, right: Expr, } type UnaryExpr = { type: "unary", op: UnaryOp, arg: Expr, } type BasicExpr = number | string type UnaryOp = "arith_negate" | "bit_negate" type BinaryOp = "add" | "subtract" | "shift_left" | "shift_right" | "bit_and" | "bit_xor" | "bit_or" // Attributes export type Attr = { name: string, args: Array, } // Types export type Type = PrimitiveType export type PrimitiveType = "s8" | "u8" | "u16"