-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsyntaxtree.ml
More file actions
95 lines (67 loc) · 1.59 KB
/
Copy pathsyntaxtree.ml
File metadata and controls
95 lines (67 loc) · 1.59 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
(* identifiers *)
type ide = Ide of string
(* arithmetical expressions *)
type aexp =
N of int
| R of float
| Var of ide
| Rec of ide * ide
| RecV of ide * ide * aexp
| RecM of ide * ide * aexp * aexp
| Vec of ide * aexp
| Mat of ide * aexp * aexp
| Sum of aexp * aexp
| Sub of aexp * aexp
| Mul of aexp * aexp
| Div of aexp * aexp
| FCall of ide * aexp list
(* boolean expressions *)
type bexp =
B of bool
| Equ of aexp * aexp
| LE of aexp * aexp
| LT of aexp * aexp
| GE of aexp * aexp
| GT of aexp * aexp
| Not of bexp
| And of bexp * bexp
| Or of bexp * bexp
(* left expressions *)
type lexp =
LVar of ide
| LRec of ide * lexp
| LVec of ide * aexp
| LMat of ide * aexp * aexp
(* commands *)
type cmd =
Ass of lexp * aexp
| Blk of cmd list
| Ite of bexp * cmd * cmd
(*
NON ANCORA IMPLEMENTATO
| It of bexp * cmd
*)
| While of bexp * cmd
| Repeat of cmd * bexp
| For of ide * aexp * aexp * cmd
| Write of aexp
| PCall of ide * aexp list
(* declarations *)
type bType = Int
| Float
type gType =
Basic of bType
| UserType of ide (* da matchare con rec_ ... *)
| Vector of int * bType
| Matrix of int * int * bType
type dec = Dec of ide * gType
(* record declarations *)
type rec_ = Record of ide * dec list
(* procedures / functions *)
type param = Par of ide * bType
type ret = Ret of bType
type proc =
Proc of ide * param list * dec list * cmd
| Func of ide * param list * ret * dec list * cmd
(* programs *)
type program = Program of rec_ list * dec list * proc list * cmd