package sexp
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=bde6acfd2814bcc38a0d3cacb42e513d8932595152dd9798419559fb0e026f4e
doc/sexp.sexp_app_pattern/Sexp_app_pattern/Output_method/Wrap_mode/index.html
Module Output_method.Wrap_mode
Source
type 'capture t =
| Wrap_always : Core.Sexp.t t
| Wrap_non_singletons : Core.Sexp.t t
| 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.