Category:Polyglot:PL/I and PL/M: Difference between revisions
m
→Include Files: typo
(→Include Files: Removed declaration of "eof") |
m (→Include Files: typo) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 4:
<br><br>
===PL/I and PL/M===
Although similar, [[PL/I]] and [[PL/M]] are not the same language.
<p>
In this, the PL/M language as implemented by Gary Kildall's original [[8080 PL/M Compiler]] will be considered.
Line 19:
* The only types are BYTE and ADDRESS - unsigned 8 and 16 bit integers.
* Identifiers cannot contain underscores - the PL/M compiler treats them as spaces - dollar signs can appear but are ignored.
* Keywords are reserved in PL/M.
<br><br>
PL/I features of interest:
Line 29 ⟶ 30:
* PL/I has a range of types, none of which are called BYTE or ADDRESS.
* Identifiers can contain underscores and some implementations allow dollar signs.
* Keywords are not reserved in PL/I.
===Arrays===
In PL/I when an array is declared, the lower boiund can be omitted and defaults to 1. The upper bound is the dimension specified in the declaration.<br>
E.g. <code>declare a ( 100 ) fixed binary;</code> declares an array of 100 integers, the subscripts range from 1 to 100.<br><br>
In PL/M when an array is declared, the lower bound cannot be specified and is always 0. The upper bound is one less than the dimension specified in the declaration.<br>
E.g. <code>DECLARE A( 101 ) ADDRESS;</code> declares an array of 101 integers, the subscripts range form 0 to 100.
<br><br>
PL/M only allows arrays with a single subscript to be declared. PL/I allows multi-dimensional arrays.
<br><br>
===Implementation===
Line 53 ⟶ 64:
A suitable file for PL/I definitions could be:
<br>
<
%replace true by '1'b, false by '0'b;
Line 119 ⟶ 130:
return ( mod( a, b ) );
end modf;
/* returns not p */
not: procedure( p )returns( bit( 1 ) );
declare p bit( 1 );
return( ^ p );
end not;
toupper: procedure( c )returns( character( 1 ) );
Line 126 ⟶ 143:
/* end pg.inc */</
For PL/M, the following definitions would be used, with the appropiate subset cut-and-pasted into the
<syntaxhighlight lang=pli>
<lang pli> DECLARE BINARY LITERALLY 'ADDRESS', CHARACTER LITERALLY 'BYTE';▼
DECLARE
DECLARE
DECLARE STATIC LITERALLY ' ', RETURNS LITERALLY ' ';
DECLARE FALSE LITERALLY '0', TRUE LITERALLY '1';
BDOSF: PROCEDURE( FN, ARG )BYTE;
DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
Line 172 ⟶ 192:
DECLARE ( A, B )ADDRESS;
RETURN( A MOD B );
END MODF;
MIN: PROCEDURE( A, B ) ADDRESS;
DECLARE ( A, B ) ADDRESS;
IF A < B THEN RETURN( A ); ELSE RETURN( B );
END MIN;
MAX: PROCEDURE( A, B ) ADDRESS;
DECLARE ( A, B ) ADDRESS;
IF A > B THEN RETURN( A ); ELSE RETURN( B );
END MAX;</syntaxhighlight>
Note the lack of comments in the PL/M "include" file - this is because the definitions will be commented out for PL/I compilers by having a "/*" starting in column 81 preceeding the definitions and /* */ follow them.
|