Protocol for the pattern subsystem.
IPatternEngine is the DIP seam between consumers (audits, linters, log
scanners) and concrete matching engines (java.util.regex today; a structural
s-expression matcher, a glob matcher, or a tree-sitter query engine next).
Consumers depend on this protocol and on a Pattern value. They never name an engine, so swapping or adding one changes no call site.
An engine MUST:
Result from every operation — never throw for a bad pattern.:pattern/unsupported-flag) rather than
ignore it: a silently dropped flag is a wrong answer.:match/end exclusive,
with (subs subject start end) equal to :match/text.engine-id keyword.Protocol for the pattern subsystem. ## ISP boundary `IPatternEngine` is the DIP seam between consumers (audits, linters, log scanners) and concrete matching engines (java.util.regex today; a structural s-expression matcher, a glob matcher, or a tree-sitter query engine next). Consumers depend on this protocol and on a Pattern value. They never name an engine, so swapping or adding one changes no call site. ## Engine contract An engine MUST: - Return `Result` from every operation — never throw for a bad pattern. - Reject a flag it cannot honour (`:pattern/unsupported-flag`) rather than ignore it: a silently dropped flag is a wrong answer. - Report matches in subject order, non-overlapping, `:match/end` exclusive, with `(subs subject start end)` equal to `:match/text`. - Use a stable, unique `engine-id` keyword.
A pluggable matching engine over a Pattern value object.
A pluggable matching engine over a Pattern value object.
(engine-id this)Keyword identifying this engine (e.g. :regex, :structural). MUST be stable and unique within a process.
Keyword identifying this engine (e.g. :regex, :structural). MUST be stable and unique within a process.
(match? this pattern subject)Does PATTERN occur in SUBJECT? Returns Result<boolean>.
Does PATTERN occur in SUBJECT? Returns Result<boolean>.
(scan this pattern subject)Every occurrence of PATTERN in SUBJECT. Returns Result<Matches> —
subject-ordered, non-overlapping, :match/end exclusive.
Every occurrence of PATTERN in SUBJECT. Returns Result<Matches> — subject-ordered, non-overlapping, `:match/end` exclusive.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |