Delimiters and operators

Delimiters and operators are used to separate identifiers and constants.

Table 1 shows delimiters.

Table 1. Delimiters
Name Delimiter Use
Comma , Separates elements of a list; precedes the BY NAME option
Period . Connects elements of a qualified name; decimal or binary point
Semicolon ; Terminates a statement
Equal sign = Indicates assignment or, in a conditional expression, equality
Colon : Connects prefixes to statements; connects lower-bound to upper-bound in a dimension attribute; used in RANGE specification of DEFAULT statement
Blank b Separates elements
Parentheses ( ) Enclose lists, expressions, iteration factors, and repetition factors; enclose information associated with various keywords
Locator –> Denotes locator qualification (pointers and offsets)
=> Denotes locator qualification (handles)
Percent % Indicates %statements and %directives
Note: Omitting certain symbols can cause errors that are difficult to trace. Common errors are unbalanced quotation marks, unmatched parentheses, unmatched comment delimiters, and missing semicolons.

Table 2 shows operators.

Table 2. Operators
Operator type Character(s) Description
Arithmetic + Addition or prefix plus
- Subtraction or prefix minus
* Multiplication
Division
** Exponentiation
Comparison = Equal to
¬= or <> Not equal to
< Less than
¬< Not less than
> Greater than
¬> Not greater than
<= Less than or equal to
>= Greater than or equal to
Logical ¬ Not, Exclusive-or
& And
| Or
String Concatenation

The characters used for delimiters can be used in other contexts. For example, the period is a delimiter when used in name qualification (for example, Weather.Temperature), but is a decimal point in an arithmetic constant (for example, 3.14).

Blanks

You can surround each operator or delimiter with blanks (b).

One or more blanks must separate identifiers and constants that are not separated by some other delimiter. The only exception to this rule is that the identifiers P, PIC and PICTURE can be followed by a character string without any intervening blanks. Any number of blanks can appear wherever one blank is allowed.

Blanks cannot occur within identifiers, composite symbols, or constants (except in character, mixed, widechar and graphic string constants). See the following examples.

ab+bc is equivalent to Ab + Bc
Table(10) is equivalent to TABLEb(b10bbb)
First,Second is equivalent to first,bsecond
AtoB is not equivalent to AbtobB

Other cases that require or allow blanks are noted where those language features are discussed.

Start of change

Comments

Comments are allowed wherever blanks are allowed as delimiters. A comment is treated as a blank and used as a delimiter. Comments are ignored and do not affect the logic of a program.

There are two kinds of comments:
  • The /* (slash, asterisk) characters, followed by any sequence of characters (including new lines), followed by the */ characters. In this case, the commented text ends with the */ characters, and the commented text may span multiple lines.
  • The // (two slashes) characters followed by any sequence of characters. In this case, the commented text ends with the end of the line containing the // characters.
The first kind of comment can be entered on one or more lines, as in the following example:
A = /* This comment is on one line */ 21;

    /* This comment spans
       two lines          */
The second kind of comment ends on the line where it starts, as in the following example:
A = 21 ; // This comment ends with the end of this line
In the following example, what appears to be a comment is actually a character string constant because it is enclosed in quotation marks.
A = '/* This is a constant, not a comment */' ;

Comments cannot be nested. However, the %DO SKIP: statement can be used as a way of "commenting out" code that contains comments.

End of change





Published: 23 December 2018