This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.
Parser
~import std/parserparser.kz · 6 tors · ~[comptime]
// The grammar declaration: a region of `! <rule-name> <cursor>` effect arms.
// Wildcard arm names (the regex `scan` decl precedent) — the arm name IS the
// rule name, the binding is the rule's cursor.
~[comptime|transform] pub tor grammar {
expr: Expression,
reporter: std/compiler:*ErrorReporter
}
! * *match
koru_std/parser.kz:64// The common picker: explicit ordered-choice over patterned branches at the
// cursor. Consumed by the `parse` transform when static; a real event so the
// page resolves honestly. `no-match` mirrors regex:match's fallback — unused
// by cut-1 rules (a rule with no matching alternative fails upward), reserved
// as the explicit-recovery arm.
~pub tor match { expr: Expression }
| * *
| ?no-match// Demand a sub-rule at the current position; binds the rule's produced value.
~pub tor sub { expr: Expression } -> string// Consume a literal token (plain text, NOT a regex — no escaping needed).
~pub tor lit { expr: Expression }// The parse site: dispatches on the named top rule's success, or parse-error.
~[comptime|transform] pub tor parse {
expr: Expression,
grammar: Expression,
reporter: std/compiler:*ErrorReporter
}
| * *
| ?parse-error { line: usize, col: usize, expected: string, found: string }~[comptime|command] pub tor generate {
program: *const Program,
allocator: __koru_std.mem.Allocator,
argv: []const []const u8
}