The evaluation of expression takes place by means of processing the operators according to certain binding rules. The operator with the strongest binding is processed first, then the operator with the next strongest binding, etc., until all operators have been processed.
Operators with equal binding strength are processed from left to right.
Operation |
Symbol |
Binding strength |
---|---|---|
Put in parentheses |
(expression) |
Strongest binding |
Function call |
Function name (parameter list) |
|
Exponentiation |
EXPT |
|
Negate Building of complements |
- NOT |
|
Multiply Divide Modulo |
* / MOD |
|
Add Subtract |
+ - |
|
Compare |
<,>,<=,>= |
|
Equal to Not equal to |
= <> |
|
Boolean AND |
AND |
|
Boolean XOR |
XOR |
|
Boolean OR |
OR |
Weakest binding |
Instruction type |
Example |
---|---|
Assignment |
A:=B; CV := CV + 1; C:=SIN(X); |
Calling a function block and use of the FB output |
CMD_TMR(IN := %IX5, PT := 300); A:=CMD_TMR.Q |
RETURN |
RETURN; |
IF |
D:=B*B; IF D<0.0 THEN C:=A; ELSIF D=0.0 THEN C:=B; ELSE C:=D; END_IF; |
CASE |
CASE INT1 OF 1: BOOL1 := TRUE; 2: BOOL2 := TRUE; ELSE BOOL1 := FALSE; BOOL2 := FALSE; END_CASE; |
FOR |
J:=101; FOR I:=1 TO 100 BY 2 DO IF ARR[I] = 70 THEN J:=I; EXIT; END_IF; END_FOR; |
WHILE |
J:=1; WHILE J<= 100 AND ARR[J] <> 70 DO J:=J+2; END_WHILE; |
REPEAT |
J:=-1; REPEAT J:=J+2; UNTIL J= 101 OR ARR[J] = 70 END_REPEAT; |
EXIT |
EXIT; |
Empty instruction |
; |