package comby-kernel

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

Metasyntax

Defines the metasyntax recognized in templates and associates the metasyntax with the matching behavior of holes.

type alias = {
  1. pattern : string;
  2. match_template : string;
  3. rule : string option;
}

aliases where a match of the string pattern maps to match_template and rule.

type hole_definition =
  1. | Delimited of string option * string option
  2. | Reserved_identifiers of string list

A hole definition should comprise either a string prefix, suffix, or both which encloses an variable identifier. See example below.

type hole_syntax =
  1. | Hole of Hole.sort * hole_definition
  2. | Regex of string * char * string

Defines syntax definitions for holes. Zero or more Hole sorts, excluding Regex should have an associated hole_definition. The Regex hole must define a prefix, separator, and suffix. See example below.

type t = {
  1. syntax : hole_syntax list;
  2. identifier : string;
  3. aliases : alias list;
}

A metasyntax comprises:

  • identifier where the list of characters are allowed in identifiers. For example, to allow only contiguous capitalized letters as recognized identifiers within some hole syntax, use:

"ABCDEFGHIJKLMNOPQRSTUVWXYZ"

  • syntax with one or more hole definitions. For example, the default metasyntax for the Everything hole is defined as:

Hole (Everything, Delimited (Some ":[", Some "]"))

A Regex hole must define a prefix, separator, and suffix. The current convention is taken to parse Regex holes as:

<prefix><identifier><separator><regular expression><suffix>

A separator is required to syntactically distinguish arbitrary identifier syntax from regular exressions. A suffix is required to syntactically distinguish when to stop parsing a regular expression and resume parsing the rest of the template.

val to_yojson : t -> Yojson.Safe.json
val of_yojson : Yojson.Safe.json -> (t, string) Core_kernel.Result.t
module type S = sig ... end

A module signature for metasyntax to parameterize a matcher

module Default : S

A module representing the default metasyntax

val default_metasyntax : t

The default metasyntax. It is defined as:

let default_syntax = Hole (Everything, Delimited (Some ":[", Some "]")) ; Hole (Expression, Delimited (Some ":[", Some ":e]")) ; Hole (Alphanum, Delimited (Some ":[[", Some "]]")) ; Hole (Non_space, Delimited (Some ":[", Some ".]")) ; Hole (Line, Delimited (Some ":[", Some "\\n]")) ; Hole (Blank, Delimited (Some ":[ ", Some "]")) ; Regex (":[", '~', "]")

let default_identifier = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_"

val json : t -> string

A JSON representation of the metasyntax defintion

val create : t -> (module S)

create definition creates a metasyntax module from a definition

val default : (module S)

default returns the default metasyntax module

OCaml

Innovation. Community. Security.