Category:Polyglot:PL/I and PL/M: Difference between revisions
Content added Content deleted
(Created stub page for Polyglot:PL/I and PL/M) |
(Added some details) |
||
Line 1:
{{stub}}{{language|Polyglot:PL/M and PL/I}}
A [[Polyglot]] program is a program whose source is a valid program in two or more languages.
<br><br>
Although similar, [[PL/I]] and [[PL/M]] are not the same language. However some features of the languages can be exploited to make sources that are valid in both languages - although some stylisation is required.
<p>
In this, the PL/M language as implemented by Gary Kildall's original 8008/8080 compiler will be considered.
<br><br>
8080 PL/M features of interest:
* The compiler ignores everything after column 80 of a source line.
* The compiler ignores lower case letters and many "special" characters.
* PL/M has a parameterless macro facility.
* The PL/M source must end with an EOF keyword - everything after it is ignored.
* The source must start with 100H: which sets the origin for CP/M programxs.
* A PL/M program is a sequence of statements and declarations, not a main procedure.
* PL/M has no builtin I/O statements - under CP/M it is possible to call OS routines.
* MOD is an operator, AND, OR and NOT are keywords.
* The only types are BYTE and ADDRESS - unsigned 8 and 16 bit integers.
* Identifiers cannot contain underscores - the PL/M compiler ignores them - dollar signs can appear but are ignored.
<br><br>
PL/I features of interest:
* PL/I is not (usually) case sensitive.
* PL/I has a powerful in-built pre-proessor, however this is not implemented in all PL/I compilers.
* A PL/I programs consists of a main procedure which contains all declarations and statements.
* The main procedure is declared as having "options(main)".
* I/O statements are built in to the language.
* MOD is a function, & | and ^ (or ¬) are used for AND, OR and NOT.
* 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.
===Implementation===
The following stratagy could be used:
<br><br>
* The program will start with <code>n100H: procedure options (main);</code> where the "(main)" starts in column 81.
* after the procedure header, a variable called eof will be declared with <code>declare eof fixed binary;</code>.
* The procedure header and the declaration of eof will be in lower case except for the final "H" of "100H! - there will be no digits in the procedure name, other than the final "100"
* an assignment to EOF will appear immediately before the final "end" of the program - EOF will be specified in upper case.
* Code that is specific to PL/M will be commented out by having the opening "/*" of the comment appear in column 81.
* The code that is specific to PL/M will have "/* */" at the end - the "/* */" will terminate before column 81.
* Code that is specific to PL/I will generally be commented out by placing "/* */" in column 78, so that the "*/" is invisible to the PL/M compiler.
* Additionally, some PL/I code can be commented out by using a macro to add a "/*" to a PL/I keyword and following the code with "/* */".
<br><br>
See below for some examples.
|
Revision as of 21:10, 13 December 2021
Polyglot:PL/I and PL/M
This programming language may be used to instruct a computer to perform a task.
Listed below are all of the tasks on Rosetta Code which have been solved using Polyglot:PL/I and PL/M.
This programming language may be used to instruct a computer to perform a task.
See Also: |
|
---|
A Polyglot program is a program whose source is a valid program in two or more languages.
Although similar, PL/I and PL/M are not the same language. However some features of the languages can be exploited to make sources that are valid in both languages - although some stylisation is required.
In this, the PL/M language as implemented by Gary Kildall's original 8008/8080 compiler will be considered.
8080 PL/M features of interest:
- The compiler ignores everything after column 80 of a source line.
- The compiler ignores lower case letters and many "special" characters.
- PL/M has a parameterless macro facility.
- The PL/M source must end with an EOF keyword - everything after it is ignored.
- The source must start with 100H: which sets the origin for CP/M programxs.
- A PL/M program is a sequence of statements and declarations, not a main procedure.
- PL/M has no builtin I/O statements - under CP/M it is possible to call OS routines.
- MOD is an operator, AND, OR and NOT are keywords.
- The only types are BYTE and ADDRESS - unsigned 8 and 16 bit integers.
- Identifiers cannot contain underscores - the PL/M compiler ignores them - dollar signs can appear but are ignored.
PL/I features of interest:
- PL/I is not (usually) case sensitive.
- PL/I has a powerful in-built pre-proessor, however this is not implemented in all PL/I compilers.
- A PL/I programs consists of a main procedure which contains all declarations and statements.
- The main procedure is declared as having "options(main)".
- I/O statements are built in to the language.
- MOD is a function, & | and ^ (or ¬) are used for AND, OR and NOT.
- 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.
Implementation
The following stratagy could be used:
- The program will start with
n100H: procedure options (main);
where the "(main)" starts in column 81. - after the procedure header, a variable called eof will be declared with
declare eof fixed binary;
. - The procedure header and the declaration of eof will be in lower case except for the final "H" of "100H! - there will be no digits in the procedure name, other than the final "100"
- an assignment to EOF will appear immediately before the final "end" of the program - EOF will be specified in upper case.
- Code that is specific to PL/M will be commented out by having the opening "/*" of the comment appear in column 81.
- The code that is specific to PL/M will have "/* */" at the end - the "/* */" will terminate before column 81.
- Code that is specific to PL/I will generally be commented out by placing "/* */" in column 78, so that the "*/" is invisible to the PL/M compiler.
- Additionally, some PL/I code can be commented out by using a macro to add a "/*" to a PL/I keyword and following the code with "/* */".
See below for some examples.
Pages in category "Polyglot:PL/I and PL/M"
The following 9 pages are in this category, out of 9 total.