POSIX ERE — the dialect grep -E speaks, rendered without regal.
regal has no ERE flavor, and its :java/:ecma output is not ERE: a nested
alternation comes out as (?:a|b), which POSIX ERE has no syntax for. So
this is the one dialect that renders from the Construct directly. It is
small because ERE is small — literals, classes, alternation, greedy
quantifiers, anchors, and one grouping syntax.
rg rejects what it cannot do: an unsupported pattern exits 2 with a
message. GNU grep 3.11 does not. Measured:
grep -E '\d+' matches a literal d — no warning, exit 0
grep -E '(?:a|b)c' matches abc — a warning, exit 0
grep -E 'ab*?' greedy — silently not lazy
grep -E '(?=x)' never matches — a warning, exit 1
Every one of those is a DIFFERENT LANGUAGE that still runs and still returns hits. For rg the capability gate converts a stderr parse into data; for grep it converts a silently wrong answer into a named refusal, which is the stronger reason the gate exists at all.
:posix-ere therefore provides: nothingIts capability set is empty. \d must be written [:class [\0 \9]],
which renders [0-9]; a tab must be a literal tab inside a :literal, not
:tab; a :capture is refused because ERE's only group is a capturing one,
so any structural group this emitter needs would shift the very index
:match/groups promises.
Everything the gate lets through is rendered exactly, or not at all.
POSIX ERE — the dialect `grep -E` speaks, rendered without regal. ## Why this emitter is hand-written regal has no ERE flavor, and its `:java`/`:ecma` output is not ERE: a nested alternation comes out as `(?:a|b)`, which POSIX ERE has no syntax for. So this is the one dialect that renders from the Construct directly. It is small because ERE is small — literals, classes, alternation, greedy quantifiers, anchors, and one grouping syntax. ## Why the gate matters more here than anywhere else `rg` rejects what it cannot do: an unsupported pattern exits 2 with a message. GNU grep 3.11 does not. Measured: grep -E '\d+' matches a literal `d` — no warning, exit 0 grep -E '(?:a|b)c' matches `abc` — a warning, exit 0 grep -E 'ab*?' greedy — silently not lazy grep -E '(?=x)' never matches — a warning, exit 1 Every one of those is a DIFFERENT LANGUAGE that still runs and still returns hits. For rg the capability gate converts a stderr parse into data; for grep it converts a silently wrong answer into a named refusal, which is the stronger reason the gate exists at all. ## What `:posix-ere` therefore provides: nothing Its capability set is empty. `\d` must be written `[:class [\0 \9]]`, which renders `[0-9]`; a tab must be a literal tab inside a `:literal`, not `:tab`; a `:capture` is refused because ERE's only group is a capturing one, so any structural group this emitter needs would shift the very index `:match/groups` promises. Everything the gate lets through is rendered exactly, or not at all.
(make-emitter)(make-emitter profile)An emitter rendering POSIX ERE for PROFILE.
An emitter rendering POSIX ERE for PROFILE.
POSIX Extended Regular Expressions, as accepted by grep -E.
:dialect/flavor is :posix-ere and names THIS emitter rather than a regal
flavor — regal has none to name.
POSIX Extended Regular Expressions, as accepted by `grep -E`. `:dialect/flavor` is `:posix-ere` and names THIS emitter rather than a regal flavor — regal has none to name.
(register-built-in!)Register the :posix-ere emitter. Returns the Result.
Register the `:posix-ere` emitter. Returns the Result.
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 |