blob: 29a62932ec748f03de24793909877484d3ec4eea (
plain) (
blame)
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
|
(* Syntaxe abstraite pour mini-C++ *)
(* rien à voir pour l'instant *)
type ident = string
type binop =
| Equal | NotEqual
| Lt | Le | Gt | Ge
| Add | Sub | Mul | Div | Modulo
| Land | Lor
type unop =
| PreIncr | PostIncr | PreDecr | PostDecr
| Ref | Deref
| Not
| Minus | Plus
type expr =
| EBinop of expr * binop * expr
| EUnary of unop * expr
| EAssign of expr * expr
| EIntConst of int
| EBoolConst of bool
| EThis
| ENull
| EMem of expr * ident
and str_expr =
| SEExpr of expr
| SEStr of string
and instr =
| IEmpty
| IExpr of expr
| IIf of expr * instr * instr
| IWhile of expr * instr
| IFor of expr list * expr option * expr list * instr
| IBlock of block
| IStdCoutWrite of str_expr list
| IReturn of expr option
| IDeclVar of ty_expr * ident * expr option
| IDeclVarAssignConstruct of ty_expr * ident * ident * expr list
and block = instr list
and ty_expr =
| TVoid
| TInt
| TId of ident
| TPtr of ty_expr
| TRef of ty_expr
and var =
| VId of ident
| VClsMem of ident * ident
type proto =
| PConstructor of constructor_proto
| PFunction of function_proto
and constructor_proto = {
cc_class : ident;
cc_args : arg list;
}
and function_proto = {
f_type : ty_expr;
f_name : var;
f_args : arg list;
}
and arg = {
arg_ty : ty_expr;
arg_name : ident;
}
and var_decl = ty_expr * ident
type cls = {
c_name : ident;
c_supers : ident list;
c_vars : var_decl list;
c_protos : proto list;
}
type program = {
p_classes : cls list;
p_vars : var_decl list;
p_functions : (proto * block) list; (* class methods included in here *)
}
|