Project

General

Profile

« Previous | Next » 

Revision 3b2bd83d

Added by Teme Kahsai about 8 years ago

updating to onera version 30f766a:2016-12-04

View differences:

src/printers.ml
16 16
(* Prints [v] as [pp_fun] would do, but adds a backslash at each end of line,
17 17
   following the C convention for multiple lines macro *)
18 18
let pp_as_c_macro pp_fun fmt v =
19
  let (out, flush, newline, spaces) = pp_get_all_formatter_output_functions fmt () in
20
  let macro_newline () = (out "\\" 0 1; newline ()) in
19
  let formatter_out_funs = pp_get_formatter_out_functions fmt () in
20
  let macro_newline () =
21
    begin
22
      formatter_out_funs.out_string "\\" 0 1;
23
      formatter_out_funs.out_newline ()
24
    end in
21 25
  begin
22
    pp_set_all_formatter_output_functions fmt out flush macro_newline spaces;
26
    pp_set_formatter_out_functions fmt { formatter_out_funs with out_newline = macro_newline };
23 27
    pp_fun fmt v;
24
    pp_set_all_formatter_output_functions fmt out flush newline spaces;
28
    pp_set_formatter_out_functions fmt formatter_out_funs;
25 29
  end
26 30

  
27 31
let rec print_dec_struct_ty_field fmt (label, cty) =
......
30 34
  match (*get_repr_type*) cty with
31 35
  | Tydec_any -> fprintf fmt "Any"
32 36
  | Tydec_int -> fprintf fmt "int"
33
  | Tydec_real 
34
  | Tydec_float -> fprintf fmt "real"
37
  | Tydec_real -> fprintf fmt "real"
35 38
  | Tydec_bool -> fprintf fmt "bool"
36 39
  | Tydec_clock cty' -> fprintf fmt "%a clock" print_dec_ty cty'
37 40
  | Tydec_const c -> fprintf fmt "%s" c
......
57 60
and pp_const fmt c = 
58 61
  match c with
59 62
    | Const_int i -> pp_print_int fmt i
60
    | Const_real r -> pp_print_string fmt r
61
    | Const_float r -> pp_print_float fmt r
63
    | Const_real (c, e, s) -> pp_print_string fmt s (*if e = 0 then pp_print_int fmt c else if e < 0 then Format.fprintf fmt "%ie%i" c (-e) else Format.fprintf fmt "%ie-%i" c e *)
64
    (* | Const_float r -> pp_print_float fmt r *)
62 65
    | Const_tag  t -> pp_print_string fmt t
63 66
    | Const_array ca -> Format.fprintf fmt "[%a]" (Utils.fprintf_list ~sep:"," pp_const) ca
64 67
    | Const_struct fl -> Format.fprintf fmt "{%a }" (Utils.fprintf_list ~sep:" " pp_struct_const_field) fl
......
131 134

  
132 135
and pp_expr_annot fmt expr_ann =
133 136
  let pp_annot fmt (kwds, ee) =
134
    Format.fprintf fmt "(*! %t: %a *)"
137
    Format.fprintf fmt "(*! %t: %a; *)"
135 138
      (fun fmt -> match kwds with | [] -> assert false | [x] -> Format.pp_print_string fmt x | _ -> Format.fprintf fmt "/%a/" (fprintf_list ~sep:"/" Format.pp_print_string) kwds)
136 139
      pp_eexpr ee
137 140
  in
......
205 208
  | Tydec_any -> fprintf fmt "<any>"
206 209
  | Tydec_int -> fprintf fmt "int"
207 210
  | Tydec_real -> fprintf fmt "real"
208
  | Tydec_float -> fprintf fmt "float"
211
  (* | Tydec_float -> fprintf fmt "float" *)
209 212
  | Tydec_bool -> fprintf fmt "bool"
210 213
  | Tydec_clock t -> fprintf fmt "%a clock" pp_var_type_dec_desc t
211 214
  | Tydec_const t -> fprintf fmt "%s" t

Also available in: Unified diff