Revision 89b9e25c
Added by Xavier Thirioux about 8 years ago
src/parser_lustre.mly | ||
---|---|---|
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 = |
|
46 |
try |
|
47 |
match (Hashtbl.find hashtbl name).top_decl_desc, value.top_decl_desc with |
|
48 |
| Node _ , ImportedNode _ when own |
|
49 |
-> |
|
50 |
Hashtbl.add hashtbl name value |
|
51 |
| ImportedNode _, _ -> |
|
52 |
Hashtbl.add hashtbl name value |
|
53 |
| Node _ , _ -> |
|
54 |
raise (Corelang.Error (Corelang.Already_bound_symbol msg, Location.symbol_rloc ())) |
|
55 |
| _ -> assert false |
|
56 |
with |
|
57 |
Not_found -> |
|
58 |
Hashtbl.add hashtbl name value |
|
59 |
|
|
45 | 60 |
let add_symbol msg hashtbl name value = |
46 | 61 |
if Hashtbl.mem hashtbl name |
47 | 62 |
then raise (Corelang.Error (Corelang.Already_bound_symbol msg, Location.symbol_rloc ())) |
... | ... | |
102 | 117 |
%start prog |
103 | 118 |
%type <Corelang.top_decl list> prog |
104 | 119 |
%start header |
105 |
%type <Corelang.top_decl list> header |
|
120 |
%type <bool -> Corelang.top_decl list> header
|
|
106 | 121 |
|
107 | 122 |
%% |
108 | 123 |
|
... | ... | |
110 | 125 |
open_list typ_def_list top_decl_list EOF { $1 @ (List.rev $3) } |
111 | 126 |
|
112 | 127 |
header: |
113 |
open_list typ_def_list top_decl_header_list EOF { $1 @ (List.rev $3) }
|
|
128 |
open_list typ_def_list top_decl_header_list EOF { (fun own -> ($1 @ (List.rev ($3 own)))) }
|
|
114 | 129 |
|
115 | 130 |
open_list: |
116 | 131 |
{ [] } |
... | ... | |
125 | 140 |
|
126 | 141 |
|
127 | 142 |
top_decl_header_list: |
128 |
top_decl_header {[$1]}
|
|
129 |
| top_decl_header_list top_decl_header {$2::$1}
|
|
143 |
top_decl_header {(fun own -> [$1 own]) }
|
|
144 |
| top_decl_header_list top_decl_header {(fun own -> ($2 own)::($1 own)) }
|
|
130 | 145 |
|
131 | 146 |
|
132 | 147 |
top_decl_header: |
... | ... | |
140 | 155 |
nodei_stateless = $12; |
141 | 156 |
nodei_spec = None}) |
142 | 157 |
in |
143 |
add_symbol ("node " ^ $2) node_table $2 nd; nd}
|
|
158 |
(fun own -> add_node own ("node " ^ $2) node_table $2 nd; nd) }
|
|
144 | 159 |
|
145 | 160 |
| nodespec_list NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR stateless_opt SCOL |
146 | 161 |
{let nd = mktop_decl (ImportedNode |
... | ... | |
152 | 167 |
nodei_stateless = $13; |
153 | 168 |
nodei_spec = Some $1}) |
154 | 169 |
in |
155 |
add_symbol ("node " ^ $3) node_table $3 nd; nd}
|
|
170 |
(fun own -> add_node own ("node " ^ $3) node_table $3 nd; nd) }
|
|
156 | 171 |
|
157 | 172 |
| FUNCTION IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL |
158 | 173 |
{let nd = mktop_decl (ImportedNode |
... | ... | |
164 | 179 |
nodei_stateless = true; |
165 | 180 |
nodei_spec = None}) |
166 | 181 |
in |
167 |
add_symbol ("function " ^ $2) node_table $2 nd; nd}
|
|
182 |
(fun own -> add_node own ("function " ^ $2) node_table $2 nd; nd) }
|
|
168 | 183 |
|
169 | 184 |
| nodespec_list FUNCTION IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL |
170 | 185 |
{let nd = mktop_decl (ImportedNode |
... | ... | |
176 | 191 |
nodei_stateless = true; |
177 | 192 |
nodei_spec = Some $1}) |
178 | 193 |
in |
179 |
add_symbol ("function " ^ $3) node_table $3 nd; nd}
|
|
194 |
(fun own -> add_node own ("function " ^ $3) node_table $3 nd; nd) }
|
|
180 | 195 |
|
181 | 196 |
top_decl: |
182 | 197 |
| CONST cdecl_list { mktop_decl (Consts (List.rev $2)) } |
... | ... | |
197 | 212 |
node_spec = None; |
198 | 213 |
node_annot = match annots with [] -> None | _ -> Some annots}) |
199 | 214 |
in |
200 |
add_symbol ("node " ^ $2) node_table $2 nd; nd}
|
|
215 |
add_node true ("node " ^ $2) node_table $2 nd; nd}
|
|
201 | 216 |
|
202 | 217 |
| nodespec_list NODE IDENT LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL_opt locals LET eq_list TEL |
203 | 218 |
{let eqs, asserts, annots = $16 in |
... | ... | |
215 | 230 |
node_spec = Some $1; |
216 | 231 |
node_annot = match annots with [] -> None | _ -> Some annots}) |
217 | 232 |
in |
218 |
add_symbol ("node " ^ $3) node_table $3 nd; nd}
|
|
233 |
add_node true ("node " ^ $3) node_table $3 nd; nd}
|
|
219 | 234 |
|
220 | 235 |
nodespec_list: |
221 | 236 |
NODESPEC { $1 } |
Also available in: Unified diff
corrected bugs in clock generalization that produced pessimistic C code (not wrong though); corrected bug with node importation policy wrt (re)declaration, (re)definition...
git-svn-id: https://cavale.enseeiht.fr/svn/lustrec/lustre_compiler/trunk@194 041b043f-8d7c-46b2-b46e-ef0dd855326e