diff --git a/src/stdune/sexp.ml b/src/stdune/sexp.ml index 2f31ed7a..0f6f27c3 100644 --- a/src/stdune/sexp.ml +++ b/src/stdune/sexp.ml @@ -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 -> diff --git a/src/stdune/sexp.mli b/src/stdune/sexp.mli index 095c1e1f..312b2bae 100644 --- a/src/stdune/sexp.mli +++ b/src/stdune/sexp.mli @@ -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