This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 9/16/2026.
Interpreter
~import std/interpreterKoru Interpreter Standard Library
interpreter.kz · 1 tors · ~[runtime]
Koru Interpreter Standard Library · 25 more lines
Koru Interpreter Standard Library
Enables runtime evaluation of Koru source code
DESIGN:
- Parses Koru source at runtime using the same parser as the compiler
- Walks the AST and executes events via registered dispatchers
- Tracks bindings in an environment as flow progresses
- Uses the shape_checker for optional validation before execution
Usage:
import std/interpreter
import std/runtime
// Register events you want callable at runtime
std/runtime:register(scope: "api") {
greet
process_order
}
// Interpret Koru source
std/interpreter:run(source: user_input, scope: "api")
| result r |> handle_result(value: r.value)
| parse-error e |> respond(status: 400, body: e.message)
| validation-error e |> respond(status: 400, body: e.message)
| dispatch-error e |> respond(status: 500, body: e.event)
// VALUE SERIALIZATION - Convert interpreter Value to JSON
~[retain] pub tor value.stringify { value: Value } -> string