File tree 1 file changed +19
-14
lines changed
1 file changed +19
-14
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ type sexp =
115
115
116
116
let rec format_sexp f s =
117
117
match s with
118
- | Atom s -> Format. fprintf f " %s " s
118
+ | Atom s -> Format. pp_print_string f s
119
119
| List l ->
120
120
let has_comment =
121
121
List. exists l ~f: (function
@@ -124,23 +124,28 @@ let rec format_sexp f s =
124
124
in
125
125
if has_comment
126
126
then (* Ensure comments are on their own line *)
127
- Format. fprintf f " @[<v 2>("
128
- else Format. fprintf f " @[<2>(" ;
129
- Format. pp_print_list ~pp_sep: (fun f () -> Format. fprintf f " @ " ) format_sexp f l;
127
+ Format. pp_open_vbox f 2
128
+ else Format. pp_open_box f 2 ;
129
+ Format. pp_print_string f " (" ;
130
+ Format. pp_print_list
131
+ ~pp_sep: (fun f () -> Format. pp_print_space f () )
132
+ format_sexp
133
+ f
134
+ l;
130
135
if
131
136
has_comment
132
- && List. fold_left
133
- ~f: (fun _ i ->
134
- match i with
135
- | Comment _ -> true
136
- | _ -> false )
137
- ~init: false
138
- l
137
+ &&
138
+ match List. last l with
139
+ | Some (Comment _ ) -> true
140
+ | Some _ | None -> false
139
141
then
140
142
(* Make sure there is a newline when a comment is at the very end. *)
141
- Format. fprintf f " @ " ;
142
- Format. fprintf f " )@]"
143
- | Comment s -> Format. fprintf f " ;;%s" s
143
+ Format. pp_print_space f () ;
144
+ Format. pp_print_string f " )" ;
145
+ Format. pp_close_box f ()
146
+ | Comment s ->
147
+ Format. pp_print_string f " ;;" ;
148
+ Format. pp_print_string f s
144
149
145
150
let index tbl x = Atom (" $" ^ Code.Var.Hashtbl. find tbl x)
146
151
You can’t perform that action at this time.
0 commit comments