55 lines
781 B
OCaml
55 lines
781 B
OCaml
type op
|
|
= OpAdd
|
|
| OpSub
|
|
| OpMul
|
|
| OpDiv
|
|
[@@deriving show]
|
|
|
|
type lit
|
|
= LitInt of int
|
|
| LitNegInt of int
|
|
| LitFloat of float
|
|
[@@deriving show]
|
|
|
|
type ty
|
|
= TySizedInt
|
|
| TyGenericInt
|
|
| TyFunc of ty list * ty
|
|
| TyPointer of ty
|
|
| TyStruct of (string * ty) list
|
|
[@@deriving show]
|
|
|
|
type expr
|
|
= ExprUnit
|
|
| ExprLit of lit
|
|
| ExprBin of expr * op * expr
|
|
| ExprAnnot of expr * ty
|
|
[@@deriving show]
|
|
|
|
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 decl
|
|
= DeclFunc of func
|
|
[@@deriving show]
|
|
|
|
type program = decl list
|
|
[@@deriving show]
|