Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

lustrec / src / lustreSpec.ml @ 1eda3e78

History | View | Annotate | Download (6.24 KB)

1 b38ffff3 ploc
(********************************************************************)
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 0cbf0839 ploc
open Format
13
14
type ident = Utils.ident
15
type rat = Utils.rat
16
type tag = Utils.tag
17 36454535 ploc
type label = Utils.ident
18 0cbf0839 ploc
19
type type_dec =
20
    {ty_dec_desc: type_dec_desc;
21
     ty_dec_loc: Location.t}
22
23
and type_dec_desc =
24
  | Tydec_any
25
  | Tydec_int
26
  | Tydec_real
27
  | Tydec_float
28
  | Tydec_bool
29
  | Tydec_clock of type_dec_desc
30
  | Tydec_const of ident
31
  | Tydec_enum of ident list
32 6560bb94 xthirioux
  | Tydec_struct of (ident * type_dec_desc) list
33 0cbf0839 ploc
  | Tydec_array of Dimension.dim_expr * type_dec_desc
34
35 70e1006b xthirioux
type typedec_desc =
36
    {tydec_id: ident}
37
38
type typedef_desc =
39
    {tydef_id: ident;
40
     tydef_desc: type_dec_desc}
41 6aeb3388 xthirioux
42 0cbf0839 ploc
type clock_dec =
43
    {ck_dec_desc: clock_dec_desc;
44
     ck_dec_loc: Location.t}
45
46
and clock_dec_desc =
47
  | Ckdec_any
48
  | Ckdec_bool of (ident * ident) list 
49
  | Ckdec_pclock of int * rat
50
51
type var_decl = 
52
    {var_id: ident;
53
     var_dec_type: type_dec;
54
     var_dec_clock: clock_dec;
55
     var_dec_const: bool;
56
     mutable var_type: Types.type_expr;
57
     mutable var_clock: Clocks.clock_expr;
58
     var_loc: Location.t}
59
60 0038002e ploc
(** The core language and its ast. Every element of the ast contains its
61
    location in the program text. The type and clock of an ast element
62
    is mutable (and initialized to dummy values). This avoids to have to
63
    duplicate ast structures (e.g. ast, typed_ast, clocked_ast). *)
64
65
66
type constant =
67
  | Const_int of int
68
  | Const_real of string
69
  | Const_float of float
70
  | Const_array of constant list
71
  | Const_tag of label
72
  | Const_string of string (* used only for annotations *)
73
  | Const_struct of (label * constant) list
74
75
type quantifier_type = Exists | Forall
76
77
78
79 0cbf0839 ploc
(* The tag of an expression is a unique identifier used to distinguish
80
   different instances of the same node *)
81 0038002e ploc
type 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 70e1006b xthirioux
105
and call_t = ident * expr * (ident * label) option 
106 0038002e ploc
     (* The third part denotes the reseting clock label and value *)
107 70e1006b xthirioux
108
and eq =
109
    {eq_lhs: ident list;
110
     eq_rhs: expr;
111
     eq_loc: Location.t}
112
113 0038002e ploc
  (* The tag of an expression is a unique identifier used to distinguish
114
     different instances of the same node *)
115 70e1006b xthirioux
and  eexpr =
116 0cbf0839 ploc
    {eexpr_tag: tag;
117 0038002e ploc
     eexpr_qfexpr: expr;
118
     eexpr_quantifiers: (quantifier_type * var_decl list) list;
119 0cbf0839 ploc
     mutable eexpr_type: Types.type_expr;
120
     mutable eexpr_clock: Clocks.clock_expr;
121 0038002e ploc
     mutable eexpr_normalized: (var_decl * eq list * var_decl list) option;
122 0cbf0839 ploc
     eexpr_loc: Location.t}
123
124 70e1006b xthirioux
and expr_annot =
125
 {annots: (string list * eexpr) list;
126
  annot_loc: Location.t}
