The a68toc manual describes the language restrictions of the
translator. Chapter 3 contains details of the FORALL
construct. This section is intended to document those extensions used
in the QAD standard prelude.
The principal extensions to Algol 68 modes are the introduction of multiple modes whose housekeeping overhead is less than the standard row modes.
STRUCT n MODE
char *
.
It is used in the ALIEN
(see section 12.3.4)
definitions of linux getenv
, for example, to reference
data.char **
. It is used to access the program's arguments.
VECTOR[n]MODE
VECTOR
:-
STR
can be used for any length VECTOR
.
OP MAKERVC = ([]CHAR s)RVC:It is also used to construct other modes such as
BOOK
(see
section 13.7).
STRUCT n MODE
can be coerced directly to a value
of mode VECTOR[]MODE
. Likewise, a value of the latter mode can
be coerced to a value of mode []MODE
. Therefore, preferably use
the mode []MODE
for a parameter to a procedure.
void *
.
int *
.
char *
.
cp
contains the actual memory address of
the procedure and the field env
contains data used by the
procedure.
VDESC=STRUCT(CCHARPTR data,BITS gc,
VECTOR
.
The data
field is the actual memory address of the start of
the data and the upb
field is the upper bound of the vector.
The gc
field is used by the garbage-collector (the heap
manager).
This section describes those constructs which are either peculiar to a68toc or which are in some way different from standard Algol 68.
FORALL
FORALL
is described in section 3.10.
ALIEN
and CODE
are described in the a68toc manual.
ALIEN
is also described in section 12.3.4. All
ALIEN
declarations used in the QAD standard prelude appear in
the file spaliens.a68
which you should consult for further
details. You should note that the ALIEN
declarations were
established by trying various modes until a definition was found
which a68toc translated to a compilable C source file.
As described in the a68toc manual, source files may contain either a
PROGRAM module or a DECS module. The latter may contain
declarations and CODE
clauses only. See the file
transput.a68
, lines 1185-92, for an example of how to execute
code when a DECS
module is being elaborated.
USE
list of a DECS
or a PROGRAM
module
generates calls to the relevant initialiser PROC
s (see the
generated C file for standard.a68
for an example) in the reverse
order of the given modules. Therefore, if the order matters, ensure
that the USE
clause mentions each module in the proper order.
FOR
loop
BY
construct in a FOR
loop (see
section 3.7) generates an internal compiler error if it is
followed by an integer denotation or a formula consisting of +
followed by an integer denotation. This
is a definite bug. The remedy is to use a simple procedure or operator
or the denotation preceded by two minus symbols. For example, instead of writing
FOR i BY 5 TO ...use
FOR i BY --5 TO ...
CASE
clause
If in a CASE
clause, whether a simple CASE
or a
conformity CASE
clause (one which determines the mode of the
value in its enquiry clause), the default clause can occur, then you
must include at least OUT SKIP
, otherwise you will get a
run-time fault.
UNION
(see section 8.1) is a
well-defined mode composed of constituent modes. A value of one of the
constituent modes may be assigned to a name of the united mode and only
that value (with its original mode) can be extracted. In the
C language, however, a “free union” or just “union” is a piece of
memory which can have different interpretations. The BIOP 99
construct enables the operand of an operator using it to be
re-interpreted as a value of the mode given in the yield. for example,
the operator FLAT
declared as
OP(REAL)STRUCT 8 CHAR FLAT = BIOP 99;accepts a
REAL
parameter which, as the yield, is regarded as an
indexable structure of 8 characters each of which can be accessed
separately. See section 13.5.3 for operators using this
construct.
These are largely operators using the BIOP 99
construct, but there are a number of other operators which ease the
task of interfacing with C library procedures.
Most of the operators used in the QAD standard prelude which are
defined using the BIOP 99
construct are for internal use only.
In the following list, the full declaration
OP(CPTR)CSTR TOCSTR = BIOP 99;is abbreviated to
OP TOCSTR=(CPTR)CSTR:
Here is a list of operators using the BIOP 99
construct which are made available by the QAD standard prelude:-
on exit
procedure.
ALIEN
procedure (such as a C library
routine).
OP TOPDESC=(PROC(INT,CPTR)VOID)PDESC:
OP TOPDESC=(PROC(INT)VOID)PDESC:
OP TOPDESC=(PROC(INT,RVC)PDESC:
TOPDESC
operators as you wish with
operands of procedures you will need. You will certainly need more
definitions of TOPDESC
if you write wrapper procedures for X
Window System procedures which have procedural parameters. See the file
transput.a68
for details of how this operator is used.
PROC VOID
to a
reference to a value of mode PDESC
.
STR
in a form suitable as a parameter to C library routines.
VECTOR[]BITS
.
VECTOR[]INT
.
Here is a list of operators not using the BIOP 99
construct:-
void *
to the type char *
.
RVC
using the standard
RS Algol 68 coercion
REF STRUCT n CHAR => REF VECTOR[]CHARIt is mainly used to access C strings yielded by C library routines. The parameter must be terminated by a
null character
.
VECTOR[4]CHAR
into a BITS
.
VECTOR[8]CHAR
into a LONG BITS
.
VECTOR[2]CHAR
into a SHORT BITS
.
BECTOR[1]CHAR
into a SHORT SHORT BITS
.
VECTOR[8]CHAR
into a REAL
.
VECTOR[4]CHAR
into a SHORT REAL
.
OP MAKERVC=(STR)RVC:
OP MAKERVC=([]CHAR)RVC:
VECTOR[]BITS
in a form
suitable as a parameter to a C library routine.
null character
must be appended to the data before
the routine is called. This need not be done for string denotations.
This routine may be used to yield a C pointer from an RVC
, as
the C representation is the same.
VECTOR[]INT
in a form suitable for
use as a parameter of a C library routine.
VCTOCHARPTR
.
STR
from a STR
for use with the
C library.