package comby

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

Match

A match is a result of matching a template pattern in an input source.

A match comprises: (1) an environment of metavariables to values, where values have an associated range. (2) the entire string matched by a match template. (3) the range of the entire matched string.

module Location : sig ... end
type location = Location.t
val equal_location : location -> location -> Ppx_deriving_runtime.bool
val sexp_of_location : location -> Ppx_sexp_conv_lib.Sexp.t
val location_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> location
module Range : sig ... end
type range = Range.t
val equal_range : range -> range -> Ppx_deriving_runtime.bool
val sexp_of_range : range -> Ppx_sexp_conv_lib.Sexp.t
val range_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> range
module Environment : sig ... end
type environment = Environment.t
type t = {
  1. range : range;
  2. environment : environment;
  3. matched : string;
}

A match t is: (1) an environment of metavariables to values, where values have an associated range. (2) the entire string matched by a match template. (3) the range of the entire matched string.

val to_yojson : t -> Yojson.Safe.json
val of_yojson : Yojson.Safe.json -> (t, string) Core.Result.t
val create : ?range:range -> unit -> t

create creates a new match with empty range by default.

val convert_offset : fast:bool -> source:string -> t -> t

convert_offset populates line and column information for a source file associated with the match (by default, only the offset is computed matches). For matches fast is an experimental option that uses a binary search to perform the conversion quickly.

val pp : Stdlib.Format.formatter -> (string option * t list) -> unit

pp is a grep-like formatted printer for matches. It accepts a (optional file path * match list)

val pp_json_lines : Stdlib.Format.formatter -> (string option * t list) -> unit

pp is a JSON formatted printer for (optional file path * match list). One line printed per match.

OCaml

Innovation. Community. Security.