-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast.ml
59 lines (49 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
(* Abstract Syntax Tree *)
type loc = Lexing.position * Lexing.position
type typ =
| Tunit
| Tbool
| Tint
| Tabool
| Taint
| Tunknown
type ident = typ * string
type unop =
| Unot (* not e *)
type binop =
| Badd | Bsub | Bmul | Bdiv (* + - * / *)
| Beq | Bneq | Blt | Ble | Bgt | Bge (* == != < <= > >= *)
| Band | Bor (* && || *)
type constant =
| Cunit
| Cbool of bool
| Cint of int
type expr =
| Ecst of loc * typ * constant
| Eident of loc * typ * ident
| Eref of loc * typ * expr
| Ederef of loc * typ * ident
| Eunop of loc * typ * unop * expr
| Ebinop of loc * typ * binop * expr * expr
| Earray of loc * typ * expr list
| Eaget of loc * typ * ident * expr
| Easize of loc * typ * ident
| Erand of loc * typ * expr * expr
type stmt =
| Sassign of loc * ident * expr * stmt
| Srefassign of loc * ident * expr
| Saassign of loc * ident * expr * expr
| Sblock of block
| Sif of loc * expr * stmt * stmt
| Swhile of loc * expr * block
| Sfor of loc * stmt * expr * stmt * block
| Sprint of expr
| Sprint_ai of loc * ident
| Sprintall_ai of loc
| Sexit
| Sskip
and block =
| Bstmt of stmt
| Bseq_l of stmt * block
| Bseq_r of block * stmt
type prog = stmt