statement ::= assign_stmt | setbit | expr_stmt | return | loop_stmt | continue | break | if | increment | decrement
assign_stmt ::= assign | op_assign assign ::= identifier "=" expression ";" op_assign ::= identifier ("+" | "-" | "*" | "&" | "|")."=" expression ";"
The combined operator-assignment form is equivalent to identifier = identifier <operator> (expression).
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.
setbit ::= identifier "@" integer = boolexpr ";"
foo.bar@3 = true; sets the third bit of foo.bar to true.
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);.
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.
loop_stmt ::= loop | repeat | while
loop ::= "loop" "{" statementblock "}"
This is a simple loop. Iteration continues until a break statement is executed.
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.
while ::= "while" "(" booleanexpession ")" "{" statementblock "}"
The while loop exits if the condition evaluates to false. Otherwise, it executes the statement block and repeats the loop.
continue ::= "continue" ";"
continue jumps to the end of the current iteration of the loop it’s in.
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
}