Skip to content

Statements

Rui Ventura edited this page Apr 1, 2017 · 2 revisions

By default, instructions are executed in sequence, except when explicitly indicated.

Blocks

Each block has a local variable declaration area (optional), followed by an area for instructions (possibly empty). Defining or declaring functions withing blocks isn't possible.

A variable's scope is limited to the block in which they're declared. Declared entities can be directly used in inner sub-blocks or passed as arguments to functions called inside the block. In case that the identifiers used to define local variables that are already being use to define other entities within the scope of the block, the new identifier now references a new entity defined in the block up until its end (the previously defined entity still exists, but can't be referenced by its name). This rule is also valid regarding a function's arguments (see function body).

Conditional statement

This statement has a similar behavior to the if-else statement in C. The corresponding elsif parts in XPL behave as chains of conditional statements in the else part of a C if-else.

Iteration statement: while

This statement's behavior is identical to the while statement in C.

Iteration statement: sweep

The sweep+/sweep- statement initializes the left-value with the value of the first expression. If the value is greater/less than or equal to the value of the second expression, the statement is executed (otherwise, it ends without executing the statement). After running, it increments/decrements the left-value with the value of the third expression (if no value is specified, the value 1 (one) is considered for the increment/decrement), restarting the cycle: the condition is reverefied, etc.

Termination statement: stop

The stop statement ends the most inner cycle where the statement is found, like the break statement in C. This statement can only exist within a cycle, being the last statement of its block.

Continuation statement: next

The next statement restarts the most inner cycle where the statement is found, like the continue statement in C. This statement can only exist within a cycle, being the last statement of its block.

Return statement: return

The return statement, if it exists, is the last statement of its block. See its behavior in the description of a function's body.

Expressions as statements and printing operations

Expressions used as statements are evaluated, even if they don't cause side effects, and, eventually, their printed value (when followed by ! or !! -- printing without/with line change). Numeric values (integers or reals) are printed in base 10. Strings are printed in native encoding. Pointers can't be printed.

Clone this wiki locally