Liking cljdoc? Tell your friends :D

hive-system.pattern.construct.schema

Malli value objects for regex CONSTRUCTS — a regex expression reified as data.

Two forms, one language

A construct is AUTHORED in lambdaisland/regal's vector syntax — [:cat "a" [:alt "b" "c"]] — and NORMALIZED into the recursive map value object this namespace defines. The authored form is what callers write; the normalized form is what carries contracts, generators and tests. construct.core promotes one into the other and projects back.

The split is forced: malli refuses a :ref reachable inside a sequence schema (::m/potentially-recursive-seqex), and regal's head-plus-variadic vector IS a sequence schema.

Capabilities

A Capability names a regex feature whose availability differs across target languages. A Dialect declares the set it PROVIDES; a construct's required set is computed from its shape. Support is a set-difference, decidable before emission — never a try/catch around a compile.

These schemas are the single source: they drive the m/=> contracts and the synthesized property/mutation tests.

Malli value objects for regex CONSTRUCTS — a regex expression reified as data.

## Two forms, one language

A construct is AUTHORED in lambdaisland/regal's vector syntax — `[:cat "a"
[:alt "b" "c"]]` — and NORMALIZED into the recursive map value object this
namespace defines. The authored form is what callers write; the normalized
form is what carries contracts, generators and tests. `construct.core`
promotes one into the other and projects back.

The split is forced: malli refuses a `:ref` reachable inside a sequence
schema (`::m/potentially-recursive-seqex`), and regal's head-plus-variadic
vector IS a sequence schema.

## Capabilities

A `Capability` names a regex feature whose availability differs across target
languages. A `Dialect` declares the set it PROVIDES; a construct's required
set is computed from its shape. Support is a set-difference, decidable before
emission — never a `try`/`catch` around a compile.

These schemas are the single source: they drive the `m/=>` contracts and the
synthesized property/mutation tests.
raw docstring

Capabilitiesclj/s

A set of capabilities: what a dialect provides, or what a construct needs.

A set of capabilities: what a dialect provides, or what a construct needs.
sourceraw docstring

Capabilityclj/s

A regex feature a dialect may or may not provide.

:lookaround (?=…) (?!…) (?<=…) (?<!…) :atomic (?>…) — a group that does not backtrack :lazy *? +? ?? {n,m}? — reluctant quantifiers :perl-class \d \w \s and complements :capture a group whose INDEX is promised. POSIX ERE has only one grouping syntax, so every structural group it emits also captures and shifts the numbering — a dialect that cannot group without capturing cannot honour :match/groups. :control-escape \t \n \r \f \a \e \0 \v — naming a control character rather than embedding the byte. ERE has no such spelling, and grep -E '\t' matches a literal t. :collation-range a bracket range by CODE POINT. POSIX bracket ranges are ordered by the runtime locale's collation, so a range whose ends are not both upper, both lower or both digit denotes a different set per locale — or none at all.

Every member is PRODUCIBLE: some Construct requires it, so the refusal property has a case for each. A feature no construct can express does not belong here until one can — a capability with no producer makes its own test vacuous.

A regex feature a dialect may or may not provide.

:lookaround       (?=…) (?!…) (?<=…) (?<!…)
:atomic           (?>…) — a group that does not backtrack
:lazy             *? +? ?? {n,m}? — reluctant quantifiers
:perl-class       \d \w \s and complements
:capture          a group whose INDEX is promised. POSIX ERE has only one
                  grouping syntax, so every structural group it emits also
                  captures and shifts the numbering — a dialect that cannot
                  group without capturing cannot honour `:match/groups`.
:control-escape   \t \n \r \f \a \e \0 \v — naming a control character
                  rather than embedding the byte. ERE has no such spelling,
                  and `grep -E '\t'` matches a literal `t`.
:collation-range  a bracket range by CODE POINT. POSIX bracket ranges are
                  ordered by the runtime locale's collation, so a range
                  whose ends are not both upper, both lower or both digit
                  denotes a different set per locale — or none at all.

Every member is PRODUCIBLE: some Construct requires it, so the refusal
property has a case for each. A feature no construct can express does not
belong here until one can — a capability with no producer makes its own
test vacuous.
sourceraw docstring

ClassEntryclj/s

One member of a character class: a literal character, a range, or a shorthand token.

One member of a character class: a literal character, a range, or a
shorthand token.
sourceraw docstring

Constructclj/s

A normalized regex expression.

Dispatches on :construct/op. Every branch is :closed — an unrecognized key is a defect, not an extension point; extension happens through the dialect registry.

:literal {:construct/text "abc"} matched verbatim :token {:construct/token :digit} :class {:construct/negated? false :construct/entries [[\a \z] _ :digit]} :repeat {:construct/arg C :construct/min 2 :construct/max 4 :construct/lazy? false} :max absent = unbounded <n-ary> {:construct/args [C …]} :cat :alt :* :+ :? …

A quantifier (:* :+ :?) carries :construct/lazy?; every other n-ary op omits it.

A normalized regex expression.

Dispatches on `:construct/op`. Every branch is `:closed` — an unrecognized
key is a defect, not an extension point; extension happens through the
dialect registry.

  :literal  {:construct/text "abc"}                    matched verbatim
  :token    {:construct/token :digit}
  :class    {:construct/negated? false
             :construct/entries [[\a \z] \_ :digit]}
  :repeat   {:construct/arg C :construct/min 2
             :construct/max 4 :construct/lazy? false}   :max absent = unbounded
  <n-ary>   {:construct/args [C …]}                     :cat :alt :* :+ :? …

A quantifier (`:*` `:+` `:?`) carries `:construct/lazy?`; every other n-ary
op omits it.
sourceraw docstring

Dialectclj/s

A regex target language, as data.

:dialect/capabilities is what the target PROVIDES. Emitting a construct that needs anything outside it is refused — never approximated, because an approximation is a different language that still runs.

:dialect/flavor is the regal flavor used to render the residual construct once the gate has passed.

A regex target language, as data.

`:dialect/capabilities` is what the target PROVIDES. Emitting a construct
that needs anything outside it is refused — never approximated, because an
approximation is a different language that still runs.

`:dialect/flavor` is the regal flavor used to render the residual construct
once the gate has passed.
sourceraw docstring

DialectIdclj/s

Stable keyword naming a registered dialect (:java, :ecma, :re2).

Stable keyword naming a registered dialect (:java, :ecma, :re2).
sourceraw docstring

DialectIndexclj/s

id -> Dialect. The registry's value; passed explicitly to pure resolvers.

id -> Dialect. The registry's value; passed explicitly to pure resolvers.
sourceraw docstring

NAryOpclj/s

An operator over one or more sub-constructs, in :construct/args, with no further keys.

An operator over one or more sub-constructs, in `:construct/args`, with no
further keys.
sourceraw docstring

Opclj/s

Every construct head. :literal, :token, :class, :repeat and the quantifiers carry shape-specific keys; everything else is plain n-ary.

Every construct head. `:literal`, `:token`, `:class`, `:repeat` and the
quantifiers carry shape-specific keys; everything else is plain n-ary.
sourceraw docstring

QuantifierOpclj/s

An n-ary operator that additionally carries :construct/lazy?. Kept out of NAryOp so the generator cannot mint a quantifier in non-quantifier shape.

An n-ary operator that additionally carries `:construct/lazy?`. Kept out of
`NAryOp` so the generator cannot mint a quantifier in non-quantifier shape.
sourceraw docstring

Rangeclj/s

An inclusive character range inside a class. START must not exceed END — Pattern/compile rejects a reversed range, so the invariant belongs here rather than in a caller's head.

An inclusive character range inside a class. START must not exceed END —
`Pattern/compile` rejects a reversed range, so the invariant belongs here
rather than in a caller's head.
sourceraw docstring

RawConstructclj/s

What a caller may hand in: regal's authored vector syntax, or an already normalized Construct. Deliberately permissive — core/normalize is the gate, and it reports WHY a form was refused.

What a caller may hand in: regal's authored vector syntax, or an already
normalized Construct. Deliberately permissive — `core/normalize` is the gate,
and it reports WHY a form was refused.
sourceraw docstring

Tokenclj/s

A construct with no arguments: an anchor, a character-class shorthand, or a literal control character. Spelled exactly as regal spells it.

A construct with no arguments: an anchor, a character-class shorthand, or a
literal control character. Spelled exactly as regal spells it.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close