Original author(s) | I. F. Currie, J. D. Morrison |
---|---|
Developer(s) | Royal Signals and Radar Establishment |
Initial release | August 1977 |
Stable release | algol68toc 1.14 / 25 August 2012 |
Written in | ALGOL 68 |
Operating system | VMS |
Platform | ICL 2900 Series, Multics, VAX |
Available in | English |
Type | Compiler, translator |
License | Freeware, public domain (parts) |
Website | algol68 |
ALGOL 68RS is the second ALGOL 68 compiler written by I. F. Currie and J. D. Morrison, at the Royal Signals and Radar Establishment (RSRE). [1] Unlike the earlier ALGOL 68-R, it was designed to be portable, and implemented the language of the Revised Report.
Versions of ALGOL 68RS were written for the ICL 2900 Series, Multics, and VAX running VMS. [2] [3]
Subsequently, parts of this compiler were released into the public domain, as a translator from ALGOL 68 to C, as part of the public release of the hardware description language ELLA, also by the RSRE.
Although the ALGOL 68-R compiler, written by I.F. Currie, J.D. Morrison, and S.G. Bond, was a great success, it suffered from two major problems: it had been written for the nearly obsolete ICL 1900 computer, and it implemented an out-of-date version of the language as it was released before the Revised Report on ALGOL 68 was available.
RSRE needed a newer compiler for various internal projects, so the team of Currie and Morrison wrote a new compiler designed for cross-platform software portability between machines. The compiler dealt with the parsing of ALGOL 68, producing a high level intermediate language known as stream language that is then compiled to machine code by a translator. The compiler needed to know only the sizes of the various object machine data types and the character encoding (set) available.
The compiler was written in ALGOL 68, bootstrapped initially using the ALGOL 68-R compiler.
A team of two programmers at Oxford University Computing Services wrote a code generator for the ICL 2900 series. [4] Martyn Thomas of South West Universities Regional Computer Centre (SWURCC) arranged that this system be sponsored by International Computers Limited (ICL) and sold as an official ICL product. [5]
Later, the Avon Universities Joint Computer Centre, a large user of Multics requested the SWURCC team to produce a Multics version of ALGOL 68RS. A version for the Digital Equipment Corporation (DEC) VAX computer was also written.
Eventually the team at SWURCC formed a company, Praxis, initially supporting the Multics version of ALGOL 68RS.
RSRE also used the ALGOL 68RS compiler for internal projects, including the Flex machine and the ELLA hardware design language. When it was decided to make ELLA freely available, Praxis was commissioned to write an ALGOL 68 to C translator named ctrans, based on the ALGOL 68RS compiler.
Like the earlier ALGOL 68-R compiler, ALGOL 68RS was a one-pass compiler, which required some restrictions on the language compiled.
The ALGOL 68 program:
PROC even = (INT number) BOOL: ( number = 0 | TRUE | odd (ABS (number - 1))); PROC odd = (INT number) BOOL: ( number = 0 | FALSE | even (ABS (number - 1)));
would have to be re-written as:
PROC (INT) BOOL odd; PROC even = (INT number) BOOL : ( number = 0 | TRUE | odd (ABS (number - 1))); odd := (INT number) BOOL : ( number = 0 | FALSE | even (ABS (number - 1)));
To allow recursive declarations of modes (types) a special stub mode declaration was used to inform the compiler that an upcoming symbol was a mode rather than an operator:
MODEB, A = STRUCT (REFB b), B = [1:10] REFA;
Like ALGOL 68-R, the operators PAR clause and the SEMA mode with its associated UP, DOWN, and LEVEL, were omitted.
One major misfeature of ALGOL 68 is that it is impossible to write the standard transput (input/output) procedures in pure ALGOL 68. The print procedure takes, for example, an array of items to print of any mode and, by a process named straightening, converts them into simple values that can be printed. For example:
STRUCT (INT a, REAL b) c := ...; print(c); { magically transformed to print ((a OF c, b OF c)); }
The writers of ALGOL 68RS decided to make straightening available as part of the language. A STRAIGHT mode resembles an array but has the special feature that items can be coerced to a STRAIGHT mode if their components can be coerced to the mode. For example:
STRUCT (INT a, REAL b) c; STRAIGHTUNION (INT, REAL) z = c;
Both the fields of C can be coerced to UNION (INT, REAL) so the field "a OF c" can be accessed as z[1] and "b OF c" is z[2].
The standard print procedure can now be declared as:
MODEPRINTMODE = UNION (INT, REAL, ... STRAIGHTPRINTMODE); PROC print = ([] PRINTMODE arguments ) VOID: ...;
The ALGOL 68 array modes are very powerful, including multiple dimensions, defined upper and lower bounds, trimming (making a new array by taking a contiguous subset of an array), slicing (making a new array by removing one dimension from an array), and rowing (making a new array by adding a dimension to an extant array.
For example:
[5:23, -7:7] INT a; { a two dimensional array } REF [,] INT b = a [ 6:21, 0:3 ] { a slice of a } REF [] INT c = a [5] { just one row of a }
While the compiler made all efforts to generate optimal code for all cases, it was felt that adding some simpler facilities would allow better code in some cases. To this end ALGOL 68RS included indexable structures (i-structs), vectors, and the FORALL statement.
ALGOL 68 already included fixed length structures to efficiently handle characters and bit-data on word-based machines, the BYTES and BITS modes. A BYTES variable held one machine word of characters, a BITS variable held the bits of one machine word.
ALGOL 68RS generalised these ideas. A STRUCT 4 CHAR variable held exactly 4 chars. The size was part of the type. On most ALGOL 68RS systems, the mode BYTES was equivalent to STRUCT 4 CHAR.
MODEBYTES = STRUCT 4 CHAR; OPELEM = (INT index, BYTES val) CHAR: val[index]; ... BYTES b = "abcd"; ... print (2 ELEM b);
The ALGOL 68RS compiler would compile any string constant to an appropriate STRUCTnCHAR.
In contexts where a VECTOR or array was wanted, an i-struct could be widened to the appropriate VECTOR or array type.
A VECTOR is a simplified array, with only one dimension and a lower bound fixed at 1.
VECTOR [4] INT a; { similar to [1:4] INT a; }
In any context where an array was required a VECTOR could be converted to an array.
The FORALL statement allows efficient stepping through the elements of an array.
[12] INT a := ...; FORALL xa IN a DO xa := xa * 2 OD
xa will be a reference to each element of a in turn. FORALL can step through multiple arrays in parallel, and be controlled by a WHILE clause:
[12] INT a, b; ... FORALL xa IN a, xb IN b WHILE xa > xb DO f(xa, xb) OD
ALGOL 68RS provided a mechanism to build libraries similar to the separate compiling facilities of ALGOL 68-R and a mechanism to build programs in a top-down manner similar to those of ALGOL 68C.
Libraries in ALGOL 68RS are written using declaration modules which consist of a sequence of MODE, variable, operator and procedure declarations followed by a keep list which defines which declarations are visible to other segments.
The library user then adds a USE header that tells the compiler to make the symbols of one or more declaration libraries available to the program.
For example, a graphics library might be written as:
DECS graphlib USE some other library MODEGRAPHDATA = STRUCT ( ... ); MODEGRAPH = REFGRAPHDATA; PROC new graph = ( ... ) GRAPH : ...; PROC draw graph = (GRAPH g) VOID : ...; ... KEEPGRAPH, new graph, draw graph FINISH
And a user program to use this library would look like:
PROGRAM myprog USE graphlib BEGINGRAPH g = new graph (...); ... draw graph (g); ... ENDFINISH
To support a top-down programming style, ALGOL 68RS provided the HERE and CONTEXT facilities.
A program could be written with parts to be filled in later marked by a HERE tag followed by a keeplist of declarations to be made available.
PROGRAM (pass1, pass2) compiler BEGINSTRING source := ...; TREE parsetree; ... HERE pass1 (source, parsetree); ... INSTRUCTIONS insts; HERE pass2 (parsetree, insts); ... ENDFINISH
The code to be executed in the context of the HERE tags would be written as:
PROGRAM pass1 implementation CONTEXT pass1 IN compiler BEGIN ... { code using "source" and "parsetree" } ENDFINISH
HERE is similar to the ALGOL 68C ENVIRON and CONTEXT is equivalent to the ALGOL 68C USING.
ALGOL 68RS was intended to be usable for low level systems programming. To allow this, facilities were included for access to machine code and non-ALGOL 68RS objects.
Code was inserted with the CODE construct:
SOMEMODECODE (item1, item2, ...) "...code..."
Where the items are ALGOL 68RS values to be made available to the code insertion and SOMEMODE is the mode returned. The mode can be omitted if the code returns no value.
Access to non-ALGOL68 objects was available with the ALIEN insertion:
SOMEMODEname = ALIEN "external-name"
Any simple ALGOL 68RS object could be cast into a VECTOR of characters using the SPELL operator:
STRUCT (INT a, REAL b) c = ...; print (("internal repr = ", SPELL c, newline));
A simple object is one that contains no arrays or VECTORs.
The ALGOL 68 to C translator written by Praxis for the ELLA system contains most of the ALGOL 68RS compiler. The notable exception is the code for handling FORMATs.
As of September 2020 [update] , ALGOL 68RS is available from SourceForge. [6]
C is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, and protocol stacks, but its use in application software has been decreasing. C is commonly used on computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.
Pascal is an imperative and procedural programming language, designed by Niklaus Wirth as a small, efficient language intended to encourage good programming practices using structured programming and data structuring. It is named after French mathematician, philosopher and physicist Blaise Pascal.
The syntax of the C programming language is the set of rules governing writing of software in C. It is designed to allow for programs that are extremely terse, have a close relationship with the resulting object code, and yet provide relatively high-level data abstraction. C was the first widely successful high-level language for portable operating-system development.
In computer science, a pointer is an object in many programming languages that stores a memory address. This can be that of another value located in computer memory, or in some cases, that of memory-mapped computer hardware. A pointer references a location in memory, and obtaining the value stored at that location is known as dereferencing the pointer. As an analogy, a page number in a book's index could be considered a pointer to the corresponding page; dereferencing such a pointer would be done by flipping to the page with the given page number and reading the text found on that page. The actual format and content of a pointer variable is dependent on the underlying computer architecture.
In computer science, a union is a value that may have any of several representations or formats within the same position in memory; that consists of a variable that may hold such a data structure. Some programming languages support special data types, called union types, to describe such values and variables. In other words, a union type definition will specify which of a number of permitted primitive types may be stored in its instances, e.g., "float or long integer". In contrast with a record, which could be defined to contain both a float and an integer; in a union, there is only one value at any given time.
ALGOL 68 is an imperative programming language that was conceived as a successor to the ALGOL 60 programming language, designed with the goal of a much wider scope of application and more rigorously defined syntax and semantics.
A struct in the C programming language is a composite data type declaration that defines a physically grouped list of variables under one name in a block of memory, allowing the different variables to be accessed via a single pointer or by the struct declared name which returns the same address. The struct data type can contain other data types so is used for mixed-data-type records such as a hard-drive directory entry, or other mixed-type records.
The computer programming languages C and Pascal have similar times of origin, influences, and purposes. Both were used to design their own compilers early in their lifetimes. The original Pascal definition appeared in 1969 and a first compiler in 1970. The first version of C appeared in 1972.
In the C programming language, data types constitute the semantics and characteristics of storage of data elements. They are expressed in the language syntax in form of declarations for memory locations or variables. Data types also determine the types of operations or methods of processing of data elements.
A class in C++ is a user-defined type or data structure declared with keyword class
that has data and functions as its members whose access is governed by the three access specifiers private, protected or public. By default access to members of a C++ class is private. The private members are not accessible outside the class; they can be accessed only through methods of the class. The public members form an interface to the class and are accessible outside the class.
Platform Invocation Services, commonly referred to as P/Invoke, is a feature of Common Language Infrastructure implementations, like Microsoft's Common Language Runtime, that enables managed code to call native code.
sizeof is a unary operator in the programming languages C and C++. It generates the storage size of an expression or a data type, measured in the number of char-sized units. Consequently, the construct sizeof (char) is guaranteed to be 1. The actual number of bits of type char is specified by the preprocessor macro CHAR_BIT, defined in the standard include file limits.h. On most modern computing platforms this is eight bits. The result of sizeof has an unsigned integer type that is usually denoted by size_t.
The C and C++ programming languages are closely related but have many significant differences. C++ began as a fork of an early, pre-standardized C, and was designed to be mostly source-and-link compatible with C compilers of the time. Due to this, development tools for the two languages are often integrated into a single product, with the programmer able to specify C or C++ as their source language.
S-algol is a computer programming language derivative of ALGOL 60 developed at the University of St Andrews in 1979 by Ron Morrison and Tony Davie. The language is a modification of ALGOL to contain orthogonal data types that Morrison created for his PhD thesis. Morrison would go on to become professor at the university and head of the department of computer science. The S-algol language was used for teaching at the university at an undergraduate level until 1999. It was also the language taught for several years in the 1980s at a local school in St. Andrews, Madras College. The computer science text Recursive Descent Compiling describes a recursive descent compiler for S-algol, implemented in S-algol.
In computer science, a type punning is any programming technique that subverts or circumvents the type system of a programming language in order to achieve an effect that would be difficult or impossible to achieve within the bounds of the formal language.
ALGOL 68-R was the first implementation of the Algorithmic Language ALGOL 68.
C++ doesn't have:
The Interactive ALGOL 68 compiler for ALGOL 68 was made available by Peter Craven of Algol Applications from 1984. Then in 1994 from OCCL until 2004.
S3 is a structured, imperative high-level computer programming language. It was developed by the UK company International Computers Limited (ICL) for its 2900 Series mainframes. It is a system programming language with syntax influenced by ALGOL 68 but with data types and operators aligned to those offered by the 2900 Series. It was the implementation language of the operating system VME.
This article describes the syntax of the C# programming language. The features described are compatible with .NET Framework and Mono.