Execution of input text
The input text, after replacement of any active identifiers by new values, is copied into the preprocessor output. Invalid characters (part of a character constant or comment) are replaced with blanks in the preprocessor output.
To determine replacements, the input text is scanned for the following occurrences:
- Characters that are not part of this PL/I character set
These characters are treated as delimiters and are otherwise copied to this output unchanged.
- PL/I character constants or PL/I comments
These are passed through unchanged from input text to preprocessor output by the preprocessor unless they appear in an argument list to an active preprocessor procedure. However, this can cause mismatches between input and output lines for strings or comments extending over several lines, when the input and output margins are different. This is especially true when V format input is used, because the output is always F format, with margins in columns 2 and 72. The output line numbering in these cases also shows this inevitable mismatch.
- Active identifiers
For an identifier to be replaced by a new value, the identifier must be first activated for replacement. Initially, an identifier can be activated by its appearance in a %DECLARE statement. It can be deactivated by executing a %DEACTIVATE statement, and it can be reactivated by executing a %ACTIVATE or %DECLARE statement.
An identifier that matches the name of an active preprocessor variable is replaced in the preprocessor output by the value of the variable.
When an identifier matches the name of an active preprocessor function (either programmer-written or built-in), the procedure is invoked and the invocation is replaced by the returned value.
Identifiers can be activated with either the RESCAN or the NORESCAN options. If the NORESCAN option applies, the value is immediately inserted into the preprocessor output. If the RESCAN option applies, a rescan is made during which the value is tested to determine whether it, or any part of it, should be replaced by another value. If it cannot be replaced, it is inserted into the preprocessor output; if it can be replaced, replacement activity continues until no further replacements can be made. Thus, insertion of a value into the preprocessor output takes place only after all possible replacements have been made.
Replacement values must not contain % symbols, unmatched quotation marks, or unmatched comment delimiters.
Preprocessor statements should be on separate lines from normal
text. The one exception is the null statement when it is specified
in the form %;. Such a null statement can be used
to concatenate replacement text and regular text. For example, suppose
that the input text is as follows:
%dcl A char;
%A = 'B';
dcl A%C fixed bin(31);
The preprocessor would produce the output text:
dcl BC fixed bin(31);
The scan terminates when an attempt is made to scan beyond the last character in the preprocessor input. The preprocessor output is then complete and compilation can begin.