forked from dextercallender/blur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast.ml
80 lines (68 loc) · 1.25 KB
/
ast.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
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
(* BLUR Abstract Syntax Tree
* Authors: Tim Goodwin - [email protected], Melissa [email protected]
*)
type binopr =
Add
| Sub
| Mult
| Div
| Mod
| Eq
| Neq
| Lt
| Leq
| Gt
| Geq
| And
| Or
| Asn
type unopr = Not | Neg | Mag
(* BLUR TYPES *)
type primitive =
Int
| Double
| Char
| String
| Bool
| Void
type expr =
Binop of expr * binopr * expr
| Unop of unopr * expr
| IntLit of int
| DoubleLit of float
| StrLit of string
| CharLit of char
| BoolLit of bool
| Id of string
| ArrayListInit of expr list
| ArrayAccess of string * expr list
| FuncCall of string * expr list
| Noexpr
type datatype =
SizedArray of primitive * int list
| UnsizedArray of primitive * int
| Datatype of primitive
type argdecl = {
argdeclType : datatype;
argdeclID : string;
}
type vardecl = {
declTyp : datatype;
declID : string;
declInit : expr;
}
type stmt =
Block of stmt list
| Expr of expr
| Decl of vardecl
| Return of expr
| If of expr * stmt * stmt
| For of expr * expr * expr * stmt
| While of expr * stmt
type funcdecl = {
typ : datatype;
fname : string;
args : argdecl list;
body : stmt list;
}
type program = vardecl list * funcdecl list