WESCL has the following types of operators:
Assignment Operator
| Operator | Description | Example |
|---|---|---|
| = | An assignment operator assigns the value to the left operand. | M1 = M2 |
Comparison Operators
| Operator | Description | Example |
|---|---|---|
| Equal (==) | Returns true if the operands are equal. | M1 == M2 |
| Not equal (!=) | Returns true if the operands are not equal. | M1 != M2 |
| Greater than (>) | Returns true if the left operand is greater than the right operand. | M1 > M2 |
| Greater than or equal (>=) | Returns true if the left operand is greater than or equals the right operand. | M1 >= M2 |
| Less than (<) | Returns true if the left operand is less than the right operand. | M1 < M2 |
| Less than or equal (<=) | Returns true if the left operand is less than or equals the right operand. | M1 <= M2 |
Arithmetic Operators
| Operator | Description | Example |
|---|---|---|
| Multiplication (*) | Returns the product of two operands. | M1 * M2 |
| Division (/) | Returns the quotient of two operands. | M1 / M2 |
| Modulus (%) | Returns the integer remainder of dividing two operands. | M1 % M2 |
| Addition (+) | Returns the sum of two operands. | M1 + M2 |
| Subtraction (-) | Returns difference between two operands. | M1 - M2 |
| Unary minus operator (-) | Returns the negation of its operand. | -M1 |
Logical Operators
| Operator | Description | Example |
|---|---|---|
| Logical AND (&&) | Returns true if both operands are true; otherwise, returns false. | operand1 && operand2 |
| Logical OR (||) | Returns true if either operand is true; if both are false, returns false. | operand1 || operand2 |
| Logical NOT (!) | Returns false if its single operand can be converted to true; otherwise, returns true. | !operand |
Special Operators
| Operator | Description | Example |
|---|---|---|
| Comma operator (,) | Separator of multiple assignments in the action part of an instruction. | M1 = M2, M2 = M3, M3 = M4 |
| Group () | Parentheses allow overriding operator precedence. Up to 5 levels of nesting is allowed. | (M1 + M2) * (M3 - M4) |
The precedence of operators determines their priorities when evaluating an expression.
The following table shows the precedence of operators, from the highest to the lowest.
| Operator type | Individual operators |
|---|---|
| group | ( ) |
| negation | ! - |
| multiply | * |
| divide | / |
| modulus | % |
| addition | + |
| subtraction | - |
| relational | < <= > >= |
| equality | == != |
| logical-and | && |
| logical-or | || |
| assignment | = |
| comma | , |