Examples and operator structure
Typical examples of conditional operator, available in "COMPAS":
- IF a = 1 THEN s:=1 ELSE s:=0;
- IF a = 1 THEN s:=1;
- IF a = 1 THEN BEGIN s:=1; q:=s+1 END ELSE BEGIN s:=0; q:=0 END;
- IF c < ' ' THEN c:=CHR(0);
- IF b THEN w:=w-1;
Possible structures of this operator can be written the following way:
IF {condition} THEN {operator1} ELSE {operator2} ;
IF {condition} THEN {operator1} ;
IF {BOOLEAN variable} THEN {operator1} ELSE {operator2} ;
IF {BOOLEAN variable} THEN {operator1} ;
Note, that instead of {operator1} and {operator2} several operators,
confined between reserved words BEGIN and END - so called
compound statement - can be used..
The scheme of full IF operator compilation is set below:

And the short variant of the operator (without ELSE):

Back to: