Category:ALGOL 68: Difference between revisions
→Coding style of samples: tweak
EdgeEffect (talk | contribs) (→Resources: added VS-Code syntax highlighting plugin to editor modes list) |
(→Coding style of samples: tweak) |
||
(12 intermediate revisions by the same user not shown) | |||
Line 24:
==Execute an ALGOL 68 program online==
* http://www.compileonline.com/execute_algol_online.php
* Algol 68G is available as one of the languages at https://tio.run
==Tasks not implemented in ALGOL 68==
[[Tasks not implemented in ALGOL 68]]
==Grammar==
The formal definition of Algol 68 is given by a "Two-Level" or [[wp:Van Wijngaarden grammar|"Van Wijngaarden" grammar]].
Line 63 ⟶ 68:
*Dec. 1968: Report on the Algorithmic Language ALGOL 68 - Offprint from Numerische Mathematik, 14, 79-218 (1969); Springer-Verlag. - Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck and C.H.A. Koster.
*Sep 1973: Revised Report on the Algorithmic Language Algol 68 - Springer-Verlag 1976 - Edited by: A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck, C.H.A. Koster, M. Sintzoff, C.H. Lindsey, L.G.L.T. Meertens and R.G. Fisker.
==Coding style of samples, alphabets and stropping==
Click "Expand" for more details.
<div class="mw-collapsible mw-collapsed" style="width:
<div class="mw-collapsible-content" style="padding-left:2em;">
Line 92 ⟶ 97:
FINISH
|}
<br><br>'''Alphabets'''
<br><br>▼
Notionally, Algol 68 source is written in two alphabets. The reserved words, mode indicants (type names) and operators that are non-symbolic (.e.g. '''and''', '''or''', ...) are generally referred to as "bold words" and usually shown in a bold font in literature. Words that are identifiers (used for "variable" names, procedure names, structure member names, ...) are in a separate, non-bold font.<br>
The [https://www.softwarepreservation.org/projects/ALGOL/manual/a68s.txt/view Manual for CMU ALGOL 68S (on softwarepreservation.org)] refers to the non-bold words as being in timid face.
<br><br>'''Examples of different program representations'''
<br><br>
At the time when ALGOL 68 was defined some predominant computers had
24 or 36 bit words, with 6 bit character sets. Hence it was desirable that
ALGOL 68 should be able to run on machines with only uppercase.
As multiple fonts were generally unavailable, a method of identifying the bold words was required.<br>
The official spec provided for different representations of the same
program.
and Point stropping (preceeding the bold words with a dot)
were used.<br>
In RES stropping some language-defined bold words are not preceded by a dot.
A pragmatic comment may have been required to indicate which
stropping convention was to be used, as in some of the examples below.<br>
Upper stropping (representing the bold words by upper case and
non-bold words in lower case) was introduced by Algol 68R.
Upper stropping is used by Algol 68RS and is one of the options for Algol 68G.<br>
Rutgers ALGOL 68 uses quote stropping.
Most of the samples on Rosetta Code use Upper stropping.<br><br>
Examples (pragmatic comments to set the stropping regime not shown):
{|border="1" style="border-collapse: collapse; border:
|| Algol68 as typically published
'''mode''' '''xint''' = '''int''';
'''xint''' sum sq:=0;
Line 120 ⟶ 131:
sum sq+:=i↑2
'''od'''
||
'mode' 'xint' = 'int';
'xint' sum sq:=0;
Line 129 ⟶ 139:
sum sq+:=i↑2
'od'
|| POINT stropping
.MODE .XINT = .INT;
.XINT SUM SQ:=0;
Line 148:
.OD
|| RES stropping
mode .xint = int;
.xint sum sq:=0;
Line 157 ⟶ 156:
od
|| Upper stropping
MODE XINT = INT;
XINT sum sq:=0;
Line 173 ⟶ 171:
<br>
Click "Expand" for more details.
<div class="mw-collapsible mw-collapsed" style="width:
<div class="mw-collapsible-content" style="padding-left:2em;">
Line 199 ⟶ 197:
g
||Right hand side of:
* Identity-declarations, as "~" in: <
* Initialisations, as "~" in: <
Also:
* Actual-parameters of calls, as "~" in:<
* Enclosed clauses of casts, as "~" in: <
* Units of routine-texts
* Statements yielding VOID
* All parts (but one) of a balanced clause
* One side of an identity relation, as "~" in: <
|bgcolor=aaaaff rowspan=4 width="50px"| deproc- eduring
|bgcolor=aaeeaa rowspan=3 width="50px"| all '''soft''' then weak deref- erencing
Line 215 ⟶ 213:
|colspan=1 bgcolor=ffcccc|
Widening occurs if there is no loss of precision. For example: An INT will be coerced to a REAL, and a REAL will be coerced to a LONG REAL. But not vice-versa. Examples:
<
INT to REAL
REAL to COMPL
BITS to []BOOL
BYTES to STRING</
A variable can also be coerced (rowed) to an array of length 1.
For example:
<
REAL to [1]REAL</
|-
!F<br>
Line 231 ⟶ 229:
m
||
*Operands of formulas as "~" in:<
*Parameters of transput calls
|colspan=3 bgcolor=ffcc99| Example:
<
|-
!M<br>
Line 243 ⟶ 241:
* Trimscripts (yielding INT)
* Enquiries: e.g. as "~" in the following
<
<
* Primaries of calls (e.g. sin in sin(x))
|colspan=4 bgcolor=ffee99|Examples:
<
REF REF REF INT to INT</
|-
!W<br>
Line 255 ⟶ 253:
k
||
* Primaries of slices, as in "~" in: <
* Secondaries of selections, as "~" in: <
|colspan=5 bgcolor=aaeeaa|Examples:
<
REF REF INT to REF INT
REF REF REF REAL to REF REAL
REF REF REF REF STRUCT to REF STRUCT</
|-
!S<br>
Line 267 ⟶ 265:
f<br>
t
|| The LHS of assignments, as "~" in: <
|colspan=6 bgcolor=aaaaff| Example:
* deproceduring of: <
|}
For more details about Primaries and Secondaries refer to [[Operator_precedence#ALGOL_68|Operator precedence]].
Line 286 ⟶ 284:
== Library code used in Rosetta Code samples ==
[https://rosettacode.org/wiki/
[https://rosettacode.org/wiki/Category:ALGOL_68-primes Prime related]<br/>
▲<br>
[https://rosettacode.org/wiki/Category:ALGOL_68-rows Row (array) related]<br/>
[https://rosettacode.org/wiki/Category:ALGOL_68-l-system L-System related]
== Tools ==
[[Syntax_highlighting_using_Mediawiki_formatting#ALGOL 68|Format an upper-stropped Algol 68 source with Mediawiki markup]]<br/>
[[Compiler/Simple_file_inclusion_pre_processor#ALGOL 68|Implement ''read'' and ''include'' pragmatic-comments for compilers that don't support file inclusion]]
{{language programming paradigm|Concurrent}}
|