This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 11/4/2026.
Regex
import std/regexregex.kz · 2 tors · ~[comptime]
// The tor declares the USER surface: any raw-name branch (the name IS the
// pattern, byte-for-byte) with a bindable payload, plus an optional void
// `no-match` fallback. The shape checker enforces this contract — binding
// rule included — with zero match-specific code; the transform's output
// needs no exemption.
//
// The `[transform]` annotation on the PROC is what makes this a transform:
// a transform IS a proc on an ordinary tor. Its machine interface
// (invocation/item/program/allocator → SiteResult) is the proc-return
// convention, not part of the tor. The tor keeps `[transform]` too —
// downstream passes read it as "implemented by a transform" (deferred
// bindings, comptime-flow skipping, variant emission).
~[comptime|transform] pub tor match {
expr: Expression,
reporter: std/compiler:*ErrorReporter
}
| * *
| ?no-match~part norm koru_std/regex.norm.kz
Koru Standard Library: the `norm` part of regex.kz. Joined via `~part norm` in regex.kz; merged into the regex module at load. Reads the `:` spec on delivery-arm destructures and normalizes it out of the emission path — `{ l: i64 }` carries the conversion spec in the `:` slot: ident-shaped RHS lands on `path` (the parser can't tell `i64` from a field name), sigil-shaped RHS on `type_text`. Either way it is THIS tor's spec — and the emitted binding must read the payload by capture name (`dst.l`), never `dst.i64`.
~part scan koru_std/regex.scan.kz
Koru Standard Library: the `scan` part of regex.kz. Joined via `~part scan` in regex.kz; merged into the regex module at load. SCAN - unanchored, streaming regex: `!` (each) where match uses `|` (once). `match` finds ONE whole-input match (anchored); `scan` finds EVERY non-overlapping occurrence as an effect stream — it fires its `!` pattern branch per hit (with the same named-group destructure match uses), then runs the optional `| done` continuation once. This is the terminal layer of the parser stack: a lexer in a few lines. Built on the engine's leftmost-longest unanchored search: the compiled SEARCH fn locates each span, and the same captures matcher `match` uses extracts the groups from that span. The `!` branch body is spliced once via `__koru_inline_<idx>` — INSIDE the loop it therefore runs per match, which is exactly effect-branch semantics. Single pattern for now (multi-pattern scan is pinned as a follow-up); pattern branches MUST be effect `!` (dispatch-into-each-match), mirroring the router.
// Koru Standard Library: the `scan` part of regex.kz.
// Joined via `~part scan` in regex.kz; merged into the regex
// module at load.
//
// SCAN - unanchored, streaming regex: `!` (each) where match uses `|` (once).
// `match` finds ONE whole-input match (anchored); `scan` finds EVERY
// non-overlapping occurrence as an effect stream — it fires its `!` pattern
// branch per hit (with the same named-group destructure match uses), then runs
// the optional `| done` continuation once. This is the terminal layer of the
// parser stack: a lexer in a few lines. Built on the engine's leftmost-longest
//
// unanchored search: the compiled SEARCH fn locates each span, and the same
// captures matcher `match` uses extracts the groups from that span. The `!`
// branch body is spliced once via `__koru_inline_<idx>` — INSIDE the loop it
// therefore runs per match, which is exactly effect-branch semantics. Single
// pattern for now (multi-pattern scan is pinned as a follow-up); pattern
// branches MUST be effect `!` (dispatch-into-each-match), mirroring the router.
~[comptime|transform] pub tor scan {
input: string,
reporter: std/compiler:*ErrorReporter
}
! * *
| ?done