2022-03-23 06:12:37 +00:00
|
|
|
type op = OpAdd | OpSub | OpMul | OpDiv [@@deriving show]
|
2022-03-08 06:16:27 +00:00
|
|
|
|
2022-03-23 06:12:37 +00:00
|
|
|
type lit = LitInt of int | LitNegInt of int | LitFloat of float
|
2022-03-08 08:52:20 +00:00
|
|
|
[@@deriving show]
|
|
|
|
|
2022-03-23 06:12:37 +00:00
|
|
|
type ty =
|
|
|
|
| TyUnit
|
|
|
|
| TySizedInt
|
2022-03-08 08:52:20 +00:00
|
|
|
| TyGenericInt
|
|
|
|
| TyFunc of ty list * ty
|
|
|
|
| TyPointer of ty
|
|
|
|
| TyStruct of (string * ty) list
|
|
|
|
[@@deriving show]
|
2022-03-08 06:16:27 +00:00
|
|
|
|
2022-03-23 06:12:37 +00:00
|
|
|
type expr =
|
|
|
|
| ExprUnit
|
2022-03-08 08:52:20 +00:00
|
|
|
| ExprLit of lit
|
2022-03-08 06:16:27 +00:00
|
|
|
| ExprBin of expr * op * expr
|
2022-03-08 08:52:20 +00:00
|
|
|
| ExprAnnot of expr * ty
|
|
|
|
[@@deriving show]
|
|
|
|
|
2022-03-23 06:12:37 +00:00
|
|
|
type pat = PatName of string [@@deriving show]
|
|
|
|
type stmt = StmtLet of pat * expr | StmtReturn of expr [@@deriving show]
|
|
|
|
type block = { stmts : stmt list; ret : expr } [@@deriving show]
|
|
|
|
type func = { name : string; body : block } [@@deriving show]
|
|
|
|
type extern_func = { name : string } [@@deriving show]
|
|
|
|
type decl = DeclFunc of func | DeclExternFunc of extern_func [@@deriving show]
|
|
|
|
type program = decl list [@@deriving show]
|