package comby

  1. Overview
  2. Docs
On This Page
  1. Rewrite
Legend:
Library
Module
Module type
Parameter
Class
Class type

Rewrite

Defines rewrite operations.

val all : ?source:string -> ?metasyntax:Matchers.metasyntax -> ?fresh:(unit -> string) -> rewrite_template:string -> match' list -> replacement option

all source metasyntax fresh rewrite_template matches substitutes rewrite_template with each match in matches to create a rewrite result. If source is specified, each rewrite result is substituted in-place in the source. If source is not specified, rewritten matches are newline-separated. If metasyntax is defined, the rewrite template will respect custom metasyntax definitions.

If the rewrite template contains the syntax :id(), then it is substituted with fresh values. fresh may be specified to supply custom fresh values. If not specified, fresh variables are generated in increasing rank starting with 1, and incremented. See substitute for more.

val substitute : ?metasyntax:Matchers.metasyntax -> ?fresh:(unit -> string) -> string -> Match.environment -> string * string list

substitute metasyntax fresh template environment substitutes template with the variable and value pairs in the environment. It returns the result after substitution, and the list of variables in environment that were substituted for. If metasyntax is defined, the rewrite template will respect custom metasyntax definitions.

The syntax :id() is substituted with fresh values. If fresh is not specified, the default behavior substitutes :id() starting with 1, and subsequent :id() values increment the ID. If fresh is set, substitutes the pattern :id() with the value of fresh () as the hole is encountered, left to right.

OCaml

Innovation. Community. Security.