42 |
42 |
let mkdim_appl f args = mkdim_appl (Location.symbol_rloc ()) f args
|
43 |
43 |
let mkdim_ite i t e = mkdim_ite (Location.symbol_rloc ()) i t e
|
44 |
44 |
|
45 |
|
let add_node own msg hashtbl name value =
|
|
45 |
let add_node loc own msg hashtbl name value =
|
46 |
46 |
try
|
47 |
47 |
match (Hashtbl.find hashtbl name).top_decl_desc, value.top_decl_desc with
|
48 |
|
| Node _ , ImportedNode _ when own
|
49 |
|
-> ()
|
50 |
|
| ImportedNode _, _ ->
|
51 |
|
Hashtbl.add hashtbl name value
|
52 |
|
| Node _ , _ ->
|
53 |
|
raise (Corelang.Error (Location.symbol_rloc (), Corelang.Already_bound_symbol msg))
|
54 |
|
| _ -> assert false
|
|
48 |
| Node _ , ImportedNode _ when own -> ()
|
|
49 |
| ImportedNode _, _ -> Hashtbl.add hashtbl name value
|
|
50 |
| Node _ , _ -> raise (Corelang.Error (loc, Corelang.Already_bound_symbol msg))
|
|
51 |
| _ -> assert false
|
55 |
52 |
with
|
56 |
|
Not_found ->
|
57 |
|
Hashtbl.add hashtbl name value
|
|
53 |
Not_found -> Hashtbl.add hashtbl name value
|
58 |
54 |
|
59 |
|
let add_symbol msg hashtbl name value =
|
|
55 |
|
|
56 |
let add_symbol loc msg hashtbl name value =
|
60 |
57 |
if Hashtbl.mem hashtbl name
|
61 |
|
then raise (Corelang.Error (Location.symbol_rloc (), Corelang.Already_bound_symbol msg))
|
|
58 |
then raise (Corelang.Error (loc, Corelang.Already_bound_symbol msg))
|
62 |
59 |
else Hashtbl.add hashtbl name value
|
63 |
60 |
|
64 |
|
let check_symbol msg hashtbl name =
|
|
61 |
let check_symbol loc msg hashtbl name =
|
65 |
62 |
if not (Hashtbl.mem hashtbl name)
|
66 |
|
then raise (Corelang.Error (Location.symbol_rloc (), Corelang.Unbound_symbol msg))
|
|
63 |
then raise (Corelang.Error (loc, Corelang.Unbound_symbol msg))
|
67 |
64 |
else ()
|
68 |
65 |
|
69 |
66 |
%}
|
... | ... | |
90 |
87 |
%token MULT DIV MOD
|
91 |
88 |
%token MINUS PLUS UMINUS
|
92 |
89 |
%token PRE ARROW
|
93 |
|
%token PROTOTYPE IN
|
|
90 |
%token PROTOTYPE LIB
|
94 |
91 |
%token EOF
|
95 |
92 |
|
96 |
93 |
%nonassoc COMMA
|
... | ... | |
148 |
145 |
| NODE { false }
|
149 |
146 |
|
150 |
147 |
top_decl_header:
|
151 |
|
| CONST cdecl_list { fun _ -> mktop_decl (Consts (List.rev $2)) }
|
|
148 |
| CONST cdecl_list { let top = mktop_decl (Consts (List.rev $2)) in fun _ -> top }
|
152 |
149 |
| nodespec_list state_annot IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR prototype_opt in_lib_opt SCOL
|
153 |
150 |
{let nd = mktop_decl (ImportedNode
|
154 |
151 |
{nodei_id = $3;
|
... | ... | |
161 |
158 |
nodei_prototype = $13;
|
162 |
159 |
nodei_in_lib = $14;})
|
163 |
160 |
in
|
164 |
|
(fun own -> add_node own ("node " ^ $3) node_table $3 nd; nd) }
|
|
161 |
(let loc = Location.symbol_rloc () in
|
|
162 |
fun own -> add_node loc own ("node " ^ $3) node_table $3 nd; nd) }
|
165 |
163 |
|
166 |
164 |
prototype_opt:
|
167 |
165 |
{ None }
|
... | ... | |
169 |
167 |
|
170 |
168 |
in_lib_opt:
|
171 |
169 |
{ None }
|
172 |
|
| IN IDENT {Some $2}
|
|
170 |
| LIB IDENT {Some $2}
|
173 |
171 |
|
174 |
172 |
top_decl:
|
175 |
173 |
| CONST cdecl_list { mktop_decl (Consts (List.rev $2)) }
|
... | ... | |
190 |
188 |
node_stateless = None;
|
191 |
189 |
node_spec = $1;
|
192 |
190 |
node_annot = match annots with [] -> None | _ -> Some annots})
|
193 |
|
in
|
194 |
|
add_node true ("node " ^ $3) node_table $3 nd; nd}
|
|
191 |
in
|
|
192 |
let loc = Location.symbol_rloc () in
|
|
193 |
add_node loc true ("node " ^ $3) node_table $3 nd; nd}
|
195 |
194 |
|
196 |
195 |
nodespec_list:
|
197 |
196 |
{ None }
|
... | ... | |
204 |
203 |
typ_def:
|
205 |
204 |
TYPE IDENT EQ typeconst {
|
206 |
205 |
try
|
207 |
|
add_symbol ("type " ^ $2) type_table (Tydec_const $2) (Corelang.get_repr_type $4)
|
|
206 |
let loc = Location.symbol_rloc () in
|
|
207 |
add_symbol loc ("type " ^ $2) type_table (Tydec_const $2) (Corelang.get_repr_type $4)
|
208 |
208 |
with Not_found-> assert false }
|
209 |
209 |
| TYPE IDENT EQ ENUM LCUR tag_list RCUR { Hashtbl.add type_table (Tydec_const $2) (Tydec_enum ($6 (Tydec_const $2))) }
|
210 |
210 |
| TYPE IDENT EQ STRUCT LCUR field_list RCUR { Hashtbl.add type_table (Tydec_const $2) (Tydec_struct ($6 (Tydec_const $2))) }
|
... | ... | |
218 |
218 |
| TBOOL array_typ_decl { $2 Tydec_bool }
|
219 |
219 |
| TREAL array_typ_decl { $2 Tydec_real }
|
220 |
220 |
| TFLOAT array_typ_decl { $2 Tydec_float }
|
221 |
|
| IDENT array_typ_decl { check_symbol ("type " ^ $1) type_table (Tydec_const $1); $2 (Tydec_const $1) }
|
|
221 |
| IDENT array_typ_decl {
|
|
222 |
let loc = Location.symbol_rloc () in
|
|
223 |
check_symbol loc ("type " ^ $1) type_table (Tydec_const $1); $2 (Tydec_const $1) }
|
222 |
224 |
| TBOOL TCLOCK { Tydec_clock Tydec_bool }
|
223 |
225 |
| IDENT TCLOCK { Tydec_clock (Tydec_const $1) }
|
224 |
226 |
|
225 |
227 |
tag_list:
|
226 |
228 |
IDENT
|
227 |
|
{ (fun t -> add_symbol ("tag " ^ $1) tag_table $1 t; $1 :: []) }
|
|
229 |
{ let loc = Location.symbol_rloc () in
|
|
230 |
(fun t ->
|
|
231 |
add_symbol loc ("tag " ^ $1) tag_table $1 t; $1 :: []) }
|
228 |
232 |
| tag_list COMMA IDENT
|
229 |
|
{ (fun t -> add_symbol ("tag " ^ $3)tag_table $3 t; $3 :: ($1 t)) }
|
230 |
|
|
|
233 |
{
|
|
234 |
let loc = Location.symbol_rloc () in
|
|
235 |
(fun t -> add_symbol loc ("tag " ^ $3)tag_table $3 t; $3 :: ($1 t))
|
|
236 |
}
|
|
237 |
|
231 |
238 |
field_list:
|
232 |
239 |
{ (fun t -> []) }
|
233 |
240 |
| field_list IDENT COL typeconst SCOL
|
234 |
|
{ (fun t -> add_symbol ("field " ^ $2) field_table $2 t; ($1 t) @ [ ($2, $4) ]) }
|
235 |
|
|
|
241 |
{
|
|
242 |
let loc = Location.symbol_rloc () in
|
|
243 |
(fun t -> add_symbol loc ("field " ^ $2) field_table $2 t; ($1 t) @ [ ($2, $4) ]) }
|
|
244 |
|
236 |
245 |
eq_list:
|
237 |
246 |
{ [], [], [] }
|
238 |
247 |
| eq eq_list {let eql, assertl, annotl = $2 in ($1::eql), assertl, annotl}
|
Solved bug:
- loading lusi
- loading lib in lusi files: "in m" is now "lib m"
git-svn-id: https://cavale.enseeiht.fr/svn/lustrec/lustre_compiler/trunk@247 041b043f-8d7c-46b2-b46e-ef0dd855326e