-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathttree.mli
67 lines (54 loc) · 1.37 KB
/
ttree.mli
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
(** arbres issus du typage *)
type ident = string
type typ =
| Tint (* int *)
| Tstructp of structure (* struct S * *)
| Tvoidstar (* void * *)
| Ttypenull (* le type donné à la constante 0 *)
and structure = {
str_name : ident;
str_fields: (ident, field) Hashtbl.t;
str_size : int
(* on pourra ajouter plus tard ici la taille totale de la structure *)
}
and field = {
field_name : string;
field_typ : typ;
field_position: int
(* on pourra ajouter plus tard ici la position du champ dans la structure *)
}
type unop = Ptree.unop
type binop = Ptree.binop
type decl_var = typ * ident
type expr = {
expr_node: expr_node;
expr_typ : typ (* chaque expression est décorée par son type *)
}
and expr_node =
| Econst of int32
| Eaccess_local of ident
| Eaccess_field of expr * field
| Eassign_local of ident * expr
| Eassign_field of expr * field * expr
| Eunop of unop * expr
| Ebinop of binop * expr * expr
| Ecall of ident * expr list
| Esizeof of structure
type stmt =
| Sskip
| Sexpr of expr
| Sif of expr * stmt * stmt
| Swhile of expr * stmt
| Sblock of block
| Sreturn of expr
and block =
decl_var list * stmt list
and decl_fun = {
fun_typ : typ;
fun_name : ident;
fun_formals: decl_var list;
fun_body : block
}
type file = {
funs: decl_fun list;
}