Xion is a case-sensitive language.
There are two kinds of comments. The inline comment starts with the string character sequence // and ends at the end of the line. Multi-lines comment starts with the character sequence /* and ends with */.
Example:
//Let's create a hello variable
HelloWriter hello/* = new HelloWriter()*/; /*Here, the variable
initialization is ignored, but the ; is necessary*/
A Xion program is made of Xion instruction sequence. Each instruction ends with the character ;, except instruction blocks. Control structures if , else, while and for are separated by their instruction (just as C or Java).
It is possible to group Xion instructions by placing them between characters { and }. This is usually done in control structures if, else, while, do and for to group a sequence of instructions. The scope of variables defined in a nested block is limited to this block. A block is not an expression.
Variables are declared with the same syntax as C/Java. Firstly is given the qualified type name, and then, separated by comas, the names of the variables may be given with an initialization expression after the character =. A variable declaration is not an expression. To call a variable, just type its name.
Example: Integer i = 0, j = ++i, k = i + j + 3;
Within the declaration of a method specified by a non static operation, the pseudo variables this and self contain the object on which the method is called.
To affect a variable or an accessible field, use the symbol =. An assignation is an expression returning Void, so it is impossible to cascade them.
Example: Integer i; i = 123456789;
Xion defines some conditional instructions that control the code execution:
It may be necessary to change the type of an expression, when the return type is not of the programmer awaited type. Two methods exist (difference explained later). For instance to transform a Real into Integer.
Notice that is is possible to cast only into a super or a sub-type (for instance, it is possible to cast a Real into Integer, but not into a String)... This follows the type conformance rule.
As C/Java: the target type is indicated before the expression between parenthesis; ex: Real r = 1.0; Integer i = (Integer)r;
The predefined operation oclAsType: Real r = 1.0; Integer i = r.oclAsType(Integer);
Notice that cast from a type to one of its supertype is implicit. For instance, the predefined operation max(Real) of Real can be called as monReal.max(12), even if 12 is an Integer, sub type of Real. The contrary is false.
For debugging reasons, it may be useful to show some values during script execution. This is possible thanks to write and writeRaw instructions. These prefix expressions and show the evaluated value. write, unlike writeRaw, will filter the output to be correctly showed in an HTML text. For instance write "toto<br>tutu"; shows toto<br>tutu, writeRaw "toto<br>"; shows on the first line toto, tutu on the second line, <br> being the HTML carriage return.