3. Statements

statement ::=  assign_stmt | setbit | expr_stmt | return | loop_stmt | continue
               | break | if | increment | decrement

3.1. Assignment

assign_stmt ::=  assign | op_assign
assign      ::=  identifier "=" expression ";"
op_assign   ::=  identifier ("+" | "-" | "*" | "&" | "|")."=" expression ";"

The combined operator-assignment form is equivalent to identifier = identifier <operator> (expression).

3.2. Increment and decrement

increment ::=  identifier "++" ";"
decrement ::=  identifier "--" ";"

The increment and decrement statements increment and decrement the specified variable by one. They can’t be used as expressions as in other C-like languages.

3.3. Set bit

setbit ::=  identifier "@" integer = boolexpr ";"

foo.bar@3 = true; sets the third bit of foo.bar to true.

3.4. Expression as statement

expr_stmt ::=  expression ";"

This evaluates the expression and throws away the value. This is useful for calling functions, since function calls are expressions.

Given the expression foo(42), it can be used as a statement as foo(42);.

3.5. Return

return ::=  "return" (expression)? ";"

For functions with return type void, returning an expression is an error. In these functions, there is an implicit return at the end of the function block.

For functions with other return types, return withoun an expression is an error, as well as not returning an expression at the end of the function.

Any number of return statements is allowed, and may occur at any location within the function.

3.6. Loops

loop_stmt ::=  loop | repeat | while

3.6.1. Loop

loop ::=  "loop" "{" statementblock "}"

This is a simple loop. Iteration continues until a break statement is executed.

3.6.2. Repeat

repeat ::=  "repeat" "(" expression ")" "{" statementblock "}"

The repeat loop repeats the statement block for a number of times indicated by the value of the expression. The expression is evaluated once.

3.6.3. While

while ::=  "while" "(" booleanexpession ")" "{" statementblock "}"

The while loop exits if the condition evaluates to false. Otherwise, it executes the statement block and repeats the loop.

3.7. Loop control

3.7.1. Continue

continue ::=  "continue" ";"

continue jumps to the end of the current iteration of the loop it’s in.

3.7.2. Break

break ::=  "break" ";"

break exits the loop it’s in.

3.8. If

if       ::=  ifelse | ifelseif
ifelse   ::=  "if" "(" boolexpr ")" "{" statementblock "}" ("else" "{" statementblock "}")?
ifelseif ::=  "if" "(" boolexpr ")" "{" statementblock "}" "else" if

If the condition evaluates to true, the first statement block is executed. Otherwise, the second statement block is executed. The absence of an else block is equivalent to an empty else block.

An example:

if (foo == bar)
{
    // do something
}
else if (foo == 42)
{
    // do something special
}
else
{
    // do something else
}