1
|
(********************************************************************)
|
2
|
(* *)
|
3
|
(* The LustreC compiler toolset / The LustreC Development Team *)
|
4
|
(* Copyright 2012 - -- ONERA - CNRS - INPT *)
|
5
|
(* *)
|
6
|
(* LustreC is free software, distributed WITHOUT ANY WARRANTY *)
|
7
|
(* under the terms of the GNU Lesser General Public License *)
|
8
|
(* version 2.1. *)
|
9
|
(* *)
|
10
|
(********************************************************************)
|
11
|
|
12
|
type ident = Utils.ident
|
13
|
type rat = Utils.rat
|
14
|
type tag = Utils.tag
|
15
|
type label = Utils.ident
|
16
|
|
17
|
type type_dec =
|
18
|
{ty_dec_desc: type_dec_desc;
|
19
|
ty_dec_loc: Location.t}
|
20
|
|
21
|
and type_dec_desc =
|
22
|
| Tydec_any
|
23
|
| Tydec_int
|
24
|
| Tydec_real
|
25
|
(* | Tydec_float *)
|
26
|
| Tydec_bool
|
27
|
| Tydec_clock of type_dec_desc
|
28
|
| Tydec_const of ident
|
29
|
| Tydec_enum of ident list
|
30
|
| Tydec_struct of (ident * type_dec_desc) list
|
31
|
| Tydec_array of Dimension.dim_expr * type_dec_desc
|
32
|
|
33
|
type typedec_desc =
|
34
|
{tydec_id: ident}
|
35
|
|
36
|
type typedef_desc =
|
37
|
{tydef_id: ident;
|
38
|
tydef_desc: type_dec_desc}
|
39
|
|
40
|
type clock_dec =
|
41
|
{ck_dec_desc: clock_dec_desc;
|
42
|
ck_dec_loc: Location.t}
|
43
|
|
44
|
and clock_dec_desc =
|
45
|
| Ckdec_any
|
46
|
| Ckdec_bool of (ident * ident) list
|
47
|
|
48
|
|
49
|
type constant =
|
50
|
| Const_int of int
|
51
|
| Const_real of Num.num * int * string (* (a, b, c) means a * 10^-b. c is the original string *)
|
52
|
| Const_array of constant list
|
53
|
| Const_tag of label
|
54
|
| Const_string of string (* used only for annotations *)
|
55
|
| Const_modeid of string (* used only for annotations *)
|
56
|
| Const_struct of (label * constant) list
|
57
|
|
58
|
type quantifier_type = Exists | Forall
|
59
|
|
60
|
type var_decl =
|
61
|
{var_id: ident;
|
62
|
var_orig:bool;
|
63
|
var_dec_type: type_dec;
|
64
|
var_dec_clock: clock_dec;
|
65
|
var_dec_const: bool;
|
66
|
var_dec_value: expr option;
|
67
|
mutable var_parent_nodeid: ident option;
|
68
|
mutable var_type: Types.type_expr;
|
69
|
mutable var_clock: Clocks.clock_expr;
|
70
|
var_loc: Location.t}
|
71
|
|
72
|
(** The core language and its ast. Every element of the ast contains its
|
73
|
location in the program text. The type and clock of an ast element
|
74
|
is mutable (and initialized to dummy values). This avoids to have to
|
75
|
duplicate ast structures (e.g. ast, typed_ast, clocked_ast). *)
|
76
|
|
77
|
|
78
|
|
79
|
(* The tag of an expression is a unique identifier used to distinguish
|
80
|
different instances of the same node *)
|
81
|
and expr =
|
82
|
{expr_tag: tag;
|
83
|
expr_desc: expr_desc;
|
84
|
mutable expr_type: Types.type_expr;
|
85
|
mutable expr_clock: Clocks.clock_expr;
|
86
|
mutable expr_delay: Delay.delay_expr;
|
87
|
mutable expr_annot: expr_annot option;
|
88
|
expr_loc: Location.t}
|
89
|
|
90
|
and expr_desc =
|
91
|
| Expr_const of constant
|
92
|
| Expr_ident of ident
|
93
|
| Expr_tuple of expr list
|
94
|
| Expr_ite of expr * expr * expr
|
95
|
| Expr_arrow of expr * expr
|
96
|
| Expr_fby of expr * expr
|
97
|
| Expr_array of expr list
|
98
|
| Expr_access of expr * Dimension.dim_expr
|
99
|
| Expr_power of expr * Dimension.dim_expr
|
100
|
| Expr_pre of expr
|
101
|
| Expr_when of expr * ident * label
|
102
|
| Expr_merge of ident * (label * expr) list
|
103
|
| Expr_appl of call_t
|
104
|
|
105
|
and call_t = ident * expr * expr option
|
106
|
(* The third part denotes the boolean condition for resetting *)
|
107
|
|
108
|
and eq =
|
109
|
{eq_lhs: ident list;
|
110
|
eq_rhs: expr;
|
111
|
eq_loc: Location.t}
|
112
|
|
113
|
(* The tag of an expression is a unique identifier used to distinguish
|
114
|
different instances of the same node *)
|
115
|
and eexpr =
|
116
|
{eexpr_tag: tag;
|
117
|
eexpr_qfexpr: expr;
|
118
|
eexpr_quantifiers: (quantifier_type * var_decl list) list;
|
119
|
eexpr_name: string option;
|
120
|
mutable eexpr_type: Types.type_expr;
|
121
|
mutable eexpr_clock: Clocks.clock_expr;
|
122
|
(* mutable eexpr_normalized: (var_decl * eq list * var_decl list) option; *)
|
123
|
eexpr_loc: Location.t}
|
124
|
|
125
|
and expr_annot =
|
126
|
{annots: (string list * eexpr) list;
|
127
|
annot_loc: Location.t}
|
128
|
|
129
|
type contract_mode =
|
130
|
{ mode_id: ident; require: eexpr list; ensure: eexpr list; mode_loc: Location.t}
|
131
|
|
132
|
type contract_import =
|
133
|
{ import_nodeid: ident;
|
134
|
inputs: expr;
|
135
|
outputs: expr;
|
136
|
import_loc: Location.t }
|
137
|
|
138
|
|
139
|
|
140
|
type offset =
|
141
|
| Index of Dimension.dim_expr
|
142
|
| Field of label
|
143
|
|
144
|
type assert_t =
|
145
|
{
|
146
|
assert_expr: expr;
|
147
|
assert_loc: Location.t;
|
148
|
}
|
149
|
|
150
|
type statement =
|
151
|
| Eq of eq
|
152
|
| Aut of automata_desc
|
153
|
|
154
|
and automata_desc =
|
155
|
{aut_id : ident;
|
156
|
aut_handlers: handler_desc list;
|
157
|
aut_loc: Location.t}
|
158
|
|
159
|
and handler_desc =
|
160
|
{hand_state: ident;
|
161
|
hand_unless: (Location.t * expr * bool * ident) list;
|
162
|
hand_until: (Location.t * expr * bool * ident) list;
|
163
|
hand_locals: var_decl list;
|
164
|
hand_stmts: statement list;
|
165
|
hand_asserts: assert_t list;
|
166
|
hand_annots: expr_annot list;
|
167
|
hand_loc: Location.t}
|
168
|
|
169
|
type contract_desc =
|
170
|
{
|
171
|
consts: var_decl list;
|
172
|
locals: var_decl list;
|
173
|
stmts: statement list;
|
174
|
assume: eexpr list;
|
175
|
guarantees: eexpr list;
|
176
|
modes: contract_mode list;
|
177
|
imports: contract_import list;
|
178
|
spec_loc: Location.t;
|
179
|
}
|
180
|
|
181
|
type node_spec_t = Contract of contract_desc
|
182
|
| NodeSpec of ident
|
183
|
|
184
|
type node_desc =
|
185
|
{node_id: ident;
|
186
|
mutable node_type: Types.type_expr;
|
187
|
mutable node_clock: Clocks.clock_expr;
|
188
|
node_inputs: var_decl list;
|
189
|
node_outputs: var_decl list;
|
190
|
node_locals: var_decl list;
|
191
|
mutable node_gencalls: expr list;
|
192
|
mutable node_checks: Dimension.dim_expr list;
|
193
|
node_asserts: assert_t list;
|
194
|
node_stmts: statement list;
|
195
|
mutable node_dec_stateless: bool;
|
196
|
mutable node_stateless: bool option;
|
197
|
node_spec: node_spec_t option;
|
198
|
node_annot: expr_annot list;
|
199
|
node_iscontract: bool;
|
200
|
}
|
201
|
|
202
|
type imported_node_desc =
|
203
|
{nodei_id: ident;
|
204
|
mutable nodei_type: Types.type_expr;
|
205
|
mutable nodei_clock: Clocks.clock_expr;
|
206
|
nodei_inputs: var_decl list;
|
207
|
nodei_outputs: var_decl list;
|
208
|
nodei_stateless: bool;
|
209
|
nodei_spec: node_spec_t option;
|
210
|
(* nodei_annot: expr_annot list; *)
|
211
|
nodei_prototype: string option;
|
212
|
nodei_in_lib: string list;
|
213
|
}
|
214
|
|
215
|
type const_desc =
|
216
|
{const_id: ident;
|
217
|
const_loc: Location.t;
|
218
|
const_value: constant;
|
219
|
mutable const_type: Types.type_expr;
|
220
|
}
|
221
|
|
222
|
|
223
|
type top_decl_desc =
|
224
|
| Node of node_desc
|
225
|
| Const of const_desc
|
226
|
| ImportedNode of imported_node_desc
|
227
|
| Open of bool * string (* the boolean set to true denotes a local
|
228
|
lusi vs a lusi installed at system level *)
|
229
|
| Include of string (* the boolean set to true denotes a local
|
230
|
lus vs a lus installed at system level *)
|
231
|
| TypeDef of typedef_desc
|
232
|
|
233
|
type top_decl =
|
234
|
{top_decl_desc: top_decl_desc; (* description of the symbol *)
|
235
|
top_decl_owner: Location.filename; (* the module where it is defined *)
|
236
|
top_decl_itf: bool; (* header or source file ? *)
|
237
|
top_decl_loc: Location.t} (* the location where it is defined *)
|
238
|
|
239
|
type program_t = top_decl list
|
240
|
|
241
|
type dep_t = {
|
242
|
local: bool;
|
243
|
name: ident;
|
244
|
content: program_t;
|
245
|
is_stateful: bool
|
246
|
}
|
247
|
|
248
|
type spec_types =
|
249
|
| LocalContract of contract_desc
|
250
|
| TopContract of top_decl list
|
251
|
|
252
|
|
253
|
|
254
|
(* Local Variables: *)
|
255
|
(* compile-command:"make -C .." *)
|
256
|
(* End: *)
|