-
Notifications
You must be signed in to change notification settings - Fork 1
/
ast.mli
97 lines (76 loc) · 2.1 KB
/
ast.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
type position = Lexing.position * Lexing.position
type ident = string
type 'a node = { value: 'a; pos: position }
type const =
| Cbool of bool
| Cint of Int32.t
| Cstring of string
| Cnull
type class_expr =
| CIdent of ident * (class_expr) list
type type_ =
| Tbool
| Tint
| Tvoid
| Tident of class_expr
type unop =
| Uminus
| Unot
type intbinop =
| Add | Sub | Mult | Div | Mod
type bineq =
| Eq | Neq
type intbincmp =
| Lt | Le | Gt | Ge
type boolbinop =
| And | Or
type expr =
| Const of const
| Unop of unop * expr node
(* Opérations séparée pour le typage *)
| Intbinop of intbinop * expr node * expr node
| Bineq of bineq * expr node * expr node
| Intbincmp of intbincmp * expr node * expr node
| Boolbinop of boolbinop * expr node * expr node
(*************************************)
| Instanceof of expr node * class_expr
| Cast of type_ * expr node
(* instr_expr dans la grammaire *)
| Affect of expr node * expr node
| PostIncr of expr node
| PreIncr of expr node
| PostDecr of expr node
| PreDecr of expr node
| New of class_expr * (expr node) list
(********************************)
(* acces dans la grammaire *)
| Ident of ident
| This
| DotAcces of expr node * ident
(***************************)
(* appel dans la grammaire *)
| Appel of expr node * (expr node) list
(***************************)
type bloc = instr list
and instr =
| Nothing
| Iexpr of expr node
| Declaration of type_ * ident * (expr node) option
| If of expr node * instr
| IfElse of expr node * instr * instr
| For of (expr node) option *
(expr node) option *
(expr node) option *
instr
| Bloc of bloc
| Return of (expr node) option
type args = (type_ * ident) list
type decl =
| DeclAtt of type_ * ident
| DeclConst of ident * args * bloc
| DeclMeth of type_ * ident * args * bloc
| DeclNativeMeth of type_ * ident * args
type class_params = ident list
type class_def = ident * class_params * class_expr option * decl list
type class_main = ident node * ident * bloc
type prog = class_def list * class_main