let mk_cont name cont state = let ws_only = state.pstack.Annot.stack = [] && Buffer.length state.pbuf = 0 in let parse_fun = let used_ref = ref false in fun ~pos ~len str -> if !used_ref then failwith "Sexplib.Sexp: parser continuation called twice" else begin used_ref := true; let max_pos = check_str_bounds name ~pos ~len str in cont state str ~max_pos ~pos end in Cont (ws_only, parse_fun)