Skip to content

Expressions

Expressions in the itemis CREATE statechart language are similar to expressions in other programming languages. The language provides operators for logical expressions, number arithmetic, bitwise arithmetic, and bit shifting.

The type of a logical expression is boolean.

Logical AND

expr1 && expr2

Logical OR

expr1 ||  expr2

Logical NOT

!expr1

Conditional expression

expr1 ? expr2 : expr3

If expr1 evaluates to true, this returns expr2, else exp3. This can be used to assign values to variables:

y = x > 5 ? 1 : 2

This does the same as the following snippet of C code:

if(x > 5) {
  y = 1;
} else {
  y = 2;
}

Bitwise XOR

expr1 ^ expr2

Bitwise OR

expr1 | expr2

Bitwise AND

expr1 & expr2

Logical relations and shift operators

less than <
equal or less than <=
greater than >
equal or greater than >=
equal ==
not equal !=
shift left <<
shift right >>

Binary arithmetic operators

plus +
minus -
multiply *
divide /
modulo %

Unary arithmetic operators

positive +
negative -
complement ~