@@ -18,6 +18,10 @@ let spaces = String.make 1000 ' '
1818let bprint b indent s =
1919 Printf. bprintf b " %s%s\n " (String. sub spaces 0 indent) s
2020
21+ let bprintf b indent fmt =
22+ Printf. kprintf (fun s ->
23+ Printf. bprintf b " %s%s\n " (String. sub spaces 0 indent) s )
24+ fmt
2125
2226let string_of_contract_kind = function
2327 | Contract -> " contract"
@@ -241,12 +245,14 @@ and contract_part b indent ~freeton cp =
241245
242246and type_definition b indent = function
243247 | EnumDefinition (id , id_list ) ->
244- bprint b indent (Format. sprintf " enum %s {" (string_of_ident id));
245- List. iter (fun id ->
246- bprint b (indent + 2 ) (string_of_ident id)) id_list;
248+ bprintf b indent " enum %s {" (string_of_ident id);
249+ List. iteri (fun i id ->
250+ bprintf b (indent + 2 ) " %s%s"
251+ (if i > 0 then " , " else " " )
252+ (string_of_ident id)) id_list;
247253 bprint b indent " }"
248254 | StructDefinition (id , var_decl_list ) ->
249- bprint b indent ( Format. sprintf " struct %s {" (string_of_ident id) );
255+ bprintf b indent " struct %s {" (string_of_ident id);
250256 List. iter (fun s ->
251257 bprint b (indent + 2 ) (string_of_field_declaration s)
252258 ) var_decl_list;
@@ -259,8 +265,8 @@ and variable_definition b indent ~freeton {
259265 var_name; var_type; var_visibility;
260266 var_mutability; var_override; var_init;
261267 var_static } =
262- bprint b indent
263- ( Format. sprintf " %s%s%s%s %s%s%s%s"
268+ bprintf b indent
269+ " %s%s%s%s %s%s%s%s"
264270 (string_of_type var_type)
265271 (if var_static then " static" else " " )
266272 (if freeton then
@@ -286,7 +292,7 @@ and variable_definition b indent ~freeton {
286292 (List. map string_of_longident ol)) ^ " )" )
287293 (match var_init with
288294 | None -> " ;"
289- | Some e -> Format. sprintf " = %s;" (string_of_expression e)))
295+ | Some e -> Format. sprintf " = %s;" (string_of_expression e))
290296
291297and function_definition b indent {
292298 fun_name; fun_params; fun_returns; fun_modifiers; fun_visibility;
0 commit comments