127 0cbf0839 ploc
128
type node_annot = {
129
  requires: eexpr list;
130 0038002e ploc
  ensures: eexpr list;
131
  behaviors: (string * eexpr list * eexpr list * Location.t) list;
132
  spec_loc: Location.t;
133 0cbf0839 ploc
}
134 0038002e ploc
type assert_t = 
135
    {
136
      assert_expr: expr;
137 36454535 ploc
      assert_loc: Location.t;
138 1eda3e78 xthirioux
    }
139
140
type statement =
141
| Eq of eq
142
| Aut of automata_desc
143 0038002e ploc
144 1eda3e78 xthirioux
and automata_desc =
145 70e1006b xthirioux
  {aut_id : ident;
146
   aut_handlers: handler_desc list;
147
   aut_loc: Location.t}
148
149
and handler_desc =
150
  {hand_state: ident;
151 29ced7be xthirioux
   hand_unless: (Location.t * expr * bool * ident) list;
152
   hand_until: (Location.t * expr * bool * ident) list;
153 70e1006b xthirioux
   hand_locals: var_decl list;
154 1eda3e78 xthirioux
   hand_stmts: statement list;
155 29ced7be xthirioux
   hand_asserts: assert_t list;
156
   hand_annots: expr_annot list;
157 70e1006b xthirioux
   hand_loc: Location.t}
158
159 0038002e ploc
type node_desc =
160
    {node_id: ident;
161
     mutable node_type: Types.type_expr;
162
     mutable node_clock: Clocks.clock_expr;
163
     node_inputs: var_decl list;
164
     node_outputs: var_decl list;
165
     node_locals: var_decl list;
166
     mutable node_gencalls: expr list;
167
     mutable node_checks: Dimension.dim_expr list;
168
     node_asserts: assert_t list; 
169 1eda3e78 xthirioux
     node_stmts: statement list;
170 0038002e ploc
     mutable node_dec_stateless: bool;
171
     mutable node_stateless: bool option;
172
     node_spec: node_annot option;
173
     node_annot: expr_annot list;
174
    }
175
176
type imported_node_desc =
177
    {nodei_id: ident;
178
     mutable nodei_type: Types.type_expr;
179
     mutable nodei_clock: Clocks.clock_expr;
180
     nodei_inputs: var_decl list;
181
     nodei_outputs: var_decl list;
182
     nodei_stateless: bool;
183
     nodei_spec: node_annot option;
184
     nodei_prototype: string option;
185
     nodei_in_lib: string option;
186
    }
187
188
type const_desc = 
189
    {const_id: ident; 
190
     const_loc: Location.t; 
191
     const_value: constant;      
192
     mutable const_type: Types.type_expr;
193
    }
194
195
type top_decl_desc =
196
| Node of node_desc
197 70e1006b xthirioux
| Const of const_desc
198 0038002e ploc
| ImportedNode of imported_node_desc
199
| Open of bool * string (* the boolean set to true denotes a local 
200
			   lusi vs a lusi installed at system level *)
201 70e1006b xthirioux
| TypeDef of typedef_desc
202 0038002e ploc
203
type top_decl =
204 70e1006b xthirioux
    {top_decl_desc: top_decl_desc;      (* description of the symbol *)
205
     top_decl_owner: Location.filename; (* the module where it is defined *)
206
     top_decl_itf: bool;                (* header or source file ? *)
207
     top_decl_loc: Location.t}          (* the location where it is defined *)
208 0038002e ploc
209
type program = top_decl list
210
211
type error =
212
    Main_not_found
213
  | Main_wrong_kind
214
  | No_main_specified
215
  | Unbound_symbol of ident
216
  | Already_bound_symbol of ident
217 70e1006b xthirioux
  | Unknown_library of ident
218 0cbf0839 ploc
219
(* Local Variables: *)
220
(* compile-command:"make -C .." *)
221
(* End: *)