diff options
| author | Bobby <[email protected]> | 2026-07-01 14:13:40 +0530 |
|---|---|---|
| committer | GitHub <[email protected]> | 2026-07-01 14:13:40 +0530 |
| commit | d46c40de921dd2ba62fbfcd0e2e4591eee8de2a9 (patch) | |
| tree | fa0232556e112b320c0bfde96e3ef5f279b3df2d /tests/errors | |
| parent | bd3b12ff2f30c251c5fc52b43f81ec2f282d53ab (diff) | |
| parent | 391a4c2fd4afbaa5910aaf670a5e1c88c5e5aa84 (diff) | |
| download | edify-d46c40de921dd2ba62fbfcd0e2e4591eee8de2a9.tar.xz edify-d46c40de921dd2ba62fbfcd0e2e4591eee8de2a9.zip | |
feat: add Pattern class and .use() composition (#261)
## Summary
Closes #125 — the ``Pattern`` class, a named reusable regex fragment
that composes with any builder via ``.subexpression()`` or ``.use()``.
Closes #126 — the ``.use(pattern)`` chain method, the ergonomic alias
for the common-case ``.subexpression(pattern)`` (drops flag / anchor
overrides, keeps sensible defaults).
## Design
**``Pattern``** is the same fluent surface as ``RegexBuilder`` minus the
terminals. It shares every chain-method mixin (anchors, assertions,
captures, chain, chars, classes, flags, groups, quantifiers,
subexpression). It deliberately does **not** carry ``to_regex`` /
``to_regex_string`` — a pattern is a fragment, and fragments compose
upward through ``.use()`` rather than compile themselves. To emit a
regex from a pattern, embed it in a builder:
``RegexBuilder().use(my_pattern).to_regex()``.
**``BuilderCore``** (new) holds the immutable-state plumbing that both
``RegexBuilder`` and ``Pattern`` need — the ``_state`` attribute, the
``__init__``, and the clone-and-replace ``_with_state`` helper. Both
concrete classes now inherit ``BuilderCore`` instead of duplicating
three lines each.
**``.use(pattern)``** lives on ``SubexpressionMixin`` alongside
``.subexpression``. It calls ``self.subexpression(pattern)`` with the
common-case defaults, so ``Pattern`` and ``RegexBuilder`` both get it
for free. Direct ``.subexpression`` calls remain available when you need
the ``namespace`` / ``ignore_flags`` / ``ignore_start_and_end``
overrides.
## Fanout
Closing this unblocks the operator algebra (#122, #123, #124), every
validator-to-callable-Pattern migration (#177–#190), the AST walker
(#143), and every building-block atom (#172–#176).
Diffstat (limited to 'tests/errors')
0 files changed, 0 insertions, 0 deletions
