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:metasyntax -> ?external_handler:External.t -> ?fresh:(unit -> string) -> ?filepath:string -> rewrite_template:string -> match' list -> replacement option

all source metasyntax external 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:metasyntax -> ?external_handler:External.t -> ?fresh:(unit -> string) -> ?filepath:string -> string -> Match.environment -> string

substitute metasyntax external fresh template environment substitutes template with the variable and value pairs in the environment. It returns the result after substitution. 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. An experimental external callback is a general callback for handling external properties in the rewrite template.