Language and documents
Document syntax, values, control flow, imports, and script execution.
.vect¶
.vect scriptsRun imperative script syntax through the shared execution intermediate representation.
Runtime: Document / runtime-specific syntax
vectrune examples/vect/Implementation: src/cli/vect.rs
.vectrune¶
.vectrune scriptsCompile English-style workflow definitions into the execution engine.
Runtime: Document / runtime-specific syntax
vectrune examples/vectrune/Implementation: src/vectrune/compiler.rs
comment¶
# commentAdd a comment to Rune source. A shebang-like #!RUNE header identifies a document.
Runtime: Document / runtime-specific syntax
#!RUNE
# A commentImplementation: src/rune_parser.rs
compound assignment¶
target += expression
target -= expression
target *= expression
target /= expressionRead a target, combine it with an expression and write the result back, including matching-object targets.
Runtime: Vect scripts / backend Rune / Rune-Web / browser emulator
Parameters
target- Variable, member path or matching-object path.
expression- Right-hand operand evaluated in the current scope.
Returns / effects
Updates the variable or path using the selected operator. Addition also supports string concatenation; the other operators are numeric.
Errors / edge cases
Missing lookup matches are not created. Backend @Values names remain read-only, including through local/let and compound assignments.
orders = [{ id: 1, items: [{ sku: "B", qty: 3 }] }]
id = 1
sku = "B"
orders[]id.items[]sku.qty += 4Implementation: src/object_syntax.rs · src/core/mod.rs · src/apps/rune_web/jscodegen.rs · runtime/rune-web/src/core_expression.ts · tests/object_syntax_parity.rs
db.request¶
record = db.request(config_path, source, packet)Access embedded or remote storage from a native extended Vect script.
Runtime: Native Vect host
Returns / effects
Decoded operation result; I/O errors include the Vect source line.
Errors / edge cases
The host must supply storage access; configuration paths resolve beside the script.
packet = { op: "get", collection: "notes", key: "hello" }
record = db.request("remote.rune", "main", packet)Implementation: src/execution/script.rs · runtime/rune-web/src/vect.ts · examples/data/storage/client.vect
environment substitution¶
$NAME$Substitute an environment variable in a Rune string configuration value.
Runtime: Document / runtime-specific syntax
secret = $jwt_secret$Implementation: src/rune_parser.rs
frontend action¶
action name(parameters):
statementDeclare an action in a Rune-Web @Logic or component scope.
Runtime: Document / runtime-specific syntax
action add(value):
total += valueImplementation: src/apps/rune_web/parser.rs · src/rune_parser.rs · tests/logic_continuation.rs
frontend arithmetic¶
+ - * / %Evaluate arithmetic in a frontend expression.
Runtime: Document / runtime-specific syntax
Returns / effects
Numeric result or string addition where supported.
Implementation: runtime/rune-web/src/expression.ts
frontend bindings¶
value <-> state.pathBind a frontend input or selection to reactive state.
Runtime: Document / runtime-specific syntax
input type=text value <-> nameImplementation: src/apps/rune_web/parser.rs
frontend boolean¶
and | or | !Combine truth values in frontend expressions.
Runtime: Document / runtime-specific syntax
Returns / effects
Boolean/short-circuit result according to the expression interpreter.
Implementation: runtime/rune-web/src/expression.ts
frontend comparison¶
== != === !== < <= > >= containsCompare frontend expression values.
Runtime: Document / runtime-specific syntax
Returns / effects
Boolean. `==`, `!=` and contains use frontend coercion rules. `===` and `!==` compare type and value with no conversion, and compare lists and objects by content.
Implementation: runtime/rune-web/src/expression.ts
frontend interpolation¶
"{expression}"Insert an expression into frontend text or attributes.
Runtime: Document / runtime-specific syntax
p "Hello {name}"Implementation: runtime/rune-web/src/interpolation.ts
frontend loops¶
for item in collection:
statementIterate a collection in frontend action logic or view templates.
Runtime: Document / runtime-specific syntax
for enemy in enemies:
enemy.x += 1Implementation: runtime/rune-web/src/logic.ts
frontend match¶
match expression:
"value" -> ComponentSelect a Rune-Web view branch by an expression.
Runtime: Document / runtime-specific syntax
match activePage:
"home" -> HomeContentImplementation: src/apps/rune_web/parser.rs
frontend nullish¶
value ?? fallbackUse a fallback for a null or unresolved value.
Runtime: Document / runtime-specific syntax
Returns / effects
Resolved value, or fallback.
Implementation: runtime/rune-web/src/expression.ts
frontend replication¶
count * { template } | grid(rows, columns, template)Generate repeated state values from templates.
Runtime: Document / runtime-specific syntax
items = 3 * { alive: true }Implementation: src/apps/rune_web/parser.rs
frontend ternary¶
condition ? yes : noChoose an expression according to a condition.
Runtime: Document / runtime-specific syntax
Returns / effects
Selected branch result.
Implementation: runtime/rune-web/src/expression.ts
frontend when¶
<command> when <condition>Run a registered frontend command only when its trailing condition evaluates true.
Runtime: Document / runtime-specific syntax
score++ when playingImplementation: runtime/rune-web/src/builtins/index.ts
if¶
if condition:
statementExecute an indented conditional block.
Runtime: Document / runtime-specific syntax
if correct * 100 >= pass_percent * total:
respond 200 { passed: true }Implementation: src/core/mod.rs · src/object_syntax.rs
if / else if / elif / else¶
if <cond>: ... else if <cond>: ... elif <cond>: ... else: ...Chained conditional branches across native run: blocks, Rune-Web actions/helpers and views, and .vect scripts.
Runtime: Native REST run: steps, Rune-Web actions/views, Pixel-3D logic, and .vect scripts
Aliases: elif
Returns / effects
Executes or renders the first matching branch.
Errors / edge cases
Invalid condition expressions surface normal runtime expression diagnostics.
if score >= 90:
grade = "A"
else if score >= 75:
grade = "B"
else:
grade = "C"Implementation: src/core/mod.rs · src/cli/vect.rs · src/apps/rune_web/parser.rs · runtime/rune-web/src/statement.ts · runtime/rune-web/src/rendering.ts
import¶
import "path.rune" | import "directory"Load top-level Rune imports before parsing the final document.
Runtime: Document / runtime-specific syntax
import "parts"Implementation: src/rune_parser.rs
local templates¶
local NAME = expression
let NAME = expressionDeclare a reusable binding or object batch in the current execution scope.
Runtime: Vect scripts / backend Rune / Rune-Web / browser emulator
Aliases: local, let
Parameters
NAME- Name used by subsequent expressions.
expression- A value, object template or generated batch.
Returns / effects
Binds the evaluated value to NAME. Rune-Web initial-state locals are private templates and are omitted from public state.
local batch = { id: i + 1, x: 10 } * 3 inc x by 5
actors = [batch with { y: 20 }, batch with { y: 40 }] all { alive: true }Implementation: src/object_syntax.rs · src/core/mod.rs · src/apps/rune_web/jscodegen.rs · runtime/rune-web/src/core_expression.ts · tests/object_syntax_parity.rs
match¶
match expression:
pattern:
statement
else:
fallbackEvaluate an expression and execute the first matching case branch without evaluating remaining branches.
Runtime: Native REST run: steps, Rune-Web actions/helpers, Pixel-3D logic, and .vect scripts
Aliases: switch
match status:
"active":
respond 200 "Active"
else:
respond 404 "Not Found"Implementation: src/core/mod.rs · src/apps/rune_web/parser.rs · runtime/rune-web/src/statement.ts · src/cli/vect.rs
matching object lookup¶
objects[]id
objects[]id.field = expression
orders[]id.items[]sku.qty += expressionSelect the first object whose named property matches the current binding of the same name, and optionally update it.
Runtime: Vect scripts / backend Rune / Rune-Web / browser emulator
Aliases: objects[]id
Parameters
objects- Array to search in source order.
id, sku- Property names that also identify lookup values in the current scope.
Returns / effects
objects[]id selects the first matching id. Numeric and string IDs compare by their string value. A target may replace the whole matching object or update a nested property. Nested lookups are supported.
Errors / edge cases
Missing-match writes and compound writes do nothing. Use ?? for a fallback on reads; hosts retain their null/undefined representation for missing values.
actors = [{ id: 1, hp: 3 }, { id: 2, hp: 4 }]
id = 2
actors[]id.hp -= 1
selected = actors[]id
missing = actors[]missing_id ?? nullImplementation: src/cli/developer.rs · src/object_syntax.rs · src/core/mod.rs · src/apps/rune_web/jscodegen.rs · runtime/rune-web/src/core_expression.ts · tests/object_syntax_parity.rs
object grid¶
grid COLS x ROWS at (X, Y) step (DX, DY) with { overrides }Generate a rectangular batch of positioned objects in row order.
Runtime: Vect scripts / backend Rune / Rune-Web / browser emulator
Aliases: grid
Parameters
COLS, ROWS- Nonnegative integer dimensions; each dimension and the total cell count must be at most 1000000.
X, Y- Finite numeric origin coordinates.
DX, DY- Finite numeric spacing between columns and rows.
overrides- Optional object with zero-based i, row/r and col/c bindings in scope.
Returns / effects
Array with x, y, start_x, start_y, col and row on each object. x = X + col * DX; y = Y + row * DY. Overrides are evaluated after these fields are created.
Errors / edge cases
Invalid dimensions, excessive cell counts and nonfinite coordinates or spacing are invalid.
cells = grid 2 x 2 at (10, 20) step (5, 15) with { id: i + 1, type: row + 1 }Implementation: src/object_syntax.rs · src/core/mod.rs · src/apps/rune_web/jscodegen.rs · runtime/rune-web/src/core_expression.ts · tests/object_syntax_parity.rs
object overlays¶
template with { overrides }
[batch with { overrides }, ...] all { overrides }Copy an object, or apply overrides to every object in a batch, without changing the template.
Runtime: Vect scripts / backend Rune / Rune-Web / browser emulator
Aliases: with, all
Parameters
template- Object or array of objects to copy.
overrides- An object whose fields override copied fields.
Returns / effects
Fresh objects with nested data copied and override properties replacing existing properties. For array sources, scalar elements are preserved. Overlay batches expand inside array literals.
Errors / edge cases
The source must be an object or array; overrides must be an object.
local batch = { x: 10, stats: { hp: 3 } } * 2 inc x by 5
actors = [batch with { y: 20 }, batch with { y: 40 }] all { alive: true }Implementation: src/object_syntax.rs · src/core/mod.rs · src/apps/rune_web/jscodegen.rs · runtime/rune-web/src/core_expression.ts · tests/object_syntax_parity.rs
object property shorthand¶
{ name, score, label: expression }Construct an object using current-scope bindings as field values; mix shorthand and explicit fields, including nested objects.
Runtime: Vect scripts / backend Rune / Rune-Web / browser emulator
Parameters
name, score- Identifiers whose current values become properties with the same names.
label: expression- An explicit field using colon syntax.
Returns / effects
{ name, score } has the same fields and values as { name: name, score: score }.
Errors / edge cases
Quoted keys require an explicit value. __proto__, constructor and prototype are rejected as member keys.
name = "Alex"
score = 7
profile = { name, stats: { score }, active: true }Implementation: src/object_syntax.rs · src/core/mod.rs · src/apps/rune_web/jscodegen.rs · runtime/rune-web/src/core_expression.ts · tests/object_syntax_parity.rs · examples/language/objects/objects.vect · examples/language/objects/objects-api.rune · examples/language/objects/objects-web.rune
object replication¶
{ template } * COUNT inc PROPERTY by STEP with { overrides }Generate independent objects from a template, optionally incrementing numeric properties and applying per-copy overrides.
Runtime: Vect scripts / backend Rune / Rune-Web / browser emulator
Parameters
COUNT- Integer from 0 through 1000000; zero produces an empty array.
PROPERTY- One property, or a parenthesized comma-separated list such as (x, start_x).
STEP- Finite numeric increment; negative steps are supported.
overrides- Optional object evaluated for each copy with zero-based i in scope.
Returns / effects
Array of COUNT objects. Evaluate the template with zero-based i, apply i * STEP to each selected numeric property, then apply overrides. Nested data is copied.
Errors / edge cases
Negative, fractional, nonnumeric or excessive counts and nonfinite steps are invalid.
batch = { id: i + 1, x: 10, start_x: 10 } * 3 inc (x, start_x) by 5 with { active: true }Implementation: src/object_syntax.rs · src/core/mod.rs · src/apps/rune_web/jscodegen.rs · runtime/rune-web/src/core_expression.ts · tests/object_syntax_parity.rs
path lookup¶
root.field | root.[key] | array[index]Resolve dotted or bracketed paths against the current context.
Runtime: Document / runtime-specific syntax
user = users.find it.id == idImplementation: src/core/mod.rs
record¶
+ key = valueStart a record; subsequent indented properties extend that record.
Runtime: Document / runtime-specific syntax
@Data/People
+ name = Ada
role = developerImplementation: src/rune_parser.rs
return¶
return <value>Finish a native resolver or step sequence with a resolved value.
Runtime: Document / runtime-specific syntax
Returns / effects
The native dispatcher resolves the argument and returns it with success status; GraphQL resolver handling uses that result.
return resultImplementation: src/builtins.rs
section¶
@Name[/path...]Create a hierarchical named section. Section names select runtime behavior when recognized by an app; arbitrary sections can hold user data.
Runtime: Document / runtime-specific syntax
@Schema/User
name = stringImplementation: src/rune_parser.rs
series¶
name:
itemDeclare an ordered series. Executable run blocks and declarative data series share this document shape.
Runtime: Document / runtime-specific syntax
run:
log "hello"
respond 200 "OK"Implementation: src/rune_parser.rs
value¶
key = valueDeclare a scalar or structured value in a section. Runtime expressions and declaration literals are parsed by different layers.
Runtime: Document / runtime-specific syntax
@Values
enabled = true
size = [320, 200]
size_text = "[320, 200]"Implementation: src/rune_ast.rs · src/rune_parser.rs