Add Sexp.Of_sexp.set_many

Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
Jeremie Dimino 2018-06-19 14:25:42 +01:00
parent aed6513b05
commit ff46b30a78
2 changed files with 9 additions and 0 deletions

View File

@ -141,6 +141,14 @@ module Of_sexp = struct
| Fields (loc, cstr, uc) ->
t (Fields (loc, cstr, Univ_map.add uc key v)) state
let set_many : type a k. Univ_map.t -> (a, k) parser -> (a, k) parser
= fun map t ctx state ->
match ctx with
| Values (loc, cstr, uc) ->
t (Values (loc, cstr, Univ_map.superpose uc map)) state
| Fields (loc, cstr, uc) ->
t (Fields (loc, cstr, Univ_map.superpose uc map)) state
let loc : type k. k context -> k -> Loc.t * k = fun ctx state ->
match ctx with
| Values (loc, _, _) -> (loc, state)

View File

@ -109,6 +109,7 @@ module Of_sexp : sig
(** Access to the context *)
val get : 'a Univ_map.Key.t -> ('a option, _) parser
val set : 'a Univ_map.Key.t -> 'a -> ('b, 'k) parser -> ('b, 'k) parser
val set_many : Univ_map.t -> ('a, 'k) parser -> ('a, 'k) parser
(** Return the location of the list currently being parsed. *)
val loc : (Loc.t, _) parser