(**************************************** ast.mli - types, motifs, expressions ****************************************) open Lexing (* Types *) type typ = | Tint | Tstring | Tbool | Tunit | Tarrow of typ * typ | Tproduct of typ list | Tlist of typ | Tvar of tvar and tvar = { id : int; mutable def : typ option } (* AST *) type ident = string type pos = { l : int ; c : int ; raw_c : int } type loc = { spos : pos ; epos : pos } type expr_loc = loc option type expr_typ = typ option type binop = | OAdd | OSub | OMul | ODiv | OAnd | OOr | OEq | ONeq | OLt | OLe | OGt | OGe type unop = | ONeg | ONot type const = | Cint of int | Cstring of string | Cbool of bool | Cunit | Cemptylist type motif_raw = | Munderscore | Mident of string | Mtuple of motif list and motif = { m : motif_raw ; motif_loc : expr_loc ; mutable motif_t : expr_typ } type expr_raw = | Econst of const | Eident of ident | Etuple of expr list | Ebinop of expr * binop * expr | Eunop of unop * expr | Eletin of motif * expr * expr | Efunc of func | Eif of expr * expr * expr | Elistcons of expr * expr | Ecall of expr * expr | Ematch of expr * expr * motif * motif * expr | Eclos of bool * ident * ident list and expr = { e : expr_raw ; loc : expr_loc ; mutable t : expr_typ } and func = { name : motif ; recursive : bool ; arg : motif ; body : expr } type letfun = ident * ident list * motif * expr