ALGOL 68RS: Difference between revisions
m ({{implementation|ALGOL 68}}) |
(→Example: lang -> syntaxhighlight) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{wikipedia}}{{implementation|ALGOL 68}} |
{{wikipedia}}{{implementation|ALGOL 68}} |
||
<br> |
|||
⚫ | ALGOL 68RS from [ |
||
<br> |
|||
⚫ | ALGOL 68RS from [[wp:Royal_Signals_and_Radar_Establishment|RSRE]] was a portable compiler system written in ALGOL 68RS (bootstrapped from [[ALGOL 68R]]), and implemented on a variety of systems including the [[wp:wiki_ICL_2900_Series|ICL 2900]]/[[wp:ICL_Series_39|Series 39]], [[Multics]] and [[wp:VAX|DEC VAX/VMS]]. |
||
The language was based on the Revised Report, but with similar subset restrictions to ALGOL 68R. |
The language was based on the Revised Report, but with similar subset restrictions to [[ALGOL 68R]]. |
||
This compiler survives in the form of an Algol68-to-C compiler aka [[ELLA ALGOL 68]]. |
This compiler survives in the form of an [[Algol68toc|Algol68-to-C]] compiler aka [[ELLA ALGOL 68]]. |
||
== Modules == |
== Modules == |
||
Line 9: | Line 11: | ||
Syntax: |
Syntax: |
||
⚫ | |||
<pre> |
|||
⚫ | |||
[ CONTEXT holename IN progtitle ] |
[ CONTEXT holename IN progtitle ] |
||
[ USE uselist ] |
[ USE uselist ] |
||
enclosed clause |
enclosed clause |
||
FINISH |
FINISH</lang> |
||
⚫ | |||
</pre> |
|||
<pre> |
|||
⚫ | |||
CONTEXT holename IN progtitle |
CONTEXT holename IN progtitle |
||
[ USE uselist ] |
[ USE uselist ] |
||
decsbody |
decsbody |
||
KEEP keeplist |
KEEP keeplist |
||
FINISH |
FINISH</lang> |
||
</pre> |
|||
=== Example === |
=== Example === |
||
⚫ | |||
<pre> |
|||
⚫ | |||
BEGIN |
BEGIN |
||
MODE PIECE = STRUCT(...); |
MODE PIECE = STRUCT(...); |
||
Line 36: | Line 32: | ||
HERE displaying(PIECE, pieces, BOARD, game); |
HERE displaying(PIECE, pieces, BOARD, game); |
||
... |
... |
||
END |
END</lang> |
||
</pre> |
|||
⚫ | |||
<pre> |
|||
⚫ | |||
CONTEXT thinking IN chess |
CONTEXT thinking IN chess |
||
... |
... |
||
FINISH |
FINISH</syntaxhighlight> |
||
</pre> |
|||
An entire program can thus be '''composed''' of pieces of other modules, particularly if a ''hole'' contains a sub-''hole'' (eg displaypiece), then this ''hole'' can in-turn be pulled into the composition. |
An entire program can thus be '''composed''' of pieces of other modules, particularly if a ''hole'' contains a sub-''hole'' (eg displaypiece), then this ''hole'' can in-turn be pulled into the composition. |
||
Example: |
Example: |
||
⚫ | |||
<pre> |
|||
⚫ | |||
COMPOSE game(thinking=thinkmodule, displaying=displayingmodule(piece=displaypiece)) |
COMPOSE game(thinking=thinkmodule, displaying=displayingmodule(piece=displaypiece)) |
||
FINISH |
FINISH</lang> |
||
</pre> |
Latest revision as of 19:50, 26 August 2022
This page uses content from Wikipedia. The original article was at ALGOL 68RS. The list of authors can be seen in the page history. As with Rosetta Code, the text of Wikipedia is available under the GNU FDL. (See links for details on variance) |
ALGOL 68RS from RSRE was a portable compiler system written in ALGOL 68RS (bootstrapped from ALGOL 68R), and implemented on a variety of systems including the ICL 2900/Series 39, Multics and DEC VAX/VMS.
The language was based on the Revised Report, but with similar subset restrictions to ALGOL 68R. This compiler survives in the form of an Algol68-to-C compiler aka ELLA ALGOL 68.
Modules
ALGOL 68RS allow the programmer the ability of creating modules, these can be used by other programs and also allowed separate compilation.
Syntax: <lang algol68>PROGRAM [ (holelist ) ] progtitle [ CONTEXT holename IN progtitle ] [ USE uselist ] enclosed clause FINISH</lang> <lang algol68>DECS dectitle CONTEXT holename IN progtitle [ USE uselist ] decsbody KEEP keeplist FINISH</lang>
Example
PROGRAM (thinking, displaying) chess
BEGIN
MODE PIECE = STRUCT(...);
[12]PIECE pieces;
...
HERE thinking(PIECE, pieces, BOARD, game);
...
HERE displaying(PIECE, pieces, BOARD, game);
...
END</lang>
<lang algol68>PROGRAM thinkmodule
CONTEXT thinking IN chess
...
FINISH
An entire program can thus be composed of pieces of other modules, particularly if a hole contains a sub-hole (eg displaypiece), then this hole can in-turn be pulled into the composition.
Example: <lang algol68>PROGRAM abc COMPOSE game(thinking=thinkmodule, displaying=displayingmodule(piece=displaypiece)) FINISH</lang>