-
Notifications
You must be signed in to change notification settings - Fork 0
/
ast.ml
32 lines (28 loc) · 961 Bytes
/
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
type types =
| UNIT_T
| IDENT_T
| U32_T
| I32_T
| BOOL_T
(* if type list is empty -> not typeable *)
type infix_operations =
| I_ADD
| I_SUB
(* | I_LSHIFT *)
(* | I_RSHIFT *)
| I_LTHAN
| I_EQUAL
type ast =
| LET of ast * ast * ast (* let x:u32 = 5 *)
| DECLARE of ast * ast (* let x:u32 *)
| ASSIGN of ast * ast (* x = 5 *)
| SEQ of (ast list) (* {thing1; thing2;} (last semicolon optional)*)
| INT of int (* 5 *)
| BOOL of bool (* true *)
| IDENT of string (* x *)
| TYPE_IDENT of types (* u32 *)
| INFIX of ast * infix_operations * ast (* x+3 or a<<1 etc..*)
(* TODO: where to handle converting from brackets (3+4)*65 to just nested INFIX *)
| IF of ast * ast * ast (* if condition then seq1 else seq2*)
| WHILE of ast * ast (* while condition seq *)
(* TODO: product and sum types (structs and enums) *)