Category:Polyglot:PL/I and PL/M: Difference between revisions

m
(→‎PL/I and PL/M: Notes on arrays)
 
(4 intermediate revisions by the same user not shown)
Line 64:
A suitable file for PL/I definitions could be:
<br>
<langsyntaxhighlight lang=pli>/* pg.inc: PL/I definitions for "polyglot PL/I and PL/M programs" compiled with PL/I */
 
%replace true by '1'b, false by '0'b;
Line 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 137 ⟶ 143:
 
 
/* end pg.inc */</langsyntaxhighlight>
 
For PL/M, the following definitions would be used, with the appropiate subset cut-and-pasted into the programLprogram:
<syntaxhighlight lang=pli>
<lang pli> DECLARE BINARY LITERALLY 'ADDRESS', CHARACTER LITERALLY 'BYTE';
DECLARE SADDR BINARY LITERALLY '.ADDRESS', BIT CHARACTER LITERALLY 'BYTE';
DECLARE FIXED LITERALLY ' ', RETURNSBIT LITERALLY ' BYTE';
DECLARE STATIC LITERALLY ' ', RETURNS LITERALLY ' ';
DECLARE TRUE FALSE LITERALLY '10', FALSE TRUE LITERALLY '01';
<lang pli> DECLARE BINARYHBOUND LITERALLY 'ADDRESSLAST', CHARACTER SADDR LITERALLY 'BYTE.';
BDOSF: PROCEDURE( FN, ARG )BYTE;
DECLARE FN BYTE, ARG ADDRESS; GOTO 5; END;
Line 185 ⟶ 192:
DECLARE ( A, B )ADDRESS;
RETURN( A MOD B );
END MODF;</lang>
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.
3,045

edits