-
Notifications
You must be signed in to change notification settings - Fork 0
/
sast.ml
64 lines (52 loc) · 1.22 KB
/
sast.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
open Ast
type sexpr =
SLiteral of int
| SStrlit of string
| SFloatlit of float
| SBoolLit of bool
| SCharlit of char
| SId of string * typ
| SBinop of sexpr * op * sexpr * typ
| SUnop of uop * sexpr * typ
| SAssign of sexpr * sexpr * typ
| SCall of string * sexpr list * typ
| SArrayAccess of sexpr * sexpr * typ
| SHashmapAccess of string * sexpr * typ
| SObjectAccess of sexpr * sexpr * typ
| SNoexpr
(*type var_decl = Vdecl of typ * string*)
type sstmt =
SBlock of sstmt list
| SExpr of sexpr * typ
| SReturn of sexpr * typ
| SIf of sexpr * sstmt * sstmt
| SFor of sexpr * sexpr * sexpr * sstmt
| SWhile of sexpr * sstmt
| SForeach of typ * string * string * sstmt
| SBreak
| SContinue
| SLocal of typ * string
type ftype = Reserved | Udf
type sfunc_decl = {
styp : typ;
sfname : string;
sformals : formal list;
sbody : sstmt list;
sftype : ftype;
scontext_class : string;
sthis_ptr : sexpr;
}
type scbody = {
sfields : var_decl list;
smethods : sfunc_decl list;
}
type scdecl = {
scname : string;
scbody : scbody;
}
type sprogram = {
classes : scdecl list;
functions : sfunc_decl list;
main : sfunc_decl;
reserved : sfunc_decl list;
}