Rutgers ALGOL 68: Difference between revisions

lang -> syntaxhighlight
(lang -> syntaxhighlight)
 
(7 intermediate revisions by the same user not shown)
Line 1:
{{implementation|ALGOL 68}}{{stub}}
=== Rutgers University Algol 68 Interpreter - runs under WIndows, Linux and DOS ===
 
Not all the exotic features are implemented. In particular there are no semaphores, formats and parallel-clauses.
<br>
Long and short modes are not implemented and will cause errors to be reported, if used.
<br>
The stadard prelude has a number of ommissions, particularly transput which is restricted to standard input and output only.
<br>
Transput event routines are also not supported.
<br>
<br>
Line 14 ⟶ 6:
* Tar ball => http://www.renyi.hu/~csirmaz/algol-68
* Laci Csirmaz, DIMACS at Rutgers, 1990; CEU, Hungary, 2000
<br><br>
Not all the exotic features are implemented. In particular there are no semaphores, formats and parallel-clauses.
<br><br>
The manual included with the interpreter details the restrictons, some of those that would affect some of the RC samples are listed here and in the Transput section.
<br><br>
Long'''long''' and '''short''' modes are not implemented and will cause errors to be reported, if used.
<br>
The stadard prelude has a number of ommissions, particularly transput which- issee restricted to standard input and output onlybelow.
<br>
There are no pragmats (using '''pr''' or '''pragma''' will cause an error message to be issued) and hence no file inclusion.
 
=== Lexical style ===
Rutgers ALGOL 68 is case-sensitive and uses quote-stropping. The standard bold-words are in lower case, e.g.:
<langsyntaxhighlight lang=algol68>'begin'
print( ( "Hello, World!", newline ) )
'end'</langsyntaxhighlight>
 
=== Transput ===
 
The restrictions Rutgers Algol68 places on the language and prelude are described in the manual. The following highlights some of the differences that are likely to affect running the RC samples with Rutgers Algol 68.<br>
<br>
Only the standard input and standard ouptut channels are supported. The transput event routines (on logical file end etc.) are not implemented. Formatted transput is not implemented.
<br><br>
There are a number of differences in the formatting of items output by print/write.
<br><br>
The read procedure handles '''char''' and '''string''' items differently to the standard.<br>
read( ( c ) ), where c is a '''char''' item gets the next character from standard input - c is set to '''repr''' 10 at end of line.
<br>
read( ( s ) ), where s is a '''string''' item does not change the bounds of s, it reads as many characters as are currently contained in s, - so '''string''' s; read( ( s, newline ) ) won't read anything into s as its bounds will be 1:0 at that point.
 
=== Building and running under Windows ===
Line 26 ⟶ 41:
Place the following batch file into the the folder and execute it. The batch file asumes TCC is being used as the C compiler, change as appropriate. The DEFINES and ALINC variables may also need to be changed.
 
<langsyntaxhighlight lang=dos>rem build.bat: build the Linux version of RutgersAlgol68 under Windows
 
rem set CC and DEFINES as appropriate for your C compiler
Line 57 ⟶ 72:
cd ..
 
cd ..</langsyntaxhighlight>
 
Note that the interpreter requires &lt;sys/times.h&gt;, the TCC compiler used in the batch file above did not have one, the following dummy times.h can be used. If needed it should be placed in a sub-folder of the installation folder, called '''sys'''.
 
<syntaxhighlight lang=C>// times.h for RutgersAlgol68 - not a real timss.h
#include <time.h>
#define times(x) (unsigned) time(x)
// end RutgersAlgol68 times.h</syntaxhighlight>
 
The following batch file can be used to execute the interpreter with an upper-stropping source (as used by most of the samples on RC):
 
<langsyntaxhighlight lang=dos>@rem u68.bat: execute an upper-stropping Algol 68 source using Rutgers Algol 68
@
@set p=%1
Line 110 ⟶ 132:
@ %rBin%\dump.exe _.d68
@ exit /b 7
@:endR68</langsyntaxhighlight>
 
The prelude.r68, postlude.r68 and upperToQuote.r68 soureces used by the above batch-file should be placed in the installation folder (\algolRutgersAlgol8 is assumed here). They are in the following sections on Using upper-stropping and Additional prelude items.
 
The '''prelude.r68''', '''postlude.r68''' and '''upperToQuote.r68''' soureces used by the above batch-file should be placed in the installation folder (\algolRutgersAlgol8 is assumed here). They are in the following sections on Using upper-stropping and Additional prelude items.
 
=== Using upper stropping ===
 
As mentioned above, Rutgers Algol 68 uses quote-stropping. The following program will convert an upper-stropping source to Rutgers style quote-stropping. ThisAdditionally, shouldit beremoves placedany in the installation folderpragmats (\algol\RutgersAlgol68i.e. ispragmatic assumedcomments here)delimited andby called'''pr''' or '''upperToQuote.r68pragma''') from the source.
<br><br>
This should be placed in the installation folder (\algol\RutgersAlgol68 is assumed here) and called '''upperToQuote.r68'''.
 
<langsyntaxhighlight lang=algol68>'begin' # convert an upper-stropped source to Rutgers quote stropping #
'proc' control = ( 'char' letter )'char': 'repr' ( 1 + ( 'abs' letter - 'abs' "A" ) );
'char' ctrlE = control( "E" );
Line 315 ⟶ 338:
'fi'
'od'
'end'</langsyntaxhighlight>
 
Note that Rutgers Algol 68 does not implement transput event routines, so cannot detect EOF. The above program assumes EOF will be indicated by control-E followed by control-O followed by control-F.
Line 325 ⟶ 348:
The following source should be placed in the instalation folder (\algol\RutgersAlgol68 is assumed here) and named '''prelude.r68''':
 
<langsyntaxhighlight lang=algol68>'begin' # additional prelude declarations for Rutgers Algol 68 #
'int' max abs char = 255;
'mode' 'complex' = 'compl';
Line 368 ⟶ 391:
found
'end'; # char in string #
'begin'</langsyntaxhighlight>
 
The following source should be placed in the installaton folder (\algol\RutgersAlgol68 is assumed here) and named '''postlude.r68'''.
Line 374 ⟶ 397:
'''Note''' that ^E^O^F should be replaced with the seuence of characters control-E, control-O and control-F.
 
<langsyntaxhighlight lang=algol68> 'end'
'end'
^E^O^F</langsyntaxhighlight>
3,021

edits