Module V1.EZ_SUBST

type 'context t = 'context -> string -> string

The type for functions performing the translation from ident to its replacement. 'context is some information, that is from the initial call to the substitution.

exception UnclosedExpression of string

The only exception that may be raised by substitutions: it indicates that the end of the expression could not be found, unless ~fail:false is specified.

val string : ?⁠sep:char -> ?⁠sym:bool -> ?⁠fail:bool -> ?⁠escape:bool Stdlib.ref -> ?⁠brace:'context t -> ?⁠paren:'context t -> ?⁠bracket:'context t -> ?⁠var:'context t -> ctxt:'context -> string -> string

string f context s performs substitutions on s following f, passing the context context to f for every expression, returning the result as a string.

val buffer : ?⁠sep:char -> ?⁠sym:bool -> ?⁠fail:bool -> ?⁠escape:bool Stdlib.ref -> ?⁠brace:'context t -> ?⁠paren:'context t -> ?⁠bracket:'context t -> ?⁠var:'context t -> ctxt:'context -> Stdlib.Buffer.t -> string -> unit

buffer f b context s performs substitutions on s following f, passing the context context to f for every expression, returning the result by appending it to the buffer b.

Note that modifications are not atomic, so if an exception is raised during the substitution, the buffer might have been modified.

exception UnknownExpression of string

This exception can be raised by string_from_list if an expression is not found in the list, no default has been specified and fail is true.

val string_from_list : ?⁠sep:char -> ?⁠sym:bool -> ?⁠fail:bool -> ?⁠brace:bool -> ?⁠paren:bool -> ?⁠bracket:bool -> ?⁠var:bool -> ?⁠default:string -> (string * string) list -> string -> string

Substitute expression using a list of associations. A default can be speciifed if an expression is not found in the list. Brace, paren, bracket and var substitutions are all activated by default, and can be deactivated by booleans.