Statements

Statements and declarations must occur inside function bodies. Simple statements end with ;; control-flow statements and blocks do not.

Declarations and assignment

int count = 0;
int values[3] = {10, 20, 30};
count = values[0];
count += 1;
count++;

Scalar declarations always require initializers.

Conditionals

Conditions are parenthesized and every branch body is a block.

if (score >= 90) {
    print("A");
} elseif (score >= 80) {
    print("B");
} else {
    print("C");
}

The keyword is elseif, written as one word.

While loops

while (index < limit) {
    index++;
}

For loops

for (int index = 0; index < 5; index++) {
    print(index);
}

All three clauses are optional: for (;;) { ... } parses. The initializer may be a declaration, assignment, increment/decrement, or expression. The update may be an assignment, increment/decrement, or expression. Each clause accepts at most one item.

Loop control

while (true) {
    if (done) {
        break;
    }
    continue;
}

break; and continue; are supported as statements. Use them inside loops.

Built-in statements

print requires at least one argument after semantic analysis and accepts any number of printable primitive values:

print("count:", count, " ready:", ready);

Non-string arguments are converted to strings by the compiler. exit() accepts zero or one argument:

exit();
exit(1);

Note

The current implementation does not distinguish the behavior of exit() and exit(argument). Argument-sensitive exit behavior is planned for a future release.

Returns and nested blocks

return;
return result;

{
    int local = 1;
    print(local);
}

A void function must not return a value. A non-void function's return statements must provide a value of exactly its declared return type.