Skip to content

Statements

Statements control execution and side effects within blocks.

Quick patterns

  • Use LET for new bindings and SET for mutation inside loops.
  • Guard code with IF and TRY/CATCH; pair ASSERT/THROW for explicit failures.
  • FOR/FOR EACH iterate collections; comprehensions in expressions provide a shorthand for building arrays.
  • OUTPUT { ... } shapes final payloads; nested OUTPUT is allowed for intermediate blocks.
  • CALL bridges to host functions; AWAIT/SUSPEND/PARALLEL require host support for async/concurrency.

Output

The OUTPUT statement specifies how results are emitted from the pipeline.

Using

The USING clause references adapters and external modules.

Transform

The TRANSFORM statement defines transformation steps in the pipeline. Use TRANSFORM Name { ... } or include { buffer } after the name to mark buffer mode explicitly.

For Loops

The FOR and FOR EACH statements provide iteration over collections.

If Statements

The IF statement provides conditional branching.

Enumerations

The ENUM statement defines enumerated types.

For Each

The FOREACH statement provides a shortcut for iteration.

Input

The INPUT keyword references the pipeline input data (alias: input).

Parallel

The PARALLEL statement enables concurrent execution.

Abort

The ABORT statement terminates execution immediately.

Throw

The THROW statement raises an exception.

Try

The TRY statement handles errors and exceptions.

Shared

The SHARED statement declares shared memory resources.

To wait for a shared entry from within a program, use the AWAIT_SHARED(resource, key) stdlib function (requires a configured shared store in the host). This cannot be demonstrated in the playground because no shared store is wired there.

Functions

The FUNC statement declares functions.

Types

The TYPE statement declares custom types.

Return

The RETURN statement exits from functions.

Modify

The MODIFY statement changes existing values.

Where

The WHERE clause provides filtering conditions.

Set

The SET statement performs assignments.

Init

The INIT statement provides initial values.

statement ::= letStmt | ifStmt | forStmt | tryStmt | callStmt
            | sharedWrite | suspendStmt | abortStmt | throwStmt
            | nestedOutput | expressionStmt | ;
【F:language/src/test/kotlin/v2/ebnf.txt†L76-L94】

Variable binding

letStmt ::= LET IDENTIFIER "=" expression ";"

LET introduces a new variable bound to the result of an expression【F:language/src/test/kotlin/v2/ebnf.txt†L82-L82】.

Control flow

ifStmt ::= IF expression block ( ELSE block )?
forStmt ::= ( FOR EACH | FOR ) IDENTIFIER IN expression block

Conditionals and loops evaluate expressions to drive branching and iteration【F:language/src/test/kotlin/v2/ebnf.txt†L83-L85】.

Error handling

tryStmt ::= TRY expression CATCH "(" IDENTIFIER ")" "=>" expression

TRY evaluates an expression and binds an error to the given identifier if one occurs【F:language/src/test/kotlin/v2/ebnf.txt†L85-L85】.

Calls and mutation

callStmt    ::= optAwait CALL IDENTIFIER "(" argList? ")" arrow IDENTIFIER ";"
sharedWrite ::= IDENTIFIER "[" expression? "]" "=" expression ";"

Call statements invoke suspended functions, while sharedWrite mutates shared memory slots【F:language/src/test/kotlin/v2/ebnf.txt†L86-L90】.

Suspension and termination

suspendStmt ::= SUSPEND expression ";"
abortStmt  ::= ABORT expression? ";"
throwStmt  ::= THROW expression? ";"

These statements pause or terminate execution, optionally carrying an expression【F:language/src/test/kotlin/v2/ebnf.txt†L90-L92】.

Nested output and expressions

nestedOutput   ::= OUTPUT templateBlock
expressionStmt ::= expression ";"

Nested OUTPUT blocks and bare expressions complete the statement set【F:language/src/test/kotlin/v2/ebnf.txt†L93-L94】.