TTCN-3 supports a number of predefined operators that may be used in the terms of TTCN-3 expressions. The predefined operators fall into seven categories:
These operators are listed in the following table:
Category | Operator | Symbol or Keyword |
---|---|---|
Arithmetic operators | addition | + |
substraction | - | |
multiplication | * | |
division | / | |
modulo | mod | |
remainder | rem | |
String operators | concatenation | & |
Relational operators | equal | == |
less than | < | |
greater than | > | |
not equal | != | |
greater than or equal | >= | |
less than or equal | <= | |
Logical operators | logical not | not |
logical and | and | |
logical or | or | |
logical xor | xor | |
Bitwise operators | bitwise not | not4b |
bitwise and | and4b | |
bitwise or | or4b | |
bitwise xor | xor4b | |
Shift operators | shift left | << |
shift right | >> | |
Rotate operators | rotate left | <@ |
rotate right | @> |
The precedence of these operators is shown in the table below. Within any row in this table, the listed operators have equal precedence. If more than one operator of equal precedence appears in an expression, the operations are evaluated from left to right. Parentheses may be used to group operands in expressions, in which case a parenthesized expression has the highest precedence for evaluation.
Priority | Operator type | Operator |
---|---|---|
highest | ( ... ) | |
Unary | +, - | |
Binary | *, /, mod, rem | |
Binary | +, -, & | |
Unary | not4b | |
Binary | and4b | |
Binary | xor4b | |
Binary | or4b | |
Binary | <<, >>, <@, @> | |
Binary | <, >, <=, >= | |
Binary | ==, != | |
Unary | not | |
Binary | and | |
Binary | xor | |
lowest | Binary | or |