blob: e517b58b916dd1b25d5fed78e50233792047a59a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
(****************************************
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
|