package sexp

  1. Overview
  2. Docs
type 'capture t =
  1. | Wrap_always : Core.Sexp.t t
  2. | Wrap_non_singletons : Core.Sexp.t t
  3. | Unwrap_always : Core.Sexp.t list t

This controls what happens when a single capture expression consumes multiple sexps during a single match. It specifies whether to wrap them together as a single sexp list or return all the results separately.

For example: "(a %.*)" tries to unwrap exactly one set of parens, match an 'a', and then capture all the sexps that follow that 'a'. Here are the three behaviors.

Wrap_always: (a) -> Sexp.List (* () *) (a b) -> Sexp.List Sexp.Atom b (* (b) *) (a b c) -> Sexp.List Sexp.Atom b; Sexp.Atom c (* (b c) *)

Wrap_non_singletons: (a) -> Sexp.List (* () *) (a b) -> Sexp.Atom b (* b *) (a b c) -> Sexp.List Sexp.Atom b; Sexp.Atom c (* (b c) *)

Unwrap_always: (a) -> (* *) (a b) -> Sexp.Atom b (* b *) (a b c) -> Sexp.Atom b; Sexp.Atom c (* b c *)

This wrapping (or not) occurs before packing the result into whatever format specified by Output_method.t below.

Since Unwrap_always has the possiblity of returning multiple sexps separately, the `capture type for it is a list of sexps instead of a single sexp.

val sexp_of_t : ('capture -> Sexplib0.Sexp.t) -> 'capture t -> Sexplib0.Sexp.t
type some_wrap_mode =
  1. | T : _ t -> some_wrap_mode