Operators and precedence
Operators combine operands (variables, literals, function calls) into expressions. This page lists the operators logiccloud supports and the exact precedence and associativity used by the parser.
Assignment
Section titled “Assignment”| Operator | Meaning |
|---|---|
:= | Assignment. Assigns the value of an expression to a variable. |
?= | Reference assignment attempt. Assigns a reference only if the runtime types are compatible, otherwise leaves the target NULL. See references. |
Assignment is a statement, not an expression operator — it cannot appear inside a larger expression.
Arithmetic operators
Section titled “Arithmetic operators”| Operator | Meaning |
|---|---|
** | Exponentiation (power) |
* | Multiplication |
/ | Division |
MOD | Modulo (integer remainder) |
+ | Addition (binary) / unary plus |
- | Subtraction (binary) / unary negation |
Comparison operators
Section titled “Comparison operators”All comparison operators sit at the same precedence level and produce a
BOOL result.
| Operator | Meaning |
|---|---|
= | Equal |
<> | Not equal |
< | Less than |
> | Greater than |
<= | Less than or equal |
>= | Greater than or equal |
Bitwise / boolean operators
Section titled “Bitwise / boolean operators”These operate bit-by-bit on bit-string types and logically on BOOL. In the
grammar & and AND are the same operator, and AND, &, OR and XOR
all share a single precedence level.
| Operator | Meaning |
|---|---|
AND, & | Logical / bitwise AND |
OR | Logical / bitwise OR |
XOR | Logical / bitwise exclusive OR |
NOT | Logical / bitwise negation (unary) |
enabled := running AND NOT faulted;mask := flagsA & flagsB; // & is ANDPrecedence and associativity
Section titled “Precedence and associativity”From highest to lowest precedence. Within a precedence level the binary operators are left-associative (evaluated left to right); parentheses override precedence entirely.
| Precedence | Operators | Notes |
|---|---|---|
| Highest | () | Parenthesized sub-expression |
Func(args) | Function / method call | |
** | Exponentiation | |
unary +, -, NOT | Applied to a single operand | |
*, /, MOD | ||
+, - (binary) | ||
=, <>, <, >, <=, >= | All comparisons at one level | |
| Lowest | AND / &, OR, XOR | All bitwise/boolean ops at one level |