Skip to content

Commit

Permalink
v0.17~preview.128.37+01
Browse files Browse the repository at this point in the history
  • Loading branch information
public-release committed Aug 30, 2023
1 parent da11afa commit d8e550c
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 46 deletions.
1 change: 1 addition & 0 deletions .ocamlformat
@@ -0,0 +1 @@
profile=janestreet
14 changes: 7 additions & 7 deletions bench/bench_record.ml
Expand Up @@ -63,13 +63,13 @@ let t_of_sexp =
; kind = Required
; conv =
(fun sexp ->
{ h =
list_of_sexp
(Sexplib0.Sexp_conv_error
.record_poly_field_value
"Record.t")
sexp
})
{ h =
list_of_sexp
(Sexplib0.Sexp_conv_error
.record_poly_field_value
"Record.t")
sexp
})
; rest = Empty
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/sexp.ml
Expand Up @@ -82,12 +82,12 @@ module Printing = struct
let n = ref 0 in
for i = 0 to String.length s - 1 do
n
:= !n
+
match String.unsafe_get s i with
| '\"' | '\\' | '\n' | '\t' | '\r' | '\b' -> 2
| ' ' .. '~' -> 1
| _ -> 4
:= !n
+
match String.unsafe_get s i with
| '\"' | '\\' | '\n' | '\t' | '\r' | '\b' -> 2
| ' ' .. '~' -> 1
| _ -> 4
done;
if !n = String.length s
then s
Expand Down Expand Up @@ -321,8 +321,8 @@ module Printing = struct
let to_string_hum ?indent = function
| Atom str
when match index_of_newline str 0 with
| None -> true
| Some _ -> false -> mach_maybe_esc_str str
| None -> true
| Some _ -> false -> mach_maybe_esc_str str
| sexp ->
let buf = buffer () in
to_buffer_hum ?indent sexp ~buf;
Expand Down
8 changes: 4 additions & 4 deletions src/sexp_conv.ml
Expand Up @@ -90,11 +90,11 @@ module Exn_converter = struct
end

module Exn_table = Ephemeron.K1.Make (struct
type t = extension_constructor
type t = extension_constructor

let equal = ( == )
let hash = Obj.Extension_constructor.id
end)
let equal = ( == )
let hash = Obj.Extension_constructor.id
end)

let the_exn_table : Registration.t Exn_table.t = Exn_table.create 17

Expand Down
1 change: 0 additions & 1 deletion src/sexp_conv.mli
Expand Up @@ -277,7 +277,6 @@ module Exn_converter : sig
-> (exn -> Sexp.t)
-> unit


module For_unit_tests_only : sig
val size : unit -> int
end
Expand Down
14 changes: 7 additions & 7 deletions src/sexp_conv_record.ml
Expand Up @@ -264,13 +264,13 @@ let parse_record_fast ~fields ~index ~extra sexps =
(* Entry points. *)

let record_of_sexps
~caller
~context
~fields
~index_of_field
~allow_extra_fields
~create
sexps
~caller
~context
~fields
~index_of_field
~allow_extra_fields
~create
sexps
=
let allow_extra_fields =
allow_extra_fields || not !Sexp_conv.record_check_extra_fields
Expand Down
14 changes: 7 additions & 7 deletions src/sexp_grammar.ml
Expand Up @@ -29,12 +29,12 @@ type grammar =
| Variant of variant (** accepts clauses keyed by a leading or sole atom *)
| Union of grammar list (** accepts a sexp if any of the listed grammars accepts it *)
| Tagged of grammar with_tag
(** annotates a grammar with a client-specific key/value pair *)
(** annotates a grammar with a client-specific key/value pair *)
| Tyvar of string
(** Name of a type variable, e.g. [Tyvar "a"] for ['a]. Only meaningful when the body of
(** Name of a type variable, e.g. [Tyvar "a"] for ['a]. Only meaningful when the body of
the innermost enclosing [defn] defines a corresponding type variable. *)
| Tycon of string * grammar list * defn list
(** Type constructor applied to arguments, and its definition.
(** Type constructor applied to arguments, and its definition.
For example, writing [Tycon ("tree", [ Integer ], defns)] represents [int tree], for
whatever [tree] is defined as in [defns]. The following defines [tree] as a binary
Expand Down Expand Up @@ -92,18 +92,18 @@ type grammar =
This transformation exposes the structure of a grammar with recursive references,
while preserving the meaning of recursively-defined elements. *)
| Recursive of string * grammar list
(** Type constructor applied to arguments. Used to denote recursive type references.
(** Type constructor applied to arguments. Used to denote recursive type references.
Only meaningful when used inside the [defn]s of a [Tycon] grammar, to refer to a
type constructor in the nearest enclosing [defn] list. *)
| Lazy of grammar lazy_t
(** Lazily computed grammar. Use [Lazy] to avoid top-level side effects. To define
(** Lazily computed grammar. Use [Lazy] to avoid top-level side effects. To define
recursive grammars, use [Recursive] instead. *)

(** Grammar of a list of sexps. *)
and list_grammar =
| Empty (** accepts an empty list of sexps *)
| Cons of grammar * list_grammar
(** accepts a non-empty list with head and tail matching the given grammars *)
(** accepts a non-empty list with head and tail matching the given grammars *)
| Many of grammar (** accepts zero or more sexps, each matching the given grammar *)
| Fields of record (** accepts sexps representing fields of a record *)

Expand All @@ -112,7 +112,7 @@ and case_sensitivity =
| Case_insensitive (** Comparison is case insensitive. Used for custom parsers. *)
| Case_sensitive (** Comparison is case sensitive. Used for polymorphic variants. *)
| Case_sensitive_except_first_character
(** Comparison is case insensitive for the first character and case sensitive afterward.
(** Comparison is case insensitive for the first character and case sensitive afterward.
Used for regular variants. *)

(** Grammar of variants. Accepts any sexp matching one of the clauses. *)
Expand Down
24 changes: 12 additions & 12 deletions test/sexplib0_test.ml
Expand Up @@ -379,24 +379,24 @@ let%expect_test "record with polymorphic fields" =
; kind = Required
; conv =
(fun sexp ->
{ a =
list_of_sexp
(Sexplib.Conv_error.record_poly_field_value caller)
sexp
})
{ a =
list_of_sexp
(Sexplib.Conv_error.record_poly_field_value caller)
sexp
})
; rest =
Field
{ name = "b"
; kind = Required
; conv =
(fun sexp ->
{ b =
Option.t_of_sexp
(Result.t_of_sexp
(Sexplib.Conv_error.record_poly_field_value caller)
(Sexplib.Conv_error.record_poly_field_value caller))
sexp
})
{ b =
Option.t_of_sexp
(Result.t_of_sexp
(Sexplib.Conv_error.record_poly_field_value caller)
(Sexplib.Conv_error.record_poly_field_value caller))
sexp
})
; rest = Empty
}
})
Expand Down

0 comments on commit d8e550c

Please sign in to comment.