Project

General

Profile

Revision 521e2a6b src/printers.ml

View differences:

src/printers.ml
71 71
let rec pp_expr fmt expr =
72 72
  (match expr.expr_annot with 
73 73
  | None -> fprintf fmt "%t" 
74
  | Some ann -> fprintf fmt "(%a %t)" pp_expr_annot ann)
74
  | Some ann -> fprintf fmt "@[(%a %t)@]" pp_expr_annot ann)
75 75
    (fun fmt -> 
76 76
      match expr.expr_desc with
77 77
    | Expr_const c -> pp_const fmt c
78
    | Expr_ident id -> Format.fprintf fmt "%s" id
78
    | Expr_ident id -> fprintf fmt "%s" id
79 79
    | Expr_array a -> fprintf fmt "[%a]" pp_tuple a
80 80
    | Expr_access (a, d) -> fprintf fmt "%a[%a]" pp_expr a Dimension.pp_dimension d
81 81
    | Expr_power (a, d) -> fprintf fmt "(%a^%a)" pp_expr a Dimension.pp_dimension d
82 82
    | Expr_tuple el -> fprintf fmt "(%a)" pp_tuple el
83
    | Expr_ite (c, t, e) -> fprintf fmt "(if %a then %a else %a)" pp_expr c pp_expr t pp_expr e
83
    | Expr_ite (c, t, e) -> fprintf fmt "@[<hov 1>(if %a then@ @[<hov 2>%a@]@ else@ @[<hov 2>%a@]@])" pp_expr c pp_expr t pp_expr e
84 84
    | Expr_arrow (e1, e2) -> fprintf fmt "(%a -> %a)" pp_expr e1 pp_expr e2
85 85
    | Expr_fby (e1, e2) -> fprintf fmt "%a fby %a" pp_expr e1 pp_expr e2
86 86
    | Expr_pre e -> fprintf fmt "pre %a" pp_expr e
......
257 257

  
258 258
let pp_spec fmt spec =
259 259
  fprintf fmt "@[<hov 2>(*@@ ";
260
  fprintf_list ~sep:"@;@@ " (fun fmt r -> fprintf fmt "requires %a;" pp_eexpr r) fmt spec.requires;
261
  fprintf_list ~sep:"@;@@ " (fun fmt r -> fprintf fmt "ensures %a; " pp_eexpr r) fmt spec.ensures;
262
  fprintf_list ~sep:"@;" (fun fmt (name, assumes, ensures, _) -> 
260
  fprintf_list ~sep:"@,@@ " (fun fmt r -> fprintf fmt "requires %a;" pp_eexpr r) fmt spec.requires;
261
  fprintf_list ~sep:"@,@@ " (fun fmt r -> fprintf fmt "ensures %a; " pp_eexpr r) fmt spec.ensures;
262
  fprintf_list ~sep:"@," (fun fmt (name, assumes, ensures, _) -> 
263 263
    fprintf fmt "behavior %s:@[@ %a@ %a@]" 
264 264
      name
265 265
      (fprintf_list ~sep:"@ " (fun fmt r -> fprintf fmt "assumes %a;" pp_eexpr r)) assumes
......
281 281
  | _ -> ()
282 282
    
283 283
let pp_node fmt nd = 
284
fprintf fmt "@[<v 0>%a%t%s %s (%a) returns (%a)@.%a%alet@.@[<h 2>   @ @[<v>%a@ %a@ %a@]@ @]@.tel@]@."
284
fprintf fmt "@[<v 0>%a%t%s %s (%a) returns (%a)@ %a%alet@[<h 2>   @ @[<v>%a@ %a@ %a@]@]@ tel@]@ "
285 285
  (fun fmt s -> match s with Some s -> pp_spec fmt s | _ -> ()) nd.node_spec
286
  (fun fmt -> match nd.node_spec with None -> () | Some _ -> Format.fprintf fmt "@.")
286
  (fun fmt -> match nd.node_spec with None -> () | Some _ -> Format.fprintf fmt "@ ")
287 287
  (if nd.node_dec_stateless then "function" else "node")
288 288
  nd.node_id
289 289
  pp_node_args nd.node_inputs
......
349 349
  | Node _ -> assert false
350 350

  
351 351
let pp_lusi_header fmt basename prog =
352
  fprintf fmt "(* Generated Lustre Interface file from %s.lus *)@." basename;
353
  fprintf fmt "(* by Lustre-C compiler version %s, %a *)@." Version.number pp_date (Unix.gmtime (Unix.time ()));
354
  fprintf fmt "(* Feel free to mask some of the definitions by removing them from this file. *)@.@.";
355
  List.iter (fprintf fmt "%a@." pp_lusi) prog    
352
  fprintf fmt "@[<v 0>";
353
  fprintf fmt "(* Generated Lustre Interface file from %s.lus *)@ " basename;
354
  fprintf fmt "(* by Lustre-C compiler version %s, %a *)@ " Version.number pp_date (Unix.gmtime (Unix.time ()));
355
  fprintf fmt "(* Feel free to mask some of the definitions by removing them from this file. *)@ @ ";
356
  List.iter (fprintf fmt "%a@ " pp_lusi) prog;
357
  fprintf fmt "@]"
356 358

  
357 359
let pp_offset fmt offset =
358 360
  match offset with

Also available in: Unified diff