-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast.ml
67 lines (59 loc) · 1.21 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
type identifier = string
type intrinsic =
| SCAN
| CANNON
| DRIVE
| DAMAGE
| SPEED
| HEADING
| LOC_X
| LOC_Y
| RAND
| SQRT
| SIN
| COS
| TAN
| ATAN
type binary_op =
| ADD
| SUB
| MUL
| DIV
| MOD
| EQ
| NEQ
| GT
| LT
| GEQ
| LEQ
| LAND
| LOR
| LSHIFT
| RSHIFT
type unary_op = UMINUS | LNOT
type parameters = identifier list
type expression =
| NIL
| IDE of identifier
| ASSIGN of identifier * expression
| CALL of identifier * expression list
| CALL_EXEC of instruction (* runtime-only *)
| CONST of int
| UNARY_EXPR of unary_op * expression
| BINARY_EXPR of expression * binary_op * expression
and instruction =
| EMPTY
| IF of expression * instruction
| IFE of expression * instruction * instruction
| WHILE of expression * instruction
| WHILE_EXEC of expression * instruction (* runtime-only *)
| EXPR of expression
| RET of expression option
| BLOCK of instruction
| BLOCK_EXEC of instruction (* runtime-only *)
| VARDECL of identifier
| VARDECL_INIT of identifier * expression
| FUNDECL of identifier * parameters * instruction
| SEQ of instruction * instruction
type program = instruction
let entry_point = CALL ("main", [])