-
Notifications
You must be signed in to change notification settings - Fork 10
/
MJ.mli
64 lines (54 loc) · 1.43 KB
/
MJ.mli
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
(** This is the same abstract syntax tree as in [LMJ.mli] but without position informations.
After typechecking, we don't need to give feedbacks to the user. *)
type identifier = string
type expression =
| EConst of constant
| EGetVar of identifier
| EUnOp of unop * expression
| EBinOp of binop * expression * expression
| EMethodCall of expression * identifier * expression list
| EArrayGet of expression * expression
| EArrayAlloc of expression
| EArrayLength of expression
| EThis
| EObjectAlloc of identifier
and constant = LMJ.constant =
| ConstBool of bool
| ConstInt of int32
and binop = LMJ.binop =
| OpAdd
| OpSub
| OpMul
| OpLt
| OpAnd
and unop = LMJ.unop = UOpNot
and instruction =
| IBlock of instruction list
| IIf of expression * instruction * instruction
| IWhile of expression * instruction
| ISyso of expression
| ISetVar of identifier * expression
| IArraySet of identifier * expression * expression
and typ =
| TypInt
| TypBool
| TypIntArray
| Typ of identifier
and metho = {
formals: (identifier * typ) list;
result: typ;
locals: (identifier * typ) list;
body: instruction list;
return: expression
}
and clas = {
extends: identifier option;
attributes: (identifier * typ) list;
methods: (identifier * metho) list
}
and program = {
name: identifier;
defs: (identifier * clas) list;
main_args: identifier;
main: instruction
}