-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype.ml
executable file
·44 lines (34 loc) · 891 Bytes
/
type.ml
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
type position = int
(** Nom de variable *)
type name = string
(** Opérateurs arithmétiques : + - * / % *)
type op = Add | Sub | Mul | Div | Mod
(** Expressions arithmétiques *)
type expr =
| Num of int
| Var of name
| Op of op * expr * expr
(** Opérateurs de comparaisons *)
type comp =
| Eq (* = *)
| Ne (* Not equal, <> *)
| Lt (* Less than, < *)
| Le (* Less or equal, <= *)
| Gt (* Greater than, > *)
| Ge (* Greater or equal, >= *)
(** Signe des Variables *)
type sign = Neg | Zero | Pos | Error
(** Condition : comparaison entre deux expressions *)
type cond = expr * comp * expr
(** Instructions *)
type instr =
| Set of name * expr
| Read of name
| Print of expr
| If of cond * block * block
| While of cond * block
and block = (position * instr) list
type program =
block
module Table = Map.Make(String)
module VarEnv = Map.Make(String)