Content deleted Content added
WP:CHECKWIKI error fix. Broken bracket problem. Do general fixes and cleanup if needed. - using AWB (10072) |
→Evolution: %THEN and %ELSE |
||
(14 intermediate revisions by 10 users not shown) | |||
Line 23:
==Preprocessor operation==
The preprocessor operates by scanning the input text and recognizing declared ''preprocessor names'', also called ''preprocessor identifiers''. The text is copied to the preprocessor output with the preprocessor names replaced with their current values. The name may represent a call to a ''preprocessor procedure'' ([[Macro (computer science)|macro
===Preprocessor data types===
Line 42:
*{{code|%IF}} controls the flow of the preprocessor scan according to the value of a preprocessor expression.
<pre>
%IF preprocessor-expression
%THEN preprocessor unit1
%ELSE preprocessor-unit2
</
The preprocessor-units can be any single preprocessor statement or a preprocessor {{code|DO}}-group.
*{{code|%ITERATE}} transfers control to the {{code|%END}} of the containing preprocessor {{code|DO}}-group, ending the current iteration and beginning the next if needed.
Line 59:
==Preprocessor built-ins==
These are the built-ins for IBM's ''PL/I for MVS and VM'' compiler.<ref name=PLI1.1>{{cite book|last=IBM Corporation|title=IBM PL/I for MVS & VM Language Reference|year=1995}}</ref>{{rp|pp.404–406}} There can be considerable difference
* {{code|COMPILETIME}} — returns the date and time of compilation as a character string such as "15 SEP 12 15:30:00" for September 15, 2012 3:30PM (local time).
* {{code|COUNTER}} — returns a character string containing a number that is "00001" for the first call to {{code|COUNTER}} and increases by one for each subsequent call.
Line 68:
==Example==
The following example for IBM PL/I for OS/2 illustrates the use of a preprocessor procedure to implement a C-like write statement for PL/I.<ref>{{cite web|last=Sturm|first=Eberhard|title=UIO-Makros für Builtin-Funktionen fileread und filewrite|url=
<syntaxhighlight lang="rexx" line highlight="1,25,26">
%uwrite:
procedure keys (File, From, Count);
Line 96:
%end;
%act uwrite;
</syntaxhighlight>
The statement {{code|uwrite file(file_name) from(var_str) count(64);}} generates the following:
<
do;
dcl Count00001 fixed bin (15);
Count00001 = filewrite(file_name, ptradd(addr(var_str), 2), min(length(var_str), 64));
end;
</syntaxhighlight>
==Evolution==
A 1964 report on "NPL",<ref>{{cite book|last=IBM Corporation|title=NPL Technical Report|year=1964|url=http://bitsavers.informatik.uni-stuttgart.de/pdf/ibm/360/pli/320-0908_NPL_Technical_Report_Dec64.pdf}}</ref>{{rp|pp.109–114}}
* <code>%DECLARE</code> – both fixed-length and varying character strings were defined.
* <code>%<var>assignment</var></code>
* <code>%<var>null statement</var></code>
* <code>%IF <var>compile_time_comparison</var> THEN <var>unit</var> [ELSE <var>unit</var>]</code> – this causes one or the other <var>unit</var> to be included in the source.
* <code>%GOTO</code>
"NPL" as defined in this manual was never implemented.
In 1965 an update to IBM's ''PL/I Language specification'' defined an even less ambitious preprocessor language.<ref>{{cite book|last=IBM Corporation|title=IBM Operating System/360 PL/I: Language Specifications (C28-6571-1)|year=1965|url=http://bitsavers.informatik.uni-stuttgart.de/pdf/ibm/360/pli/C28-6571-1_PL_I_Language_Specifications_Jul65.pdf}}</ref>{{rp|pp.131–133}}
* <code>%DECLARE</code>
* <code>%<var>assignment</var></code>
* <code>%<var>null statement</var></code>
* <code>%IF <var>compile_time_comparison</var> THEN GOTO <var>label</var></code> – No <code>ELSE</code> clause was defined.
* <code>%GOTO</code>
This language specification was again never implemented, however a 1966 revision of this manual restored preprocessor procedures with the now-current {{code|%PROCEDURE ... %END}} syntax and brought the specification close to what was actually included in PL/I(F).<ref>{{cite book|last=IBM Corporation|title=IBM Operating System/360 PL/I: Language Specifications (C28-6571-3)|year=1966|url=http://bitsavers.informatik.uni-stuttgart.de/pdf/ibm/360/pli/C28-6571-3_PL_I_Language_Specifications_Jul66.pdf}}</ref>{{rp|pp.132–139}}<ref>{{cite book|last=IBM Corporation|title=IBM System/360 PL/I Reference Manual (C28-8201-3)|year=1969|url=http://bitsavers.informatik.uni-stuttgart.de/pdf/ibm/360/pli/C28-8201-1_PLIrefMan_Jan69.pdf}}</ref>{{rp|pp.154–162}}
* <code>%ACTIVATE</code>
* <code>%DEACTIVATE</code>
Line 129:
* <code>RETURN</code> in a compile-time procedure only.
* <code>%INCLUDE</code>
* <code>
A single compile-time builtin, <code>SUBSTR</code>, was added.
Also in 1966 Robert Rosin published a pair of articles<ref>{{cite journal|last=Rosin|first=Robert|title=PL/I Macro Processor - Progress Report|journal=PL/I Bulletin|date=August 1966|issue=2|url=http://www.iron-spring.com/PLI_Bulletins/PLI_Bulletin_2.pdf|
==See also==
*
==References==
Line 143:
==External links==
*{{cite web
|url = http://publibfp.boulder.ibm.com/
|title = Enterprise PL/I Language Reference (SC27-1460-09): Chapter 21. Preprocessor Facilities
|author = IBM Corporation
|date = October 2009
|
}}
Line 155:
|author = Micro Focus International plc
|year = 2011
|
}}
Line 163:
|author = Kednos Enterprises
|year = 2007
|
}}
*{{cite web
|url = https://sites.google.com/site/plipreproc/
|title = PL/I Preprocessor Wiki
|author = Peter Flass
| year = 2010
|access-date = 2017-12-06
}} Comparison of preprocessor features
{{DEFAULTSORT:PL I preprocessor}}
|