Statements

Empty statement

An empty statement does nothing.

statement
	: ';'
    ;

An empty statement is used when there are no operations to perform in a context where a statement is required.

Block statement

A block statement allows a list of statements where a single statement is allowed.

statementBlock
	: block
	;

block
	: '{' (statement)* '}'
	;

A block statement is executed as follows:

  • If the block is empty, the execution is transferred at the end of the block.
  • If the block is not empty, the execution is transferred to the first statement in the block then to the next statement and so on until the last statement is reached. After the last statement the execution is transferred at the end of the block. The end of the block will not be reached if: (a) a return statement is reached or (b) an error has occured.

Assign statement

The assign statement assigns the value of an evaluable to an assignable.

statementAssign
	: assignable '=' evaluable
	;

An assign statement is executed as follows:

  • The evaluable part is evaluated and converted to the required type. The compiler validates that the type of the of the value produced by the evaluable is assignable directly or by implicit conversion to the type of the assignable.
  • The assignable is set to the value.

Variable statement

The variable declaration statement is used to define variable in the context of the enclosing block.

statementVar
	: 'var' ID (('=' evaluable) | 'as' scalarTypeInstance)
	;

A variable declare statement is executed as follows:

  • If the statement contains initialization the evaluable is evaluated. The value produced by the evaluable will be the value of the variable.
  • If the statement does not contain initialization the default constructor of the scalarTypeInstance is called to obtain the value of the variable.

Function call statement

The function call statement is used to call methods (of functions igoring their return value) outside expressions.

functionCall
	: obj '->' functionCallMethod functionCallArguments
	;

if statement

statementIf
	: 'if' '(' evaluable ')' t=statement ('else' f=statement)?
	;

The if statement is executed as follows:

  • The evaluable part is evaluated and converted to the bool type. The compiler validates that the type of the of the value produced by the evaluable is assignable directly or by implicit conversion to bool.
  • If the value is true then the execution is transferred to the t statement.
  • If the value is false then the execution is transferred to the f statement.

foreach statement

statementForEach
	: 'foreach' ID 'in' evaluable statement
	;

The foreach statement is executed as follows:

  • The evaluable part is evaluated and converted to the collection type. The compiler validates that the type of the of the value produced by the evaluable is assignable directly or by implicit conversion to collection.
  • A new enclosing block context for the statement is created.
  • A variable meant to hold the current item is created in the context of the enclosing block. The name of the variable is specified by the ID identifier.
  • The execution is transferred to statement.
  • The execution continues with the next item until: (a) the collection is sequentially traversed or (b) a return or break statement is reached.
  • If the execution reaches a continue statement then the execution continues with the next item by ignoring all other subsequent statements.

break statement

statement
	: 'break' ';'
	;

continue statement

statement
	: 'continue' ';'
    ;

return statement

statementReturn
	: 'return' expression
	;

DELETE statement

entityDeleteStatement
	: 'DELETE' ID '(' expression ')'
	| 'DELETE' variable
	| 'DELETE' 'CHILD' v1=variable relationshipName=ID v2=variable
	;

PUT statement

entityPutStatement
	: 'PUT' variable
	;

INCREMENT statement

entityIncrement
	: 'INCREMENT' property evaluable
	;