Add Sexp.Of_sexp.capture

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

View File

@ -199,6 +199,12 @@ module Of_sexp = struct
let ctx = Values (Ast.loc sexp, None, context) in
result ctx (t ctx [sexp])
let capture ctx state =
let f t =
result ctx (t ctx state)
in
(f, [])
let end_of_list (Values (loc, cstr, _)) =
match cstr with
| None ->

View File

@ -122,6 +122,9 @@ module Of_sexp : sig
until the end of sequence is reached. *)
val repeat : 'a t -> 'a list t
(** Capture the rest of the input for later parsing *)
val capture : ('a t -> 'a) t
(** [enter t] expect the next element of the input to be a list and
parse its contents with [t]. *)
val enter : 'a t -> 'a t