Page
Library
Module
Module type
Parameter
Class
Class type
Source
This document fixes the governing-source hierarchy for ecma-regex.
It answers one question for each public surface:
which source governs this behavior first, which sources are secondary, and which parts are intentionally library-defined?
This file is not a test matrix and not a release log. It is the stable boundary that later conformance and evidence documents must use.
When sources overlap, this repository uses the following precedence model.
lastIndex behavior, string-iterator behavior, and RegExp adapter semantics.RegExp.escape governs the escaping helper exposed as Ecma_regex.escape and Ecma_regex.escape_js.pattern and patternProperties are regular-expression searches, not implicit full-string matches. JSON Schema does not replace ECMA-262 as the RegExp semantic source.Corollaries:
The repository is expected to respect the following layered split.
These are governed first by ECMA-262 tables and UCD 16.0.0 source data. They must come from generator tooling and generated runtime source, not from hand-maintained ad hoc runtime lists:
lib/ecma_regex_ucd_tables.ml.Generated cache or matrix outputs are development artifacts. They may be used to reproduce evidence, but they are not public API and are not part of the package surface.
These are governed by ECMA-262 grammar and algorithm prose and must remain explicit in runtime code:
u / v conflict rejection;lastIndex behavior;These are intentionally outside direct normative text:
syntax_error = string as the current public diagnostic representation.option, list, result, or raises invalid_arg for inputs outside documented OCaml preconditions.Library-defined does not mean untested. It means the behavior is judged by the documented OCaml contract and by consistency with the governing runtime semantics, not by one-to-one textual equivalence to a JavaScript host object operation.
Public surface | Governing source | Secondary sources | Library-defined remainder |
|---|---|---|---|
| ECMA-262 RegExp flags | ECMA-262 Unicode mode and UnicodeSets mode constraints | OCaml constructor shape and error-string text |
| ECMA-262 regular-expression literal lexical grammar | ECMA-262 flag grammar | returned OCaml record shape |
| ECMA-262 RegExp grammar and static semantics | UCD 16.0.0 for Unicode property validation |
|
| ECMA-262 matching algorithms | UCD 16.0.0 for Unicode-sensitive matching | UTF-8 convenience input surface and OCaml result shape |
| ECMA-262 search adapter semantics | ECMA-262 UTF-16 index model | direct OCaml function instead of JS method dispatch |
| ECMA-262 match adapter semantics | ECMA-262 global matching and empty-match advancement |
|
| ECMA-262 matchAll adapter semantics | ECMA-262 iterator behavior | eager OCaml list instead of JS iterator object |
| ECMA-262 RegExp split adapter semantics | ECMA-262 captures and | OCaml |
| ECMA-262 RegExp replacement semantics | ECMA-262 replacement-template behavior | string-replacement-only OCaml surface, no functional replacer dispatch |
| ECMA-262 | ECMA-262 syntax character rules | OCaml string input/output shape |
| ECMA-262 ECMAScript String model | Unicode scalar/code-unit distinction | OCaml abstract type and validation error shape |
| ECMA-262 matching over ECMAScript String values | UCD 16.0.0 for Unicode-sensitive behavior | explicit |
| ECMA-262 RegExp adapter semantics over ECMAScript String values | ECMA-262 raw UTF-16 indexing and capture semantics | OCaml records, variants, and list materialization |
| ECMA-262 RegExp instance state model | ECMA-262 global/sticky behavior | explicit mutable OCaml |
| ECMA-262 stateful RegExp operation semantics | ECMA-262 | direct OCaml instance calls instead of JS receiver protocol |
| ECMA-262 RegExp String Iterator behavior | ECMA-262 | explicit OCaml iterator types |
JSON Schema regex compatibility | JSON Schema | ECMA-262 RegExp semantics | consumer-profile evidence, not a separate regex language |
Generated Unicode runtime tables | UCD 16.0.0 plus ECMA-262 property tables | generator tooling | generated OCaml source is committed runtime source; generated cache is not public API |
Package metadata and install surface | Dune/opam package model | repository release policy | exact package description and included docs |
ecma-regex is an OCaml library for ECMAScript regular-expression behavior. It is not a JavaScript runtime.
The following JavaScript-host behaviors are outside this public surface:
These areas are not runtime matcher semantics. They are JavaScript host/object protocol. The OCaml library may expose equivalent RegExp operations as direct functions, and those direct functions are the public surface to test.
Any future claim that one of these excluded areas is required must show:
Until then, these areas belong in product-surface policy or a deviation register as non-OCaml-surface behavior, not in the implementation backlog.
JSON Schema compatibility is a consumer profile over ECMA-262 RegExp semantics.
For this repository:
pattern and patternProperties use search semantics, not implicit full-string anchoring.format: regex is a compile/parse consumer of the same RegExp syntax.Unicode-sensitive behavior in this repository is pinned to UCD 16.0.0.
This affects:
Changing the Unicode version is a semantic change. It requires regenerated runtime source and regenerated evidence, followed by the relevant test gates.
Any implementation or documentation change should be able to name:
If one of these is missing, the work stays in research/audit phase and must not be described as completed release work.