e0/lib/ast.ml
Michael Zhang e66b515826
Parsing
2022-03-08 02:52:20 -06:00

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]