-
Notifications
You must be signed in to change notification settings - Fork 0
/
TMJ.mli
73 lines (62 loc) · 1.64 KB
/
TMJ.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
65
66
67
68
69
70
71
72
73
(** 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 = { raw_expression : raw_expression; typ : typ }
and raw_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
| EInc of identifier
| EDec of identifier
and constant = LMJ.constant =
| ConstBool of bool
| ConstInt of int32
| ConstString of string
and binop = LMJ.binop =
| OpAdd
| OpSub
| OpMul
| OpLt
| OpAnd
| OpEq
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 * typ * expression
| IArraySet of identifier * expression * expression
| IExpr of expression
| IExprM of expression
and typ =
| TypInt
| TypBool
| TypString
| 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
}