Project

General

Profile

Revision 6394042a src/parser_lustre.mly

View differences:

src/parser_lustre.mly
37 37

  
38 38
let mkannots annots = { annots = annots; annot_loc = get_loc () }
39 39

  
40
let node_stack : ident list ref = ref []
41
let debug_calls () = Format.eprintf "call stack: %a@.@?" (Utils.fprintf_list ~sep:", " Format.pp_print_string) !node_stack
42
let push_node nd =  node_stack:= nd :: !node_stack
43
let pop_node () = try node_stack := List.tl !node_stack with _ -> assert false
44
let get_current_node () = try List.hd !node_stack with _ -> assert false
45

  
40 46
%}
41 47

  
42 48
%token <int> INT
......
118 124
  UIDENT { $1 }
119 125
| IDENT  { $1 }
120 126

  
127
node_ident_decl:
128
 node_ident { push_node $1; $1 }
129

  
121 130
vdecl_ident:
122 131
  UIDENT { $1 }
123 132
| IDENT  { $1 }
......
176 185
				  nodei_prototype = $13;
177 186
				  nodei_in_lib = $14;})
178 187
     in
188
     pop_node ();
179 189
     (*add_imported_node $3 nd;*) [nd] }
180 190

  
181 191
prototype_opt:
......
188 198

  
189 199
top_decl:
190 200
| CONST cdecl_list { List.rev ($2 false) }
191
| nodespec_list state_annot node_ident LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL_opt locals LET stmt_list TEL 
192
    {let stmts, asserts, annots = $16 in
193
     let nd = mktop_decl false (Node
194
				  {node_id = $3;
195
				   node_type = Types.new_var ();
196
				   node_clock = Clocks.new_var true;
197
				   node_inputs = List.rev $5;
198
				   node_outputs = List.rev $10;
199
				   node_locals = List.rev $14;
200
				   node_gencalls = [];
201
				   node_checks = [];
202
				   node_asserts = asserts; 
203
				   node_stmts = stmts;
204
				   node_dec_stateless = $2;
205
				   node_stateless = None;
206
				   node_spec = $1;
207
				   node_annot = annots})
208
     in
201
| nodespec_list state_annot node_ident_decl LPAR vdecl_list SCOL_opt RPAR RETURNS LPAR vdecl_list SCOL_opt RPAR SCOL_opt locals LET stmt_list TEL 
202
    {
203
      let stmts, asserts, annots = $16 in
204
      (* Declaring eqs annots *)
205
      List.iter (fun ann -> 
206
	List.iter (fun (key, _) -> 
207
	  Annotations.add_node_ann $3 key
208
	) ann.annots
209
      ) annots;
210
     (* Building the node *)
211
      let nd = mktop_decl false (Node
212
				   {node_id = $3;
213
				    node_type = Types.new_var ();
214
				    node_clock = Clocks.new_var true;
215
				    node_inputs = List.rev $5;
216
				    node_outputs = List.rev $10;
217
				    node_locals = List.rev $14;
218
				    node_gencalls = [];
219
				    node_checks = [];
220
				    node_asserts = asserts; 
221
				    node_stmts = stmts;
222
				    node_dec_stateless = $2;
223
				    node_stateless = None;
224
				    node_spec = $1;
225
				    node_annot = annots})
226
      in
209 227
     (*add_node $3 nd;*) [nd] }
210

  
211
nodespec_list:
228
    
229
 nodespec_list:
212 230
 { None }
213 231
| NODESPEC nodespec_list { 
214 232
  (function 
......
350 368
| IDENT { mkexpr (Expr_ident $1) }
351 369
| tag_ident { mkexpr (Expr_ident $1) (*(Expr_const (Const_tag $1))*) }
352 370
| LPAR ANNOT expr RPAR
353
    {update_expr_annot $3 $2}
371
    {update_expr_annot (get_current_node ()) $3 $2}
354 372
| LPAR expr RPAR
355 373
    {$2}
356 374
| LPAR tuple_expr RPAR

Also available in: Unified diff