package yuujinchou

  1. Overview
  2. Docs

The Pattern module defines the patterns.

Pattern Type

type path = string list

The type of hierarchical names.

We assume names are hierarchical and can be encoded as lists of strings. For example, the name x.y.z is represented as the following OCaml list:

["x"; "y"; "z"]
type +'hook t

The type of patterns, parametrized by the type of hook labels. See hook.

The pattern type is abstract---you should build a pattern using the following builders and execute it by Action.run.

val equal : ('hook -> 'hook -> bool) -> 'hook t -> 'hook t -> bool

Checking equality.

Pattern Builders

Basics

val any : 'hook t

any keeps the content of the current tree. It is an error if the tree is empty (no name to match).

val only : path -> 'hook t

only path keeps the subtree rooted at path. It is an error if the subtree was empty.

val in_ : path -> 'hook t -> 'hook t

in_ path pattern runs the pattern pat on the subtree rooted at path. Bindings outside the subtree are kept intact. For example, in_ ["x"]any will keep y (if existing), while only["x"] will drop y.

Negation

val none : 'hook t

none drops everything. It is an error if the tree was already empty (nothing to drop).

val except : path -> 'hook t

except p drops the subtree rooted at p. It is an error if there was nothing in the subtree. This is equivalent to in_pnone.

Renaming

val renaming : path -> path -> 'hook t

renaming path path' relocates the subtree rooted at path to path'. It is an error if the subtree was empty (nothing to move).

Sequencing

val seq : 'hook t list -> 'hook t

seq [pat0; pat1; pat2; ...; patn] runs the patterns pat0, pat1, pat2, ..., patn in order.

Union

val union : 'hook t list -> 'hook t

union [pat0; pat1; pat2; ...; patn] calculates the union of the results of individual patterns pat0, pat1, pat2, ..., patn.

Custom Hooks

val hook : 'hook -> 'hook t

hook h applies the hook labelled h to the entire trie; see Action.run_with_hooks.

Utility Functions

val pp_path : Format.formatter -> Pattern.path -> unit

Pretty printer for path.

OCaml

Innovation. Community. Security.