From 9ed1b0e964c8fd030b75a71ad5b589988e51cc1d Mon Sep 17 00:00:00 2001 From: "Jose E. Marchesi" Date: Sat, 11 Oct 2025 19:43:37 +0200 Subject: [PATCH] a68: gcc/algol68 misc files README contains a description of the front-end, and brief instructions for developers. At the moment the front-end doesn't define any custom tree node, as of yet. gcc/algol68/a68-tree.def is a placeholder where to have these node codes. a68-types.h and a68.h are the main header files used by the front-end. Together they provide data definitions and prototypes of functions defined in the .cc files. ga68.vw contains a revised-report like formal description of the language implemented by this compiler. This includes GNU extensions. Signed-off-by: Jose E. Marchesi gcc/ChangeLog * algol68/README: New file. * algol68/a68-tree.def: Likewise. * algol68/a68-types.h: Likewise. * algol68/a68.h: Likewise. * algol68/ga68.vw: Likewise. --- gcc/algol68/README | 130 +++ gcc/algol68/a68-tree.def | 24 + gcc/algol68/a68-types.h | 1166 ++++++++++++++++++++++++ gcc/algol68/a68.h | 1117 +++++++++++++++++++++++ gcc/algol68/ga68.vw | 1845 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 4282 insertions(+) create mode 100644 gcc/algol68/README create mode 100644 gcc/algol68/a68-tree.def create mode 100644 gcc/algol68/a68-types.h create mode 100644 gcc/algol68/a68.h create mode 100644 gcc/algol68/ga68.vw diff --git a/gcc/algol68/README b/gcc/algol68/README new file mode 100644 index 00000000000..9d1595ad8d8 --- /dev/null +++ b/gcc/algol68/README @@ -0,0 +1,130 @@ +This is the GNU Algol 68 compiler. + +This compiler implements the Algol 68 programming language +(https://www.algol68-lang.org) as defined in the Revised Report, along +with several GNU extensions to the language which are oriented to +enhance its application in systems programming and to achieve a good +integration in POSIX systems. + +The parser component used in this front-end has been adapted from +Algol 68 Genie, an Algol 68 interpreter written by Marcel van der +Veer. It is worth noting that this parser is not your typical garden +variety parser, as it is capable of effectively parsing the two-level +grammar of Algol 68, which is no small task. Parsing Algol 68 is +notoriously difficult, and without Marcel's careful work of many years +this front-end would most probably not exist. It is also a beautiful +implementation that is a delight to both read and work with. + +The syntax tree built by the parser is lowered into a GENERIC tree by +a lowering pass, which then invokes the gimplifier and hands the +resulting gimple IR over to the rest of the compilation, down the +rabbit hole all the way to optimized assembly code. + +The compiler driver is called `ga68'. +The compiler proper is called `a681'. + +Programs built by this compiler make use of the libga68 run-time +library. + +Building +======== + +Configure and build GCC with: + + $ mkdir build-algol68 + $ cd build-algol68 + $ ../configure --enable-languages=algol68 + $ make + $ make install + +Alternatively you can configure and build a non-bootstrapped compiler, +which is much faster to build. But note that in this case you better +pass some flags so the compiler gets built optimized, or the resulting +compiler will be rather slow: + + $ mkdir build-algol68 + $ cd build-algol68 + $ ../configure --enable-languages=algol68 BOOT_CFLAGS="-O2 -g" \ + BOOT_CXXFLAGS="-O2 -g" \ + STAGE1_CFLAGS="-O2 -g" \ + STAGE1_CXXFLAGS="-O2 -g" + $ make + $ make install + +Debugging +========= + +A few front-end specific options useful for debugging are: + + '-fa68-dump-ast' + Emits a textual representation of the parse tree as produced by the parser. + + '-fa68-dump-modes' + Emits a list of all parsed modes. + +See the Developer Options section in the GNU Algol Compiler manual for +more hacking related options. + +Testing +======= + +Invoke the full testsuite from the build directory: + + $ make check-algol68 + +You can pass -jN to run tests in parallel: + + $ make -jN check-algol68 + +Invoke a subset of the testsuite. For example, to only run tests that +involve compilation but not running: + + $ make check-algol68 RUNTESTFLAGS="compile.exp" + +There are the following sets of tests: + + compile.exp - compilation tests + +Invoke only a specific test: + + $ make check-algol68 RUNTESTFLAGS="--all compile.exp=bad-coercion-1.a68" + +Test in both 32-bit and 64-bit in multilib arches: + + $ make check-algol68 RUNTESTFLAGS="--target_board=unix\{-m64,-m32\}" + +Test that integration with the GCC GC is correct: + + $ make check-algol68 RUNTESTFLAGS="CFLAGS_FOR_TARGET='--param=ggc-min-expand=0 --param=ggc-min-heapsize=0'" + +Logs (with corresponding commands) can be found in +BUILD/gcc/testsuite/algol68/algol68.log. + +See https://gcc.gnu.org/install/test.html for more details. + +Useful Resources +================ + +- An Emacs mode for editing Algol 68 programs can be found at + https://git.sr.ht/~jemarch/a68-mode. It supports automatic + indentation, pretty-printing of bold tags, an auto-stropping minor + mode and other features. + +- The Algol 68 Jargon File at https://jemarch.net/a68-jargon provides + a comprehensive list of definitions of many of the technical and + non-technical terms used in the context of Algol 68. + +- The very formal Revised Report on the Algorithmic Language ALGOL 68 + can be found at [1]. + +- The truly delightful Informal Introduction to ALGOL 68 by C.H + Lindsey and van der Meulen can be found at [2]. + +Community +========= + +mailing list: algol68@gcc.gnu.org +irc: irc.oftc.net - #gnualgol + +[1] https://www.softwarepreservation.org/projects/ALGOL/report/Algol68_revised_report-AB-600dpi.pdf +[2] https://inria.hal.science/hal-03027689/file/Lindsey_van_der_Meulen-IItA68-Revised.pdf diff --git a/gcc/algol68/a68-tree.def b/gcc/algol68/a68-tree.def new file mode 100644 index 00000000000..1d7c644988f --- /dev/null +++ b/gcc/algol68/a68-tree.def @@ -0,0 +1,24 @@ +/* This file contains the definitions and documentation for the + additional tree codes used in the GNU Algol 68 compiler (see + tree.def for the standard codes). + Copyright (C) 2025 Jose E. Marchesi. + + GCC is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 3, or (at your option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + details. + + You should have received a copy of the GNU General Public License along with + GCC; see the file COPYING3. If not see . */ + +/* Tree nodes used in the Algol68 frontend only. */ + +/* +Local variables: +mode:c +End: +*/ diff --git a/gcc/algol68/a68-types.h b/gcc/algol68/a68-types.h new file mode 100644 index 00000000000..df9133fb12f --- /dev/null +++ b/gcc/algol68/a68-types.h @@ -0,0 +1,1166 @@ +/* Type definitions for the ALGOL 68 parser. + Copyright (C) 2001-2023 J. Marcel van der Veer. + Copyright (C) 2025 Jose E. Marchesi. + + Original implementation by J. Marcel van der Veer. + Adapted for GCC by Jose E. Marchesi. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#ifndef __A68_TYPES_H__ +#define __A68_TYPES_H__ + +#include "config.h" +#include "system.h" + +#include +#include "vec.h" + +/* Enumerations. */ + +enum a68_stropping +{ + UPPER_STROPPING, + SUPPER_STROPPING +}; + +enum a68_attribute +{ + STOP = 0, +#define A68_ATTR(ATTR,DESCR) ATTR, +#include "a68-parser-attrs.def" +#undef A68_ATTR +}; + +enum a68_tree_index +{ + /* Type trees. */ + ATI_VOID_TYPE, + ATI_BOOL_TYPE, + ATI_CHAR_TYPE, + ATI_SHORT_SHORT_BITS_TYPE, + ATI_SHORT_BITS_TYPE, + ATI_BITS_TYPE, + ATI_LONG_BITS_TYPE, + ATI_LONG_LONG_BITS_TYPE, + ATI_BYTES_TYPE, + ATI_LONG_BYTES_TYPE, + ATI_SHORT_SHORT_INT_TYPE, + ATI_SHORT_INT_TYPE, + ATI_INT_TYPE, + ATI_LONG_INT_TYPE, + ATI_LONG_LONG_INT_TYPE, + ATI_REAL_TYPE, + ATI_LONG_REAL_TYPE, + ATI_LONG_LONG_REAL_TYPE, + /* Sentinel. */ + ATI_MAX +}; + +/* + * Type definitions. + */ + +typedef char BUFFER[BUFFER_SIZE + 1]; + +typedef struct MODES_T MODES_T; +typedef struct NODE_T NODE_T; +typedef struct MODE_CACHE_T MODE_CACHE_T; +typedef struct MOID_T MOID_T; +typedef struct GINFO_T GINFO_T; +typedef struct KEYWORD_T KEYWORD_T; +typedef struct LINE_T LINE_T; +typedef struct NODE_INFO_T NODE_INFO_T; +typedef struct PACK_T PACK_T; +typedef struct SOID_T SOID_T; +typedef struct TABLE_T TABLE_T; +typedef struct TAG_T TAG_T; +typedef struct TOKEN_T TOKEN_T; +typedef struct ORIGIN_T ORIGIN_T; +typedef struct POSTULATE_T POSTULATE_T; +typedef struct OPTIONS_T OPTIONS_T; +typedef struct PARSER_T PARSER_T; +typedef struct MODULE_T MODULE_T; +typedef struct EXTRACT_T EXTRACT_T; +typedef struct MOIF_T MOIF_T; +typedef struct A68_T A68_T; + +#define NO_A68_REF ((A68_REF *) 0) +#define NO_ARRAY ((A68_ARRAY *) 0) +#define NO_BOOK ((BOOK_T *) 0) +#define NO_BOOL ((bool *) 0) +#define NO_BYTE ((BYTE_T *) 0) +#define NO_CONSTANT ((void *) 0) +#define NO_DEC ((DEC_T *) 0) +#define NO_EDLIN ((EDLIN_T *) 0) +#define NO_FILE ((FILE *) 0) +#define NO_FORMAT ((A68_FORMAT *) 0) +#define NO_GINFO ((GINFO_T *) 0) +#define NO_GPROC ((void (*) (NODE_T *)) 0) +#define NO_HANDLE ((A68_HANDLE *) 0) +#define NO_INT ((int *) 0) +#define NO_JMP_BUF ((jmp_buf *) 0) +#define NO_KEYWORD ((KEYWORD_T *) 0) +#define NO_NINFO ((NODE_INFO_T *) 0) +#define NO_NOTE ((void (*) (NODE_T *)) 0) +#define NO_OPTION_LIST ((OPTION_LIST_T *) 0) +#define NO_PACK ((PACK_T *) 0) +#define NO_PPROC ((PROP_T (*) (NODE_T *)) 0) +#define NO_PROCEDURE ((A68_PROCEDURE *) 0) +#define NO_REAL ((REAL_T *) 0) +#define NO_REFINEMENT ((REFINEMENT_T *) 0) +#define NO_REGMATCH ((regmatch_t *) 0) +#define NO_SCOPE ((SCOPE_T *) 0) +#define NO_SOID ((SOID_T *) 0) +#define NO_STREAM NO_FILE +#define NO_TEXT ((char *) 0) +#define NO_TICK ((bool *) 0) +#define NO_TOKEN ((TOKEN_T *) 0) +#define NO_TUPLE ((A68_TUPLE *) 0) +#define NO_VAR (0) + +/* A STATUS_MASK_T is a word of flags denoting states. + + Status masks are used in parse tree nodes (NODE_T) and in entries in the + symbol table (TAG_T). + + + SCOPE_ERROR_MASK is used by the static scope checker in order to avoid + emitting duplicated scope warnings. */ + +typedef uint32_t STATUS_MASK_T; + +#define STATUS_CLEAR(p, q) {STATUS (p) &= (~(q));} +#define STATUS_SET(p, q) {STATUS (p) |= (q);} +#define STATUS_TEST(p, q) ((STATUS (p) & (q)) != (uint32_t) 0) + +#define NULL_MASK ((STATUS_MASK_T) 0x00000000) +#define SCOPE_ERROR_MASK ((STATUS_MASK_T) 0x00000200) + +/* Structure containing the lowering context which is propagated while calling + the lowering handlers. */ + +struct LOW_CTX_T +{ + /* The common declarer in a declaration list. */ + NODE_T **declarer; + /* The defining identifier of the procedure declaration being processed, or + NO_NODE. This is set by a68_lower_procedure_declaration and used by + a68_lower_routine_text. */ + NODE_T *proc_decl_identifier; + /* If proc_decl_identifier is no NO_NODE, this denotes whether the + declaration being processed is of an operator. */ + bool proc_decl_operator; + /* Name of current module definition, or NULL. */ + const char *module_definition_name; + /* For debugging purposes. */ + int level; +}; + +typedef struct LOW_CTX_T LOW_CTX_T; + +/* Type of the lowerer routines defined in a68-low-prelude.cc. */ +typedef tree (*LOWERER_T) (struct NODE_T *, struct LOW_CTX_T); + +#define NO_LOWERER a68_lower_unimplemented + +struct GTY((chain_next ("%h.more"), chain_prev ("%h.less"))) KEYWORD_T +{ + enum a68_attribute attribute; + const char *text; + KEYWORD_T *less, *more; +}; + +/* A MOID_T represents a mode indicator. + + NUMBER is an unique number assigned to the moid when it gets created. A + renumber_moids function exists in a68-parser-modes.cc but it dosn't seem to + be used at all. + + ATTRIBUTE characterizes the kind of mode and is one of the values defined in + a68-parser-attrs.def. Valid values are: + + PROC_SYMBOL for procecure modes. + ROWS_SYMBOL for row modes. + REF_SYMBOL for reference modes. + FLEX_SYMBOL for flexible reference modes. + STRUCT_SYMBOL for struct modes. + UNION_SYMBOL for union modes. + IN_TYPE_MODE for XXX modes. + OUT_TYPE_MODE for XXX modes. + SERIES_MODE for XXX modes. + INDICANT for XXX modes. + MODULE_INDICANT for XXX modules. + STANDARD for standard modes. + + NODE is a parse tree node XXX. + + HAS_ROWS is true if the mode contains rows somewhere in its internal + structure. + + The interpretation of SUB depends on the kind of mode: + - For REF modes it is the referred mode. + - For FLEX modes it is the referred mode. + - For ROW modes it is the mode of the elements. + - For PROC modes it is the mode of the value yielded by the procedure. + + The interpretation of DIM depends on the kind of mode: + - In VOID_SYMBOL, STANDARD or INDICANT mode, if DIM is positive it + specifies the size of the longsety of the mode. If DIM is negative then + abs (DIM) is the size of hte shortsety of the mode. + - In ROW modes, DIM is the number of dimensions. + - In STRUCT modes, DIM is the number of fields. + - In UNION modes, DIM is the number of united modes. + - In PROC_SYMBOL modes, DIM is the number of arguments. + - In SERIES_MODE and STOWED_MODE modes, DIM is the number modes. + + SLICE is the mode resulting from slicing a value of this mode. For example, + slicing a M_ROW_INT yields a M_INT. + + EQUIVALENT_MODE (referred as EQUIVALENT), for INDICANTs it is its declarer + mode (in MODE FOO = BAR FOO is the indicant and BAR is its declarer) and for + STANDARD modes it may be a mode that reflects its structure. + + USE is used by the is_well_formed function, which detects whether a mode is + well formed, i.e. that the mode doesn't refer to itself nor it relates to + void. + + DEFLEXED_MODE is like the current mode, but without FLEX. Only defined for + modes that have a SUB, i.e. REF, FLEX, ROW and PROC. In other modes this is + NO_MODE. + + For refs to structs, rows or flex, NAME points to the corresponding name + mode. For example, for a mode REF STRUCT (INT i, REAL x), NAME points to a + mode STRUCT (REF INT i, REF REAL x). This is used for selections. + + For rows of structs, rows or flex, MULTIPLE points to the corresponding row + mode. For example, for a mode [] STRUCT (INT i, REAL x), MULTIPLE points to + a mode STRUCT ([]INT i, []REAL x). This is used for selections. + + PACK is a pack of moids. For a STOWED_MODE, it contains the modes of the + arguments of a procedure, or the modes of the units in a collateral clause. + For a SERIES_MODE, it contains the modes of the completing units in a serial + clause, the alternatives in a conformity clause, the alternatives in a + CONDITIONAL_CLAUSE, the alternatives in a CASE_CLAUSE, + + CTYPE is a GCC GENERIC tree corresponding to this mode. It is computed and + installed by a68_lower_moid. + + ASM_LABEL is an assembly label used by a68_asm_output_mode. */ + +#define NO_MOID ((MOID_T *) 0) + +struct GTY((chain_next ("%h.next"))) MOID_T +{ + int number; + int attribute; + int dim; + bool has_rows, use, portable, derivate; + NODE_T *node; + PACK_T *pack; + MOID_T *sub, *equivalent_mode, *slice, *deflexed_mode, *name, *multiple_mode, *next, *rowed, *trim; + tree ctype; + const char *asm_label; +}; + +/* A MODES_T struct contains a collection of particular pre-defined modes. + + These modes are initialized by either stand_moids or make_special_mode. + They are commonly referred using the corresponding M_* macros. + + ROWS is a mode to which any ROW mode can be strongly coerced. It is used as + the mode of the second operand of the ELEMS, LWB and UPB operators. + + HIP is the mode of NIL. */ + +struct MODES_T +{ + MOID_T *BITS, *BOOL, *BYTES, *CHANNEL, *CHAR, *COLLITEM, *COMPL, *COMPLEX, + *C_STRING, *ERROR, *FILE, *FORMAT, *HEX_NUMBER, *HIP, *INT, *LONG_BITS, *LONG_BYTES, + *LONG_COMPL, *LONG_COMPLEX, *LONG_INT, *LONG_LONG_BITS, *LONG_LONG_COMPL, + *LONG_LONG_COMPLEX, *LONG_LONG_INT, *LONG_LONG_REAL, *LONG_REAL, *NUMBER, + *PROC_REAL_REAL, *PROC_LONG_REAL_LONG_REAL, *PROC_REF_FILE_BOOL, *PROC_REF_FILE_VOID, *PROC_ROW_CHAR, + *PROC_STRING, *PROC_VOID, *REAL, *REF_BITS, *REF_BOOL, *REF_BYTES, + *REF_CHAR, *REF_COMPL, *REF_COMPLEX, *REF_FILE, *REF_INT, + *REF_LONG_BITS, *REF_LONG_BYTES, *REF_LONG_COMPL, *REF_LONG_COMPLEX, + *REF_LONG_INT, *REF_LONG_LONG_BITS, *REF_LONG_LONG_COMPL, + *REF_LONG_LONG_COMPLEX, *REF_LONG_LONG_INT, *REF_LONG_LONG_REAL, *REF_LONG_REAL, + *REF_REAL, *REF_REF_FILE, *REF_ROW_CHAR, *REF_ROW_COMPLEX, *REF_ROW_INT, + *REF_ROW_REAL, *REF_ROW_ROW_COMPLEX, *REF_ROW_ROW_REAL, + *REF_SHORT_BITS, *REF_SHORT_SHORT_BITS, *REF_SHORT_INT, + *REF_SHORT_SHORT_INT, *REF_STRING, + *ROW_BITS, *ROW_BOOL, *ROW_CHAR, *ROW_COMPLEX, *ROW_INT, *ROW_LONG_BITS, *ROW_LONG_LONG_BITS, + *ROW_REAL, *ROW_ROW_CHAR, *ROW_ROW_COMPLEX, *ROW_ROW_REAL, *ROWS, *ROW_SIMPLIN, *ROW_SIMPLOUT, + *ROW_STRING, *SEMA, *SHORT_BITS, *SHORT_SHORT_BITS, *SHORT_INT, *SHORT_SHORT_INT, + *SIMPLIN, *SIMPLOUT, *STRING, *FLEX_ROW_CHAR, + *FLEX_ROW_BOOL, *UNDEFINED, *VACUUM, *VOID; +}; + +/* The OPTIONS_T structure record which front-end options have been activated. + Each option OPTION has a corresponding GCC -f[no-]a68-OPTION command-line + switch that can be used to activate or deactivate it. + + STROPPING indicates the stropping regime in use. It can be UPPER_STROPPING + or SUPPER_STROPPING. + + BRACKETS indicates whether [ .. ] and { .. } are equivalent to ( .. ). + + STRICT indicates that no ALGOL 68 extension is allowed. + + ASSERT indicates whether to generate code for assertions. + + BOUNDS_CHECKING indicates whether to perform array bound checking at + run-time. + + NIL_CHECKING indicates whether to check for NIL when dereferencing at + run-time. */ + +struct GTY(()) OPTIONS_T +{ + enum a68_stropping stropping; + bool brackets; + bool strict; + bool assert; + bool bounds_checking; + bool nil_checking; +}; + +/* The access class static property of a stored value determines how the value + can be reached at run-time. It is used by the lowering pass in order to + minimize copies at run-time. + + CONSTANT is for constant literals. At run-time these literals will either + reside in operand instructions or in space allocated in CONSTAB%. + + DIRIDEN (direct identifier) means that the value is stored on IDST% at some + static address. This is the access class used for values ascribed to + identifiers as long as the block in hich they are declared has not been + left. It is also used for values resulting from actions such as the + selection from a value possessed by an identifier or the dereferencing fo a + name corespodning to a variable. + + VARIDEN (variable identifier) is used for values which are names/variables. + The name is stored on IDST%. The static elaboration of the dereferencing of + a variable with access VARIDEN results in a value with access DIRIDEN, not + requiring any run-time action. Same happens with selections of variables of + access VARIDEN. + + INDIDEN (indirect identifier) is used for values that are stored in a memory + location in IDST%. The static elaboration of a dereferencing applied to a + value of access DIRIDEN. + + DIRWOST (direct working stack) is very much like DIRIDEN, except that the + value is stored in WOST% rathern than in IDST%. This access is used for the + result of an action when this result does not preexist in memory and hence + has to be constructed in WOST%. + + INDWOST (indirect working stack) is very similar to INDIDEN. Such an access + can be obtained for example through the static elaboration of the + dereferencing of a name the access of which is DIRWOST. + + NIHIL is used to characterize the absence of value. This is used in the + static elaboration of a jump, a voiding and a call ith a void result. + + Note that in all these classes we assume as run-time the intermediate + language level we are lowering to, i.e. GENERIC. A DIRIDEN value, for + example, can very well stored in a register depending on further compiler + optimizations. */ + +#define ACCESS_NIHIL 0 +#define ACCESS_CONSTANT 1 +#define ACCESS_DIRIDEN 2 +#define ACCESS_INDIDEN 3 +#define ACCESS_DIRWOST 4 + +/* A NODE_T is a node in the A68 Syntax tree produced by the lexer-scanner and + later expanded by the Mailloux parser. + + NUMBER identifies the node uniquely in the syntax tree. + + ATTRIBUTE is a code that specifies the kind of entity denoted by the node. + Valid attributes are defined in the enumeration a68_attribute above in + this file. Examples of attributes are ELIF_PART, GOTO_SYMBOL or BOLD_TAG. + + ANNOTATION provides a way to annotate a node with a reference to another + node attribute. This is currently used by the mode checker to annotate + indexer nodes as slicer or as trimmers. + + TYPE (accessed as MOID) is either NO_MOID if the entity denoted by the node + doesn't have a mode, or a suitable MOID_T reflecting the mode of the entity. + This attribute is calculated and set in all the nodes of the tree by the + mode collection and checker pass implemented by make_moid_list. + + INFO contains additional attributes of the node. See NODE_INFO_T below. + + NEXT, PREVIOUS and SUB are links to other tree nodes. They are used to link + the syntax tree structure from the top: + + TOP <-> N <-> N <-> ... + | < is PREVIOUS + N <-> N <-> ... > is NEXT + | | is SUB + N <-> ... + + SEQUENCE is a link to another tree node. It is used by the tax collector + (symbol table builder) in order to handle DO .. OD ranges. + + NEST is a link to another tree node, which is the NEST for the current node. + It is set by the tax collector (symbol table builder) and it is used for + diagnostics. + + PACK (accessed as NODE_PACK) is either NO_PACK or an instance of the PACK_T + structure defined below. It is used by the modes checker. + + STATUS is a mask of flags, used by several passes that handle nodes. Valid status flags are: + + SYMBOL_TABLE (accessed as TABLE) is either NO_TABLE or a TABLE_T containing + a symbol table introduced by the entity denoted by the tree node. These + nodes are the ones introducing ranges: BEGIN, DO, etc. + + NON_LOCAL is either NO_TABLE, if the environ established by the node is + local, or a pointer to a TABLE_T identifying the non-local environment + associated with the tree node. It is set by the static scope checker. See + 3.2.2 and 5.2.3.2.b in the report for its application in the handling of + local generators in serial clauses. + + TAG (accessed as TAX) is either NO_TAG or a TAG_T used to bind identifier + nodes, routine texts and other indicants to their corresponding entry in a + symbol table. This is set by the taxes collector. + + The following fields are static properties managed an used in the lowering + pass. + + ORIGIN is a static property that describes the history of the entity denoted + by the node. This is only used in nodes denoting values. + + DYNAMIC_STACK_ALLOCS is a flag used in serial clause nodes. It determines + whether the elaboration of the phrases in the serial clause may involve + dynamic stack allocation. This is used by the lower pass, along with + NON_LOCAL above, in order to properly manage the stack pointer while + lowering these clauses. + + PUBLICIZED is true for DEFINING_OPERATOR, DEFINING_IDENTIFIER and + DEFINING_INDICANT nodes that appear in declarations marked with PUB. + + CDECL is a GCC GENERIC tree corresponding to a DECL_FIELD for FIELD + nodes. */ + +struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) NODE_T +{ + GINFO_T *genie; + int number; + enum a68_attribute attribute; + enum a68_attribute annotation; + MOID_T *type; + NODE_INFO_T *info; + NODE_T *next, *previous, *sub; + NODE_T *sequence, *nest; + PACK_T *pack; + STATUS_MASK_T status; + TABLE_T *symbol_table; + TABLE_T *non_local; + TAG_T *tag; + tree cdecl; + bool dynamic_stack_allocs; + bool publicized; +}; + +#define NO_NODE ((NODE_T *) 0) + +/* A NODE_INFO_T struct contains additional attributes of a NODE_T parse tree + node. + + PROCEDURE_LEVEL indicates how lexically deep the tree node is in terms of + routine texts. This attribute is set for all the nodes in the syntax tree + by the taxes collector and originally used by ALGOL 68 Genie's monitor. + Even if at the moment this is not used by GCC, this field and the + correponding machinery is still here in case it is useful in the future. + + PRIORITY (accessed as PRIO) is used by operator tree nodes and specifies the + priority of the operator denoted by the node. This is set tree wide by the + bottom-up parser. + + SYMBOL (accessed indirectly as NSYMBOL) contains the symbol value, a string, + corresponding to the tree node. This is used by tree nodes representing + tokens such as bold tags, keywords and identifiers. The symbols are set by + the parser-scanner. + + LINE is a pointer to the source line from which the tree node originates. + This is set for tree nodes representing tokens and is set by the + parser-scanner. */ + +struct GTY(()) NODE_INFO_T +{ + int procedure_level; + int priority; + char * GTY((skip)) char_in_line; + int comment_type; + char * GTY((skip)) comment; + LINE_T *comment_line; + char * GTY((skip)) comment_char_in_line; + int pragmat_type; + char * GTY((skip)) pragmat; + LINE_T *pragmat_line; + char * GTY((skip)) pragmat_char_in_line; + const char *symbol; + LINE_T *line; +}; + +struct GTY(()) GINFO_T +{ + MOID_T *partial_proc, *partial_locale; +}; + +struct GTY((chain_next ("%h.next"), chain_prev ("%h.previous"))) PACK_T +{ + MOID_T *type; + const char *text; + NODE_T *node; + PACK_T *next, *previous; +}; + +/* Postulates. */ + +struct GTY((chain_next ("%h.next"))) POSTULATE_T +{ + MOID_T *a, *b; + POSTULATE_T *next; +}; + +#define NO_POSTULATE ((POSTULATE_T *) 0) + +struct GTY((chain_next ("%h.next"))) SOID_T +{ + int attribute, sort, cast; + MOID_T *type; + NODE_T *node; + SOID_T *next; +}; + +struct GTY((chain_next ("%h.next"))) LINE_T +{ + char marker[6]; + char * GTY((skip)) string; + const char *filename; + int number; + LINE_T *next, *previous; +}; +#define NO_LINE ((LINE_T *) 0) + +/* Symbol table. + + PUBLIC_RANGE is true in ranges whose declarations may be made accessible to + other compilation units. decl trees lowered for declarations in public + ranges will be put in the top-level block. This is used for top-level + module declarations. */ + +struct GTY(()) TABLE_T +{ + int num, level, nest, attribute; + bool initialise_frame, initialise_anon, proc_ops, public_range; + TABLE_T *previous, *outer; + TAG_T *identifiers, *operators, *modules, *priority, *indicants, *labels, *anonymous; + NODE_T *jump_to, *sequence; +}; +#define NO_TABLE ((TABLE_T *) 0) + +/* A TAG_T structure denotes an entry in the symbol table. Each entry + corresponds to an identity. + + TAX: TAG; TAB; TAD; TAM; + + TYPE is the mode of the entry. + + NODE is the defining identifier associated to the declaration. + + SCOPE is the lexical depth of the tag. Zero corresponds to the primal + scope. It is set by the static scope checker. + + SCOPE_ASSIGNED determines whether a SCOPE has been actually assigned to the + tag. It is set by the static scope checker. The entities which get + assigned scopes are identities of format texts and routine texts. + + PORTABLE determines whether the construction associated with the tag is + Algol 68 or some extension. + + VARIABLE is set when the defining identifier in NODE is defined in a + variable declaration, as opposed to an identity declaration. This is set by + extract_variables and is used by the lowering pass. + + HEAP is used for defining identifier in NODE is defined in a variable + declaration. It is HEAP_SYMBOL or LOC_SYMBOL. + + IS_RECURSIVE is set for mode indicants whose definition is recursive, + i.e. they appear in actual declarers within its own definition. + + PUBLICIZED is set for tags that are marked as public and therefore shall be + exported as part of a module interface. + + EXPORTED is set for DEFINING_MODULEs whose module interface is to be + exported. + + ASCRIBED_ROUTINE_TEXT is set when the defining identifier is ascribed a + routine-text in an identity declaration. + + IN_PROC is set when the defining identifier has been set in a + proc-identity-declaration or in a brief-op-declaration. These declarations + are optimized in a similar way than variable declarations in order to avoid + indirect addressing. + + YOUNGEST_ENVIRON is used when NODE is either a ROUTINE_TEXT or a + FORMAT_TEXT, and contains the youngest (higher) lexical level of any object + directly declared in the routine or format body. This is filled in and used + by the scope checker. + + TREE_DECL is the GENERIC declaration for the definition of this symbol. + This is set and used by the lower pass. For mode indicants, it contains a + function that generates a pointer to the given mode, and is used by + a68_low_generator to handle recursive modes. + + MOIF is a list of module interfaces. This is used in ACCESS_CLAUSE nodes. + + EXTERN_SYMBOL is a string with the symbol that was obtained from an imported + module declaration. This is only used in entries where MOIF is not NO_MOIF. + + LOWERER is a lowering routine defined in a68-low-prelude.cc. These are used + in taxes that denote some pre-defined operator. */ + +struct GTY((chain_next ("%h.next"))) TAG_T +{ + TABLE_T *symbol_table; + MOID_T *type; + NODE_T *node, *unit; + const char *value; + bool scope_assigned, use, in_proc, loc_assigned, portable, variable; + bool ascribed_routine_text, is_recursive, publicized, exported; + int priority, heap, scope, youngest_environ, number; + STATUS_MASK_T status; + tree tree_decl; + MOIF_T *moif; + LOWERER_T lowerer; + TAG_T *next, *body; + const char *extern_symbol; +}; +#define NO_TAG ((TAG_T *) 0) + +struct GTY((chain_next ("%h.more"), chain_prev ("%h.less"))) TOKEN_T +{ + const char *text; + TOKEN_T *less, *more; +}; +#define NO_TOKEN ((TOKEN_T *) 0) + +struct GTY(()) MODULE_T +{ + bool tree_listing_safe, cross_reference_safe; + int error_count, warning_count, source_scan; + LINE_T *top_line; + MOID_T *top_moid, *standenv_moid; + NODE_T *top_node; + OPTIONS_T options; + FILE * GTY ((skip)) file_source_fd; + const char *file_source_name; + struct + { + LINE_T *save_l; + char * GTY((skip)) save_s, GTY((skip)) save_c; + } scan_state; +}; + +/* Module interface extracts. + + KIND is the kind of extract. One of the GA68_EXTRACT_* codes defined in + a68-exports.cc. + + SYMBOL is a string with the symbol name for the entity represented by the + extract. It is mangled. + + MODE applies to identifier, operator and indicatione extracts. + + PRIORITY is the priority number in a priority extract. + + VARIABLE applies to GA68_EXTRACT_IDEN and GA68_EXTRACT_OPER extracts, and + indicates whether the exported symbol was declared via a variable + declaration. These decls are optimized and don't require indirect + addressing. This is compiler-specific and part of mdextra. + + IN_PROC applies to GA68_EXTRACT_IDEN and GA68_EXTRACT_OPER extracts. If + set, the exported symbol shall not be indirected. This is compiler-specific + and part of mdextra. */ + +struct GTY(()) EXTRACT_T +{ + unsigned int kind; + const char *symbol; + MOID_T *mode; + int priority; + bool variable, in_proc; +}; + +/* Module interfaces. + + VERSION is the version of the exports format to report in the encoded data. + + NAME is the name of the module as it is accessed at the source level, which + corresponds to a bold word. + + PRELUDE and POSTLUDE are mangled symbols corresponding to the entry points + of the module's prelude and postlude. + + MODES is a vector of modes which conform the modes table of the module + interface. + + MODULES is a vector of TAGs for module extracts. + INDICANTS is a vector of TAGs for mode extracts. + IDENTIFIERS is a vector of TAGs for identifier extracts. + PRIOS is a vector of TAGs for operator priorities. */ + +#define NO_MOIF ((MOIF_T *) 0) + +struct GTY(()) MOIF_T +{ + unsigned int version; + const char *name; + const char *prelude; + const char *postlude; + vec *modes; + vec *modules; + vec *indicants; + vec *identifiers; + vec *prios; + vec *operators; +}; + +struct MODE_CACHE_T +{ + MOID_T *proc_bool; + MOID_T *proc_char; + MOID_T *proc_complex_complex; + MOID_T *proc_int; + MOID_T *proc_int_int; + MOID_T *proc_int_int_real; + MOID_T *proc_int_real; + MOID_T *proc_int_real_real; + MOID_T *proc_int_real_real_real; + MOID_T *proc_real; + MOID_T *proc_real_int_real; + MOID_T *proc_real_real; + MOID_T *proc_real_real_int_real; + MOID_T *proc_real_real_real; + MOID_T *proc_real_real_real_int; + MOID_T *proc_real_real_real_real; + MOID_T *proc_real_real_real_real_real; + MOID_T *proc_real_real_real_real_real_real; + MOID_T *proc_real_ref_real_ref_int_void; + MOID_T *proc_void; +}; + +/* A PARSER_T struct contains all the global state that is kept by the parser. + This information is managed and used exclusively by a68_parser. + + ERROR_TAG is a tag that signifies an error. It is initialized in + a68_parser. + + STOP_SCANNER is a control flag used exclusively by the main loop in + tokenise_source, which is recursive. + + SCAN_BUF is a scratch buffer used by the scanner for several purposes. This + buffer is known to be big enough to hold any substring from the source file. + It is initialized in read_source_file. + + MAX_SCAN_BUF_LENGTH is the useable size of SCAN_BUF. This is used by the + scanner to grow SCAN_BUF as it includes other files. + + TAG_NUMBER is a global counter used by the parser to assign an unique number + to each tag it creates. It is used in a68_new_tag. + + BOTTOM_UP_CRASH_EXIT and TOP_DOWN_CRASH_EXIT are used to longjmp from deeply + nested errors in the bottom-up and top-down parsers respectively. */ + +struct GTY(()) PARSER_T +{ + TAG_T *error_tag; + bool stop_scanner; + size_t max_scan_buf_length; + char * GTY((skip)) scan_buf; + int tag_number; + jmp_buf GTY((skip)) bottom_up_crash_exit; + jmp_buf GTY((skip)) top_down_crash_exit; +}; + +/* A A68_T struct contains the global state used by the ALGOL 68 front-end. + + OUTPUT_LINE is used by the diagnostics machinery in order to write out + message lines. + + EDIT_LINE is used as a scratch buffer for composing error messages and the + like. + + INPUT_LINE is used by the original ALGOL 68 Genie to read lines from the + tty. But in this parser it is used uninitialized (!) by the + a68_phrase_to_text routine in the top-down parser. XXX. + + NEW_NODES is a global counter that keeps the number of parse tree nodes + created. It is currently not used for anything, but still updated in + a68_new_node. + + NEW_MODES is a global counter that keeps the number of moids created. It is + currently not used for anything, but still updated in a68_new_moid. + + NEW_POSTULATES is a global counter that keeps the number of postulates + created by the front-end. It is currently not used for anything, but still + updated in a68_make_postulate. + + NEW_NODE_INFOS is a global counter that keeps the number of NODE_INFO_T + structures created by the front-end. It is currently not used for anything, + but still updated in a68_new_node_info. + + NEW_GENIE_INFOS is a global counter that keeps the number of GINFO_T + structures created by the front-end. It is currently no tused for anything, + but still updated in a68_new_genie_info. + + SYMBOL_TABLE_COUNT is a global counter used by the parser. XXX move to + parser global state when syntax tree finalisation is moved to a68_parser? + + MODE_COUNT is the number of modes registered in the global modes table. XXX + which table. + + TOP_KEYWORD is the top of the list of keywords known to the font-end. + + MODE_CACHE XXX. + + A68_MODES (accessed as MODE) is a collection of particular pre-defined + modes. These modes are initialized by stand_moids. + + JOB (accessed as A68_JOB) is the instance of MODULE_T with the global data + corresponding to the source file being compiled. + + OPTIONS is the set of options currently set for the front-end. + + TOP_POSTULATE and TOP_POSTULATE_LIST are lists of postulates maintained by + the front-end. + + POSTULATES is a collection of postulates used by the moid pretty printer. + + TOP_SOID_LIST is used by the moid machinery. + + STANDENV XXX. + + TOP_TOKEN XXX. + + INCLUDE_PATHS is the list of paths where we search for files to include. + Directories are added to the list at the option handling language hook. + The list is searched in FIFO order. + + IMPORT_PATHS is the list of paths where we search for module exports data. + Directories are added to the list at the option handling language hook. The + list is searched in FIFO order. + + GLOBAL_TREES is an array with global types like a68_void_type and + a68_long_int_type. It is indexed by an enum a68_tree_index. + + MODULE_DEFINITION_DECLS is the global list of the tree decls corresponding + to the module definition being compiled. Note that currently we only allow + top-level modules, so there is no nesting. This is part of the context of + the lowering pass, and these declarations are collected by the lowering + handlers and finally compiled down to assembler in lower_module_declaration. + It cannot go in LOW_CTX_T because the later is on the stack and is not + reachable by the GGC. + + PARSER_STATE contains the parser's global state. + + GLOBAL_CONTEXT is the context to be used for global declarations. Normally + the translation unit. + + GLOBAL_DECLARATIONS contains a array of global declarations to pass back to + the middle-end at the end of the compilation. +*/ + +struct GTY(()) A68_T +{ + BUFFER output_line; + BUFFER edit_line; + BUFFER input_line; + int new_nodes; + int new_modes; + int new_postulates; + int new_node_infos; + int new_genie_infos; + int symbol_table_count; + int mode_count; + KEYWORD_T *top_keyword; + MODE_CACHE_T mode_cache; + MODES_T a68_modes; + MODULE_T job; + OPTIONS_T *options; + POSTULATE_T *postulates, *top_postulate, *top_postulate_list; + SOID_T *top_soid_list; + TABLE_T *standenv; + TOKEN_T *top_token; + vec *include_paths; + vec *import_paths; + hash_map *module_files; + tree global_trees[ATI_MAX]; + PARSER_T parser_state; + vec *module_definition_decls; + tree global_context; + vec *global_declarations; +}; + +/* + * Access macros to fields in the struct types defined above. These are used * + * in order to achieve a nice ALGOL-like field OF struct style. + */ + +#define ASM_LABEL(m) ((m)->asm_label) +#define BACKWARD(p) (p = PREVIOUS (p)) +#define DEFLEX(p) (DEFLEXED (p) != NO_MOID ? DEFLEXED(p) : (p)) +#define FORWARD(p) ((p) = NEXT (p)) +#define A(p) ((p)->a) +#define ANNOTATION(p) ((p)->annotation) +#define ANONYMOUS(p) ((p)->anonymous) +#define ATTRIBUTE(p) ((p)->attribute) +#define ASCRIBED_ROUTINE_TEXT(p) ((p)->ascribed_routine_text) +#define B(p) ((p)->b) +#define BODY(p) ((p)->body) +#define CAST(p) ((p)->cast) +#define CHAR_IN_LINE(p) ((p)->char_in_line) +#define CROSS_REFERENCE_SAFE(p) ((p)->cross_reference_safe) +#define CDECL(p) ((p)->cdecl) +#define COMMENT(p) ((p)->comment) +#define COMMENT_CHAR_IN_LINE(p) ((p)->comment_char_in_line) +#define COMMENT_LINE(p) ((p)->comment_line) +#define COMMENT_TYPE(p) ((p)->comment_type) +#define CTYPE(p) ((p)->ctype) +#define DEFLEXED(p) ((p)->deflexed_mode) +#define DEREFO(p) ((p).derefo) +#define DERIVATE(p) ((p)->derivate) +#define DIM(p) ((p)->dim) +#define DYNAMIC_STACK_ALLOCS(p) ((p)->dynamic_stack_allocs) +#define EQUIVALENT(p) ((p)->equivalent_mode) +#define EQUIVALENT_MODE(p) ((p)->equivalent_mode) +#define ERROR_COUNT(p) ((p)->error_count) +#define EXPORTED(p) ((p)->exported) +#define EXTERN_SYMBOL(p) ((p)->extern_symbol) +#define EXTRACT_IN_PROC(p) ((p)->in_proc) +#define EXTRACT_KIND(p) ((p)->kind) +#define EXTRACT_MODE(p) ((p)->mode) +#define EXTRACT_PRIO(p) ((p)->priority) +#define EXTRACT_SYMBOL(p) ((p)->symbol) +#define EXTRACT_VARIABLE(p) ((p)->variable) +#define WARNING_COUNT(p) ((p)->warning_count) +#define F(p) ((p)->f) +#define FILENAME(p) ((p)->filename) +#define FILE_SOURCE_FD(p) ((p)->file_source_fd) +#define FILE_SOURCE_NAME(p) ((p)->file_source_name) +#define FLEXO(p) ((p).flexo) +#define FLEXO_KNOWN(p) ((p).flexo_known) +#define G(p) ((p)->g) +#define GINFO(p) ((p)->genie) +#define GENO(p) ((p).geno) +#define GET(p) ((p)->get) +#define GPARENT(p) (PARENT (GINFO (p))) +#define GREEN(p) ((p)->green) +#define H(p) ((p)->h) +#define HANDLE(p) ((p)->handle) +#define HAS_ROWS(p) ((p)->has_rows) +#define HEAP(p) ((p)->heap) +#define ID(p) ((p)->id) +#define IDENTIFICATION(p) ((p)->identification) +#define IDENTIFIERS(p) ((p)->identifiers) +#define IDF(p) ((p)->idf) +#define IM(z) (VALUE (&(z)[1])) +#define IN(p) ((p)->in) +#define INDEX(p) ((p)->index) +#define INDICANTS(p) ((p)->indicants) +#define INFO(p) ((p)->info) +#define INITIALISE_ANON(p) ((p)->initialise_anon) +#define INITIALISE_FRAME(p) ((p)->initialise_frame) +#define INI_PTR(p) ((p)->ini_ptr) +#define INS_MODE(p) ((p)->ins_mode) +#define IN_FORBIDDEN(p) ((p)->in_forbidden) +#define IN_PREFIX(p) ((p)->in_prefix) +#define IN_PROC(p) ((p)->in_proc) +#define IN_TEXT(p) ((p)->in_text) +#define IS_OPEN(p) ((p)->is_open) +#define IS_RECURSIVE(p) ((p)->is_recursive) +#define IS_TMP(p) ((p)->is_tmp) +#define JUMP_STAT(p) ((p)->jump_stat) +#define JUMP_TO(p) ((p)->jump_to) +#define K(q) ((q)->k) +#define LABELS(p) ((p)->labels) +#define LAST(p) ((p)->last) +#define LAST_LINE(p) ((p)->last_line) +#define LESS(p) ((p)->less) +#define LEVEL(p) ((p)->level) +#define LEX_LEVEL(p) (LEVEL (TABLE (p))) +#define LINBUF(p) ((p)->linbuf) +#define LINE(p) ((p)->line) +#define LINE_APPLIED(p) ((p)->line_applied) +#define LINE_DEFINED(p) ((p)->line_defined) +#define LINE_END_MENDED(p) ((p)->line_end_mended) +#define LINE_NUMBER(p) (NUMBER (LINE (INFO (p)))) +#define LINSIZ(p) ((p)->linsiz) +#define LIST(p) ((p)->list) +#define ln(x) (log (x)) +#define LOCALE(p) ((p)->locale) +#define LOC_ASSIGNED(p) ((p)->loc_assigned) +#define LOWERER(p) ((p)->lowerer) +#define LOWER_BOUND(p) ((p)->lower_bound) +#define LWB(p) ((p)->lower_bound) +#define MARKER(p) ((p)->marker) +#define MATCH(p) ((p)->match) +#define MODIFIED(p) ((p)->modified) +#define MODULES(p) ((p)->modules) +#define VERSION(p) ((p)->version) +#define MODES(p) ((p)->modes) +#define MOID(p) ((p)->type) +#define MOIF(p) ((p)->moif) +#define MORE(p) ((p)->more) +#define MSGS(p) ((p)->msgs) +#define MULTIPLE(p) ((p)->multiple_mode) +#define MULTIPLE_MODE(p) ((p)->multiple_mode) +#define NAME(p) ((p)->name) +#define NEST(p) ((p)->nest) +#define NEXT(p) ((p)->next) +#define NEXT_NEXT(p) (NEXT (NEXT (p))) +#define NEXT_NEXT_NEXT(p) (NEXT (NEXT_NEXT (p))) +#define NEXT_SUB(p) (NEXT (SUB (p))) +#define NF(p) ((p)->nf) +#define NILO(p) ((p).nilo) +#define NILO_KNOWN(p) ((p).nilo_known) +#define NODE(p) ((p)->node) +#define NODE_DEFINED(p) ((p)->node_defined) +#define NODE_PACK(p) ((p)->pack) +#define NON_LOCAL(p) ((p)->non_local) +#define NCHAR_IN_LINE(p) (CHAR_IN_LINE (INFO (p))) +#define NCOMMENT(p) (COMMENT (INFO (p))) +#define NCOMMENT_CHAR_IN_LINE(p) (COMMENT_CHAR_IN_LINE (INFO (p))) +#define NCOMMENT_LINE(p) (COMMENT_LINE (INFO (p))) +#define NCOMMENT_TYPE(p) (COMMENT_TYPE (INFO (p))) +#define NPRAGMAT(p) (PRAGMAT (INFO (p))) +#define NPRAGMAT_CHAR_IN_LINE(p) (PRAGMAT_CHAR_IN_LINE (INFO (p))) +#define NPRAGMAT_LINE(p) (PRAGMAT_LINE (INFO (p))) +#define NPRAGMAT_TYPE(p) (PRAGMAT_TYPE (INFO (p))) +#define NSYMBOL(p) (SYMBOL (INFO (p))) +#define NUM(p) ((p)->num) +#define NUMBER(p) ((p)->number) +#define OPER(p) ((p)->oper) +#define OPERATORS(p) ((p)->operators) +#define OPT(p) ((p)->opt) +#define OPTIONS(p) ((p)->options) +#define OPTION_ASSERT(p) (OPTIONS (p).assert) +#define OPTION_BOUNDS_CHECKING(p) (OPTIONS (p).bounds_checking) +#define OPTION_BRACKETS(p) (OPTIONS (p).brackets) +#define OPTION_NIL_CHECKING(p) (OPTIONS (p).nil_checking) +#define OPTION_STRICT(p) (OPTIONS (p).strict) +#define OPTION_STROPPING(p) (OPTIONS (p).stropping) +#define OPTION_LIST(p) (OPTIONS (p).list) +#define OPTION_LOCAL(p) (OPTIONS (p).local) +#define OPTION_NODEMASK(p) (OPTIONS (p).nodemask) +#define OUT(p) ((p)->out) +#define OUTER(p) ((p)->outer) +#define P(q) ((q)->p) +#define PACK(p) ((p)->pack) +#define PARTIAL_LOCALE(p) ((p)->partial_locale) +#define PARTIAL_PROC(p) ((p)->partial_proc) +#define PORTABLE(p) ((p)->portable) +#define POSTLUDE(p) ((p)->postlude) +#define PRAGMAT(p) ((p)->pragmat) +#define PRAGMAT_CHAR_IN_LINE(p) ((p)->pragmat_char_in_line) +#define PRAGMAT_LINE(p) ((p)->pragmat_line) +#define PRAGMAT_TYPE(p) ((p)->pragmat_type) +#define PRELUDE(p) ((p)->prelude) +#define PREVIOUS(p) ((p)->previous) +#define PRIO(p) ((p)->priority) +#define PRIOS(p) ((p)->prios) +#define PROCEDURE_LEVEL(p) ((p)->procedure_level) +#define PROC_OPS(p) ((p)->proc_ops) +#define PUBLICIZED(p) ((p)->publicized) +#define PUBLIC_RANGE(p) ((p)->public_range) +#define R(p) ((p)->r) +#define RE(z) (VALUE (&(z)[0])) +#define ROWED(p) ((p)->rowed) +#define SCAN_STATE_C(p) ((p)->scan_state.save_c) +#define SCAN_STATE_L(p) ((p)->scan_state.save_l) +#define SCAN_STATE_S(p) ((p)->scan_state.save_s) +#define SCOPE(p) ((p)->scope) +#define SCOPE_ASSIGNED(p) ((p)->scope_assigned) +#define SEQUENCE(p) ((p)->sequence) +#define SEVERITY(p) ((p)->severity) +#define SLICE(p) ((p)->slice) +#define SORT(p) ((p)->sort) +#define SOURCE_SCAN(p) ((p)->source_scan) +#define STANDENV_MOID(p) ((p)->standenv_moid) +#define STATUS(p) ((p)->status) +#define STRING(p) ((p)->string) +#define SUB(p) ((p)->sub) +#define SUB_MOID(p) (SUB (MOID (p))) +#define SUB_NEXT(p) (SUB (NEXT (p))) +#define SUB_SUB(p) (SUB (SUB (p))) +#define SYMBOL(p) ((p)->symbol) +#define TABLE(p) ((p)->symbol_table) +#define TAG_LEX_LEVEL(p) (LEVEL (TAG_TABLE (p))) +#define TAG_TABLE(p) ((p)->symbol_table) +#define TAX(p) ((p)->tag) +#define TAX_TREE_DECL(p) ((p)->tree_decl) +#define TEXT(p) ((p)->text) +#define TOP_LINE(p) ((p)->top_line) +#define TOP_MOID(p) ((p)->top_moid) +#define TOP_NODE(p) ((p)->top_node) +#define TRANSIENT(p) ((p)->transient) +#define TREE_LISTING_SAFE(p) ((p)->tree_listing_safe) +#define TRIM(p) ((p)->trim) +#define TUPLE(p) ((p)->tuple) +#define UNIT(p) ((p)->unit) +#define USE(p) ((p)->use) +#define VALUE(p) ((p)->value) +#define VARIABLE(p) ((p)->variable) +#define WHERE(p) ((p)->where) +#define IS_FLEXETY_ROW(m) (IS_FLEX (m) || IS_ROW (m) || m == M_STRING) +#define IS_FLEX(m) IS ((m), FLEX_SYMBOL) +#define IS_LITERALLY(p, s) (strcmp (NSYMBOL (p), s) == 0) +#define ISNT(p, s) (! IS (p, s)) +#define IS(p, s) (ATTRIBUTE (p) == (s)) +#define IS_REF_FLEX(m) (IS (m, REF_SYMBOL) && IS (SUB (m), FLEX_SYMBOL)) +#define IS_REF(m) IS ((m), REF_SYMBOL) +#define IS_INTEGRAL(m) \ + ((m) == M_INT \ + || (m) == M_LONG_INT \ + || (m) == M_LONG_LONG_INT \ + || (m) == M_SHORT_INT \ + || (m) == M_SHORT_SHORT_INT) +#define IS_BITS(m) \ + ((m) == M_BITS \ + || (m) == M_LONG_BITS \ + || (m) == M_LONG_LONG_BITS \ + || (m) == M_SHORT_BITS \ + || (m) == M_SHORT_SHORT_BITS) +#define IS_BYTES(m) \ + ((m) == M_BYTES || (m) == M_LONG_BYTES) +#define IS_COMPLEX(m) \ + ((m) == M_COMPLEX \ + || (m) == M_LONG_COMPLEX \ + || (m) == M_LONG_LONG_COMPLEX) +#define IS_REAL(m) \ + ((m) == M_REAL \ + || (m) == M_LONG_REAL \ + || (m) == M_LONG_LONG_REAL) +#define IS_ROW(m) IS ((m), ROW_SYMBOL) +#define IS_STRUCT(m) IS ((m), STRUCT_SYMBOL) +#define IS_UNION(m) IS ((m), UNION_SYMBOL) +#define YOUNGEST_ENVIRON(p) ((p)->youngest_environ) + +#endif /* ! __A68_TYPES_H */ diff --git a/gcc/algol68/a68.h b/gcc/algol68/a68.h new file mode 100644 index 00000000000..92dc28e222f --- /dev/null +++ b/gcc/algol68/a68.h @@ -0,0 +1,1117 @@ +/* Definitions for the Algol 68 GCC front end. + Copyright (C) 2025 Jose E. Marchesi. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#ifndef __A68_H__ +#define __A68_H__ + +/* Some common definitions first. */ + +#define BUFFER_SIZE 1024 +#define SMALL_BUFFER_SIZE 128 +#define SNPRINTF_SIZE ((size_t) (BUFFER_SIZE - 1)) +#define BUFCLR(z) {memset ((z), 0, BUFFER_SIZE + 1);} +#define MOID_ERROR_WIDTH 80 + +#define MONADS "%^&+-~!?" +#define NOMADS ">= 4001) || GCC_VERSION == BUILDING_GCC_VERSION +#define ATTRIBUTE_A68_DIAG(m, n) __attribute__ ((__format__ (__gcc_tdiag__, m, n))) ATTRIBUTE_NONNULL(m) +#else +#define ATTRIBUTE_A68_DIAG(m, n) ATTRIBUTE_NONNULL(m) +#endif + +/* Maximum number of priorities supported for operators. The Algol 68 RR + specifies 9. */ + +#define MAX_PRIORITY 9 + +/* The primal scope is the top-level scope. */ + +#define PRIMAL_SCOPE 0 + +/* Deflexing strategy. See the moid checking routines in + a68-parser-moids-check for an explanation of these values. */ + +enum +{ + NO_DEFLEXING = 1, SAFE_DEFLEXING, ALIAS_DEFLEXING, FORCE_DEFLEXING, + SKIP_DEFLEXING +}; + +/* Magic number for the exports data. */ + +#define A68_EXPORT_MAGIC_LEN 2 + +#define A68_EXPORT_MAGIC1 0x0a +#define A68_EXPORT_MAGIC2 0x68 + +/* The segment name we pass to simple_object_start_read to find Algol 68 export + data. */ + +#ifndef A68_EXPORT_SEGMENT_NAME +#define A68_EXPORT_SEGMENT_NAME "__GNU_A68" +#endif + +/* The section name we use when reading and writing export data. */ + +#ifndef A68_EXPORT_SECTION_NAME +#define A68_EXPORT_SECTION_NAME ".a68_exports" +#endif + +/* ga68 export format definitions. See ga68-exports.pk. */ + +#define GA68_EXPORTS_VERSION 1 + +#define GA68_MODE_UNKNOWN 0 +#define GA68_MODE_VOID 1 +#define GA68_MODE_INT 2 +#define GA68_MODE_REAL 3 +#define GA68_MODE_BITS 4 +#define GA68_MODE_BYTES 5 +#define GA68_MODE_CHAR 6 +#define GA68_MODE_BOOL 7 +#define GA68_MODE_CMPL 8 +#define GA68_MODE_ROW 9 +#define GA68_MODE_STRUCT 10 +#define GA68_MODE_UNION 11 +#define GA68_MODE_NAME 12 +#define GA68_MODE_PROC 13 +#define GA68_MODE_STRING 14 +#define GA68_MODE_FLEX 15 + +#define GA68_EXTRACT_MODU 0 +#define GA68_EXTRACT_IDEN 1 +#define GA68_EXTRACT_MODE 2 +#define GA68_EXTRACT_PRIO 3 +#define GA68_EXTRACT_OPER 4 + +/* Then the types. */ + +#include "a68-types.h" + +/* Front-end global state. */ + +extern GTY(()) A68_T a68_common; +#define A68(z) (a68_common.z) +#define A68_JOB A68 (job) +#define A68_STANDENV A68 (standenv) +#define A68_MCACHE(z) A68 (mode_cache.z) +#define A68_INCLUDE_PATHS A68 (include_paths) +#define A68_IMPORT_PATHS A68 (import_paths) +#define A68_MODULE_FILES A68 (module_files) +#define A68_GLOBAL_TREES A68 (global_trees) +#define A68_PARSER(Z) (A68 (parser_state).Z) +#define A68_MODULE_DEFINITION_DECLS A68 (module_definition_decls) +#define A68_GLOBAL_CONTEXT A68 (global_context) +#define A68_GLOBAL_DECLARATIONS A68 (global_declarations) + +/* Particular pre-defined modes. */ + +#define MODE(p) A68 (a68_modes.p) +#define M_BITS (MODE (BITS)) +#define M_BOOL (MODE (BOOL)) +#define M_BYTES (MODE (BYTES)) +#define M_CHANNEL (MODE (CHANNEL)) +#define M_CHAR (MODE (CHAR)) +#define M_COLLITEM (MODE (COLLITEM)) +#define M_COMPLEX (MODE (COMPLEX)) +#define M_C_STRING (MODE (C_STRING)) +#define M_ERROR (MODE (ERROR)) +#define M_FILE (MODE (FILE)) +#define M_FLEX_ROW_BOOL (MODE (FLEX_ROW_BOOL)) +#define M_FLEX_ROW_CHAR (MODE (FLEX_ROW_CHAR)) +#define M_FORMAT (MODE (FORMAT)) +#define M_HIP (MODE (HIP)) +#define M_INT (MODE (INT)) +#define M_LONG_BITS (MODE (LONG_BITS)) +#define M_LONG_BYTES (MODE (LONG_BYTES)) +#define M_LONG_COMPLEX (MODE (LONG_COMPLEX)) +#define M_LONG_INT (MODE (LONG_INT)) +#define M_LONG_LONG_INT (MODE (LONG_LONG_INT)) +#define M_LONG_LONG_BITS (MODE (LONG_LONG_BITS)) +#define M_LONG_LONG_COMPLEX (MODE (LONG_LONG_COMPLEX)) +#define M_LONG_LONG_INT (MODE (LONG_LONG_INT)) +#define M_LONG_LONG_REAL (MODE (LONG_LONG_REAL)) +#define M_LONG_REAL (MODE (LONG_REAL)) +#define M_NIL (MODE (NIL)) +#define M_NUMBER (MODE (NUMBER)) +#define M_PROC_LONG_REAL_LONG_REAL (MODE (PROC_LONG_REAL_LONG_REAL)) +#define M_PROC_REAL_REAL (MODE (PROC_REAL_REAL)) +#define M_PROC_REF_FILE_BOOL (MODE (PROC_REF_FILE_BOOL)) +#define M_PROC_REF_FILE_VOID (MODE (PROC_REF_FILE_VOID)) +#define M_PROC_ROW_CHAR (MODE (PROC_ROW_CHAR)) +#define M_PROC_STRING (MODE (PROC_STRING)) +#define M_PROC_VOID (MODE (PROC_VOID)) +#define M_REAL (MODE (REAL)) +#define M_REF_BITS (MODE (REF_BITS)) +#define M_REF_BOOL (MODE (REF_BOOL)) +#define M_REF_BYTES (MODE (REF_BYTES)) +#define M_REF_CHAR (MODE (REF_CHAR)) +#define M_REF_COMPLEX (MODE (REF_COMPLEX)) +#define M_REF_FILE (MODE (REF_FILE)) +#define M_REF_INT (MODE (REF_INT)) +#define M_REF_LONG_BITS (MODE (REF_LONG_BITS)) +#define M_REF_LONG_BYTES (MODE (REF_LONG_BYTES)) +#define M_REF_LONG_COMPLEX (MODE (REF_LONG_COMPLEX)) +#define M_REF_LONG_INT (MODE (REF_LONG_INT)) +#define M_REF_LONG_LONG_BITS (MODE (REF_LONG_LONG_BITS)) +#define M_REF_LONG_LONG_COMPLEX (MODE (REF_LONG_LONG_COMPLEX)) +#define M_REF_LONG_LONG_INT (MODE (REF_LONG_LONG_INT)) +#define M_REF_LONG_LONG_REAL (MODE (REF_LONG_LONG_REAL)) +#define M_REF_LONG_REAL (MODE (REF_LONG_REAL)) +#define M_REF_REAL (MODE (REF_REAL)) +#define M_REF_REF_FILE (MODE (REF_REF_FILE)) +#define M_REF_SHORT_BITS (MODE (REF_SHORT_BITS)) +#define M_REF_SHORT_SHORT_BITS (MODE (REF_SHORT_SHORT_BITS)) +#define M_REF_ROW_CHAR (MODE (REF_ROW_CHAR)) +#define M_REF_ROW_COMPLEX (MODE (REF_ROW_COMPLEX)) +#define M_REF_ROW_INT (MODE (REF_ROW_INT)) +#define M_REF_ROW_REAL (MODE (REF_ROW_REAL)) +#define M_REF_ROW_ROW_COMPLEX (MODE (REF_ROW_ROW_COMPLEX)) +#define M_REF_ROW_ROW_REAL (MODE (REF_ROW_ROW_REAL)) +#define M_REF_SHORT_INT (MODE (REF_SHORT_INT)) +#define M_REF_SHORT_SHORT_INT (MODE (REF_SHORT_SHORT_INT)) +#define M_REF_STRING (MODE (REF_STRING)) +#define M_ROW_BITS (MODE (ROW_BITS)) +#define M_ROW_BOOL (MODE (ROW_BOOL)) +#define M_ROW_CHAR (MODE (ROW_CHAR)) +#define M_ROW_COMPLEX (MODE (ROW_COMPLEX)) +#define M_ROW_INT (MODE (ROW_INT)) +#define M_ROW_REAL (MODE (ROW_REAL)) +#define M_ROW_ROW_CHAR (MODE (ROW_ROW_CHAR)) +#define M_ROW_ROW_COMPLEX (MODE (ROW_ROW_COMPLEX)) +#define M_ROW_ROW_REAL (MODE (ROW_ROW_REAL)) +#define M_ROW_SIMPLIN (MODE (ROW_SIMPLIN)) +#define M_ROW_SIMPLOUT (MODE (ROW_SIMPLOUT)) +#define M_ROWS (MODE (ROWS)) +#define M_ROW_STRING (MODE (ROW_STRING)) +#define M_SEMA (MODE (SEMA)) +#define M_SHORT_BITS (MODE (SHORT_BITS)) +#define M_SHORT_SHORT_BITS (MODE (SHORT_SHORT_BITS)) +#define M_SHORT_INT (MODE (SHORT_INT)) +#define M_SHORT_SHORT_INT (MODE (SHORT_SHORT_INT)) +#define M_SIMPLIN (MODE (SIMPLIN)) +#define M_SIMPLOUT (MODE (SIMPLOUT)) +#define M_STRING (MODE (STRING)) +#define M_UNDEFINED (MODE (UNDEFINED)) +#define M_VACUUM (MODE (VACUUM)) +#define M_VOID (MODE (VOID)) + +/* Usage of TYPE_LANG_FLAG_* flags. */ + +#define A68_ROW_TYPE_P(NODE) TYPE_LANG_FLAG_0 (NODE) +#define A68_UNION_TYPE_P(NODE) TYPE_LANG_FLAG_1 (NODE) +#define A68_STRUCT_TYPE_P(NODE) TYPE_LANG_FLAG_2 (NODE) +#define A68_ROWS_TYPE_P(NODE) TYPE_LANG_FLAG_3 (NODE) +#define A68_TYPE_HAS_ROWS_P(NODE) TYPE_LANG_FLAG_4 (NODE) + +/* Language-specific tree checkers. */ + +#define STRUCT_OR_UNION_TYPE_CHECK(NODE) \ + TREE_CHECK2 (NODE, RECORD_TYPE, UNION_TYPE) + +/* Usage of TYPE_LANG_SLOT_* fields. */ + +#define TYPE_FORWARD_REFERENCES(NODE) \ + (TYPE_LANG_SLOT_1 (STRUCT_OR_UNION_TYPE_CHECK (NODE))) + +/* a68-unistr.cc */ + +int a68_u8_mbtouc (uint32_t *puc, const uint8_t *s, size_t n); +int a68_u8_uctomb (uint8_t *s, uint32_t uc, ptrdiff_t n); + +uint32_t *a68_u8_to_u32 (const uint8_t *s, size_t n, uint32_t *resultbuf, size_t *lengthp); + +/* a68-lang.cc */ + +/* Global types. These are built in a68_build_a68_type_nodes and used by the + lowering routines. */ + +#define a68_void_type A68_GLOBAL_TREES[ATI_VOID_TYPE] +#define a68_bool_type A68_GLOBAL_TREES[ATI_BOOL_TYPE] +#define a68_char_type A68_GLOBAL_TREES[ATI_CHAR_TYPE] +#define a68_short_short_bits_type A68_GLOBAL_TREES[ATI_SHORT_SHORT_BITS_TYPE] +#define a68_short_bits_type A68_GLOBAL_TREES[ATI_SHORT_BITS_TYPE] +#define a68_bits_type A68_GLOBAL_TREES[ATI_BITS_TYPE] +#define a68_long_bits_type A68_GLOBAL_TREES[ATI_LONG_BITS_TYPE] +#define a68_long_long_bits_type A68_GLOBAL_TREES[ATI_LONG_LONG_BITS_TYPE] +#define a68_bytes_type A68_GLOBAL_TREES[ATI_BYTES_TYPE] +#define a68_long_bytes_type A68_GLOBAL_TREES[ATI_LONG_BYTES_TYPE] +#define a68_short_short_int_type A68_GLOBAL_TREES[ATI_SHORT_SHORT_INT_TYPE] +#define a68_short_int_type A68_GLOBAL_TREES[ATI_SHORT_INT_TYPE] +#define a68_int_type A68_GLOBAL_TREES[ATI_INT_TYPE] +#define a68_long_int_type A68_GLOBAL_TREES[ATI_LONG_INT_TYPE] +#define a68_long_long_int_type A68_GLOBAL_TREES[ATI_LONG_LONG_INT_TYPE] +#define a68_real_type A68_GLOBAL_TREES[ATI_REAL_TYPE] +#define a68_long_real_type A68_GLOBAL_TREES[ATI_LONG_REAL_TYPE] +#define a68_long_long_real_type A68_GLOBAL_TREES[ATI_LONG_LONG_REAL_TYPE] + +struct lang_type *a68_build_lang_type (MOID_T *moid); +struct lang_decl *a68_build_lang_decl (NODE_T *node); +MOID_T *a68_type_moid (tree type); + +/* a68-diagnostics.cc */ + +void a68_error (NODE_T *p, const char *loc_str, ...); +void a68_error_in_pragmat (NODE_T *p, size_t off, + const char *loc_str, ...); +bool a68_warning (NODE_T *p, int opt, const char *loc_str, ...); +void a68_inform (NODE_T *p, const char *loc_str, ...); +void a68_fatal (NODE_T *p, const char *loc_str, ...); +void a68_scan_error (LINE_T *u, char *v, const char *txt, ...); + +/* a68-parser-scanner.cc */ + +bool a68_lexical_analyser (const char *filename); + +/* a68-parser.cc */ + +int a68_count_operands (NODE_T *p); +int a68_count_formal_bounds (NODE_T *p); +void a68_count_pictures (NODE_T *p, int *k); +bool a68_is_ref_refety_flex (MOID_T *m); +bool a68_is_semicolon_less (NODE_T *p); +bool a68_is_formal_bounds (NODE_T *p); +bool a68_is_unit_terminator (NODE_T *p); +bool a68_is_loop_keyword (NODE_T *p); +bool a68_is_new_lexical_level (NODE_T *p); +bool a68_dont_mark_here (NODE_T *p); +enum a68_attribute a68_get_good_attribute (NODE_T *p); +void a68_parser (const char *filename); +NODE_INFO_T *a68_new_node_info (void); +GINFO_T *a68_new_genie_info (void); +NODE_T *a68_new_node (void); +NODE_T *a68_some_node (const char *t); +TABLE_T *a68_new_symbol_table (TABLE_T *p); +MOID_T *a68_new_moid (void); +PACK_T *a68_new_pack (void); +TAG_T *a68_new_tag (void); +void a68_make_special_mode (MOID_T **, int m); +void a68_make_sub (NODE_T *p, NODE_T *, enum a68_attribute t); +bool a68_whether (NODE_T *, ...); +bool a68_is_one_of (NODE_T *p, ...); +void a68_bufcat (char *dst, const char *src, int len); +void a68_bufcpy (char *dst, const char *src, int len); +char *a68_new_string (const char *t, ...); +const char *a68_attribute_name (enum a68_attribute attr); +location_t a68_get_node_location (NODE_T *p); +location_t a68_get_line_location (LINE_T *line, const char *pos); + +/* a68-parser-top-down.cc */ + +void a68_substitute_brackets (NODE_T *p); +const char *a68_phrase_to_text (NODE_T *p, NODE_T **w); +void a68_top_down_parser (NODE_T *p); + +/* a68-parser-bottom-up.cc */ + +void a68_bottom_up_parser (NODE_T *p); +void a68_bottom_up_error_check (NODE_T *p); +void a68_rearrange_goto_less_jumps (NODE_T *p); +void a68_bottom_up_coalesce_pub (NODE_T *p); + +/* a68-parser-extract.cc */ + +void a68_extract_indicants (NODE_T *p); +void a68_extract_priorities (NODE_T *p); +void a68_extract_operators (NODE_T *p); +void a68_extract_labels (NODE_T *p, int expect); +void a68_extract_declarations (NODE_T *p); +void a68_elaborate_bold_tags (NODE_T *p); + +/* a68-parser-keywords.cc */ + +const char *a68_strop_keyword (const char *keyword); +void a68_set_up_tables (void); +TOKEN_T *a68_add_token (TOKEN_T **p, const char *t); +KEYWORD_T *a68_find_keyword (KEYWORD_T *p, const char *t); +KEYWORD_T *a68_find_keyword_from_attribute (KEYWORD_T *p, enum a68_attribute a); + +/* a68-postulates.cc */ + +void a68_init_postulates (void); +void a68_free_postulate_list (POSTULATE_T *, POSTULATE_T *); +void a68_make_postulate (POSTULATE_T **, MOID_T *, MOID_T *); +POSTULATE_T *a68_is_postulated (POSTULATE_T *, MOID_T *); +POSTULATE_T *a68_is_postulated_pair (POSTULATE_T *, MOID_T *, MOID_T *); + +/* a68-parser-moids-check.cc */ + +void a68_mode_checker (NODE_T *p); + +/* a68-parser-moids-coerce.cc */ + +void a68_coercion_inserter (NODE_T *p); + +/* a68-parser-moids-equivalence.cc */ + +bool a68_prove_moid_equivalence (MOID_T *, MOID_T *); + +/* a68-parser-brackets.cc */ + +void a68_check_parenthesis (NODE_T *top); + +/* a68-parser-prelude.cc */ + +void a68_make_standard_environ (void); + +/* a68-parser-taxes.cc */ + +void a68_set_proc_level (NODE_T *p, int n); +void a68_set_nest (NODE_T *p, NODE_T *s); +int a68_first_tag_global (TABLE_T * table, const char *name); +void a68_collect_taxes (NODE_T *p); +TAG_T *a68_add_tag (TABLE_T *s, int a, NODE_T *n, MOID_T *m, int p); +TAG_T *a68_find_tag_global (TABLE_T *table, int a, const char *name); +int a68_is_identifier_or_label_global (TABLE_T *table, const char *name); +void a68_reset_symbol_table_nest_count (NODE_T *p); +void a68_bind_routine_tags_to_tree (NODE_T *p); +void a68_fill_symbol_table_outer (NODE_T *p, TABLE_T *s); +void a68_finalise_symbol_table_setup (NODE_T *p, int l); +void a68_preliminary_symbol_table_setup (NODE_T *p); +void a68_mark_moids (NODE_T *p); +void a68_mark_auxilliary (NODE_T *p); +void a68_warn_for_unused_tags (NODE_T *p); +void a68_jumps_from_procs (NODE_T *p); + +/* a68-parser-victal.cc */ + +void a68_victal_checker (NODE_T *p); + +/* a68-parser-modes.cc */ + +int a68_count_pack_members (PACK_T *u); +MOID_T *a68_register_extra_mode (MOID_T **z, MOID_T *u); +MOID_T *a68_create_mode (int att, int dim, NODE_T *node, MOID_T *sub, PACK_T *pack); +MOID_T *a68_search_equivalent_mode (MOID_T *m); +MOID_T *a68_add_mode (MOID_T **z, int att, int dim, NODE_T *node, MOID_T *sub, PACK_T *pack); +void a68_contract_union (MOID_T *u); +PACK_T *a68_absorb_union_pack (PACK_T * u); +void a68_add_mode_to_pack (PACK_T **p, MOID_T *m, const char *text, NODE_T *node); +void a68_add_mode_to_pack_end (PACK_T **p, MOID_T *m, const char *text, NODE_T *node); +void a68_make_moid_list (MODULE_T *mod); + +void a68_renumber_moids (MOID_T *p, int n); + +/* a68-moids-to-string.cc */ + +const char *a68_moid_to_string (MOID_T *n, size_t w, NODE_T *idf, + bool indicant_value = false); + +/* a68-moids-misc.cc */ + +bool a68_basic_coercions (MOID_T *p, MOID_T *q, int c, int deflex); +bool a68_clause_allows_balancing (int att); +bool a68_is_balanced (NODE_T *n, SOID_T *y, int sort); +bool a68_is_coercible_in_context (SOID_T *p, SOID_T *q, int deflex); +bool a68_is_coercible (MOID_T *p, MOID_T *q, int c, int deflex); +bool a68_is_coercible_series (MOID_T *p, MOID_T *q, int c, int deflex); +bool a68_is_coercible_stowed (MOID_T *p, MOID_T *q, int c, int deflex); +bool a68_is_deprefable (MOID_T *p); +bool a68_is_equal_modes (MOID_T *p, MOID_T *q, int deflex); +bool a68_is_firmly_coercible (MOID_T *p, MOID_T *q, int deflex); +bool a68_is_firm (MOID_T *p, MOID_T *q); +bool a68_is_meekly_coercible (MOID_T *p, MOID_T *q, int deflex); +bool a68_is_mode_isnt_well (MOID_T *p); +bool a68_is_moid_in_pack (MOID_T *u, PACK_T *v, int deflex); +bool a68_is_name_struct (MOID_T *p); +bool a68_is_nonproc (MOID_T *p); +bool a68_is_printable_mode (MOID_T *p); +bool a68_is_proc_ref_file_void_or_format (MOID_T *p); +bool a68_is_readable_mode (MOID_T *p); +bool a68_is_ref_row (MOID_T *p); +bool a68_is_rows_type (MOID_T *p); +bool a68_is_softly_coercible (MOID_T *p, MOID_T *q, int deflex); +bool a68_is_strongly_coercible (MOID_T *p, MOID_T *q, int deflex); +bool a68_is_strong_name (MOID_T *p, MOID_T *q); +bool a68_is_strong_slice (MOID_T *p, MOID_T *q); +bool a68_is_subset (MOID_T *p, MOID_T *q, int deflex); +bool a68_is_transput_mode (MOID_T *p, char rw); +bool a68_is_unitable (MOID_T *p, MOID_T *q, int deflex); +bool a68_is_weakly_coercible (MOID_T * p, MOID_T * q, int deflex); +bool a68_is_widenable (MOID_T *p, MOID_T *q); +MOID_T *a68_absorb_related_subsets (MOID_T *m); +MOID_T *a68_depref_completely (MOID_T *p); +MOID_T *a68_depref_once (MOID_T *p); +MOID_T *a68_depref_rows (MOID_T *p, MOID_T *q); +MOID_T *a68_deproc_completely (MOID_T *p); +MOID_T *a68_derow (MOID_T *p); +MOID_T *a68_determine_unique_mode (SOID_T *z, int deflex); +MOID_T *a68_get_balanced_mode (MOID_T *m, int sort, bool return_depreffed, int deflex); +MOID_T *a68_get_balanced_mode_or_no_mode (MOID_T *m, int sort, bool return_depreffed, int deflex); +MOID_T *a68_make_series_from_moids (MOID_T *u, MOID_T *v); +MOID_T *a68_make_united_mode (MOID_T *m); +MOID_T *a68_pack_soids_in_moid (SOID_T *top_sl, int attribute); +MOID_T *a68_unites_to (MOID_T *m, MOID_T *u); +void a68_absorb_series_pack (MOID_T **p); +void a68_absorb_series_union_pack (MOID_T **p); +void a68_add_to_soid_list (SOID_T **root, NODE_T *where, SOID_T *soid); +void a68_free_soid_list (SOID_T *root); +void a68_investigate_firm_relations (PACK_T *u, PACK_T *v, bool *all, bool *some); +void a68_make_coercion (NODE_T *l, enum a68_attribute a, MOID_T *m); +void a68_make_depreffing_coercion (NODE_T *n, MOID_T *p, MOID_T *q); +void a68_make_ref_rowing_coercion (NODE_T *n, MOID_T *p, MOID_T *q); +void a68_make_rowing_coercion (NODE_T *n, MOID_T *p, MOID_T *q); +void a68_make_soid (SOID_T *s, int sort, MOID_T *type, int attribute); +void a68_make_strong (NODE_T *n, MOID_T *p, MOID_T *q); +void a68_make_uniting_coercion (NODE_T *n, MOID_T *q); +void a68_make_void (NODE_T *p, MOID_T *q); + +#define A68_DEPREF true +#define A68_NO_DEPREF false + +#define A68_IF_MODE_IS_WELL(n) (! ((n) == M_ERROR || (n) == M_UNDEFINED)) + +/* a68-parser-scope.cc */ + +void a68_scope_checker (NODE_T *p); + +/* a68-parser-serial-dsa.cc */ + +void a68_serial_dsa (NODE_T *p); + +/* a68-parser-pragmat.cc */ + +void a68_handle_pragmats (NODE_T *p); + +/* a68-moids-diagnostics.cc */ + +const char *a68_mode_error_text (NODE_T *n, MOID_T *p, MOID_T *q, int context, int deflex, int depth); +void a68_cannot_coerce (NODE_T *p, MOID_T *from, MOID_T *to, int context, int deflex, int att); +void a68_warn_for_voiding (NODE_T *p, SOID_T *x, SOID_T *y, int c); +void a68_semantic_pitfall (NODE_T *p, MOID_T *m, int c, int u); + +/* a68-low-misc.cc */ + +tree a68_lower_assertion (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_jump (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_parameter (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_parameter_list (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_parameter_pack (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_operator (NODE_T *p, LOW_CTX_T ctx); + +/* a68-low-moids.cc */ + +void a68_lower_moids (MOID_T *m); +void a68_set_type_moid (tree type, MOID_T *m); +tree a68_row_elements_pointer_type (tree type); +tree a68_row_elements_type (tree type); +tree a68_triplet_type (void); + +/* a68-low-bits.cc */ + +tree a68_get_bits_skip_tree (MOID_T *m); +tree a68_bits_width (tree type); +tree a68_bits_maxbits (tree type); +tree a68_bits_bin (MOID_T *m, tree val); +tree a68_bits_abs (MOID_T *m, tree bits); +tree a68_bits_leng (tree type, tree bits); +tree a68_bits_shorten (tree type, tree bits); +tree a68_bits_not (tree bits); +tree a68_bits_and (tree bits1, tree bits2); +tree a68_bits_ior (tree bits1, tree bits2); +tree a68_bits_xor (tree bits1, tree bits2); +tree a68_bits_elem (NODE_T *p, tree pos, tree bits); +tree a68_bits_subset (tree bits1, tree bits2); +tree a68_bits_shift (tree shift, tree bits); +tree a68_bits_eq (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_bits_ne (tree a, tree b, location_t loc = UNKNOWN_LOCATION); + +/* a68-low_bools.cc */ + +tree a68_get_bool_skip_tree (void); +tree a68_bool_abs (tree val); +tree a68_bool_eq (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_bool_ne (tree a, tree b, location_t loc = UNKNOWN_LOCATION); + +/* a68-low-ints.cc */ + +tree a68_get_int_skip_tree (MOID_T *m); +tree a68_int_maxval (tree type); +tree a68_int_minval (tree type); +tree a68_int_width (tree type); +tree a68_int_sign (tree val); +tree a68_int_abs (tree val); +tree a68_int_shorten (MOID_T *to_mode, MOID_T *from_mode, tree val); +tree a68_int_leng (MOID_T *to_mode, MOID_T *from_mode, tree val); + +tree a68_int_plus (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_minus (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_mult (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_div (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_mod (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_pow (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_eq (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_ne (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_lt (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_le (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_gt (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_int_ge (tree a, tree b, location_t loc = UNKNOWN_LOCATION); + +/* a68-low-complex.cc */ + +tree a68_complex_i (MOID_T *mode, tree re, tree im); +tree a68_complex_re (tree z); +tree a68_complex_im (tree z); +tree a68_complex_conj (MOID_T *mode, tree z); +tree a68_complex_widen_from_real (MOID_T *mode, tree r); + +/* a68-low-posix.cc */ + +tree a68_posix_setexitstatus (void); +tree a68_posix_argc (void); +tree a68_posix_argv (void); +tree a68_posix_getenv (void); +tree a68_posix_putchar (void); +tree a68_posix_puts (void); +tree a68_posix_fconnect (void); +tree a68_posix_fcreate (void); +tree a68_posix_fopen (void); +tree a68_posix_fclose (void); +tree a68_posix_fsize (void); +tree a68_posix_lseek (void); +tree a68_posix_errno (void); +tree a68_posix_perror (void); +tree a68_posix_strerror (void); +tree a68_posix_getchar (void); +tree a68_posix_fgetc (void); +tree a68_posix_fputc (void); +tree a68_posix_fputs (void); +tree a68_posix_gets (void); +tree a68_posix_fgets (void); + +/* a68-low-reals.cc */ + +tree a68_get_real_skip_tree (MOID_T *m); +tree a68_real_pi (tree type); +tree a68_real_maxval (tree type); +tree a68_real_minval (tree type); +tree a68_real_smallval (tree type); +tree a68_real_width (tree type); +tree a68_real_exp_width (tree type); +tree a68_real_sign (tree val); +tree a68_real_abs (tree val); +tree a68_real_sqrt (tree val); +tree a68_real_tan (tree type); +tree a68_real_sin (tree type); +tree a68_real_cos (tree type); +tree a68_real_acos (tree type); +tree a68_real_asin (tree type); +tree a68_real_atan (tree type); +tree a68_real_ln (tree type); +tree a68_real_log (tree type); +tree a68_real_exp (tree type); +tree a68_real_shorten (MOID_T *to_mode, MOID_T *from_mode, tree val); +tree a68_real_leng (MOID_T *to_mode, MOID_T *from_mode, tree val); +tree a68_real_entier (tree val, MOID_T *to_mode, MOID_T *from_mode); +tree a68_real_round (tree val, MOID_T *to_mode, MOID_T *from_mode); + +tree a68_real_plus (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_minus (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_mult (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_div (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_mod (MOID_T *m, tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_pow (MOID_T *m, MOID_T *a_mode, MOID_T *b_mode, + tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_eq (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_ne (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_lt (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_le (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_gt (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_real_ge (tree a, tree b, location_t loc = UNKNOWN_LOCATION); + + +/* a68-low-strings.cc */ + +tree a68_get_string_skip_tree (void); +tree a68_string_concat (tree str1, tree str2); +tree a68_string_mult (tree str1, tree str2); +tree a68_string_from_char (tree c); +tree a68_string_cmp (tree s1, tree s2); +char *a68_string_process_breaks (NODE_T *p, const char *str); + +/* a68-low-chars.cc */ + +tree a68_get_char_skip_tree (void); +tree a68_char_max (void); +tree a68_char_repr (NODE_T *p, tree val); +tree a68_char_abs (tree val); +tree a68_char_eq (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_char_ne (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_char_lt (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_char_le (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_char_gt (tree a, tree b, location_t loc = UNKNOWN_LOCATION); +tree a68_char_ge (tree a, tree b, location_t loc = UNKNOWN_LOCATION); + +/* a68-low-refs.cc */ + +tree a68_get_ref_skip_tree (MOID_T *m); + +/* a68-low-procs.cc */ + +tree a68_get_proc_skip_tree (MOID_T *m); + +/* a68-low-structs.cc */ + +tree a68_get_struct_skip_tree (MOID_T *m); + +/* a68-low-multiples.cc */ + +tree a68_get_multiple_skip_tree (MOID_T *m); +tree a68_multiple_dimensions (tree exp); +tree a68_multiple_num_elems (tree exp); +tree a68_multiple_lower_bound (tree exp, tree dim); +tree a68_multiple_upper_bound (tree exp, tree dim); +tree a68_multiple_stride (tree exp, tree dim); +tree a68_multiple_triplets (tree exp); +tree a68_multiple_elements (tree exp); +tree a68_multiple_elements_size (tree exp); +tree a68_multiple_set_elements (tree exp, tree elements); +tree a68_multiple_set_elements_size (tree exp, tree elements_size); +void a68_multiple_compute_strides (tree type, size_t dim, + tree *lower_bounds, tree *upper_bounds, + tree *strides); +tree a68_multiple_set_lower_bound (tree exp, tree dim, tree bound); +tree a68_multiple_set_upper_bound (tree exp, tree dim, tree bound); +tree a68_multiple_set_stride (tree exp, tree dim, tree stride); +tree a68_row_value (tree type, size_t dim, + tree elements, tree elements_size, + tree *lower_bound, tree *upper_bound); +tree a68_row_value_raw (tree type, tree descriptor, + tree elements, tree elements_size); +tree a68_row_malloc (tree type, int dim, + tree elements, tree elements_size, + tree *lower_bound, tree *upper_bound); +tree a68_multiple_slice (NODE_T *p, tree multiple, bool slicing_name, + int num_indexes, tree *indexes); +tree a68_multiple_copy_elems (MOID_T *to_mode, tree to, tree from); +tree a68_rows_dim (tree exp); +tree a68_rows_value (tree multiple); +tree a68_rows_lower_bound (tree rows, tree dim); +tree a68_rows_upper_bound (tree rows, tree dim); +tree a68_rows_dim_check (NODE_T *p, tree rows, tree dim); +tree a68_multiple_dim_check (NODE_T *p, tree multiple, tree dim); +tree a68_multiple_single_bound_check (NODE_T *p, tree dim, tree multiple, + tree index, bool upper_bound); +tree a68_multiple_bounds_check (NODE_T *p, tree dim, tree multiple, + tree index); +tree a68_multiple_bounds_check_equal (NODE_T *p, tree m1, tree m2); + +/* a68-low-ranges.cc */ + +bool a68_in_global_range (void); +void a68_init_ranges (void); +void a68_push_range (MOID_T *mode); +tree a68_pop_range (void); +tree a68_pop_range_with_finalizer (tree *finalizer); +void a68_push_stmt_list (MOID_T *mode); +tree a68_pop_stmt_list (void); +void a68_push_function_range (tree fndel, tree result_type, + bool top_level = false); +void a68_pop_function_range (tree body); +void a68_push_serial_clause_range (MOID_T *clause_mode, + bool save_restore_stack = false); +tree a68_pop_serial_clause_range (void); +void a68_add_stmt (tree exp); +void a68_add_decl (tree decl); +void a68_add_decl_expr (tree decl_expr); +void a68_add_completer (void); +tree a68_range_context (void); +tree a68_range_names (void); +tree a68_range_stmt_list (void); + +/* a68-low-runtime.cc */ + +enum a68_libcall_fn +{ +#define DEF_A68_RUNTIME(CODE, N, T, P, F) A68_LIBCALL_ ## CODE, +#include "a68-low-runtime.def" +#undef DEF_A68_RUNTIME + A68_LIBCALL_LAST +}; + +tree a68_get_libcall (a68_libcall_fn libcall); +tree a68_build_libcall (a68_libcall_fn libcall, tree type, int nargs, ...); + +/* a68-low-clauses.cc */ + +void a68_begin_serial_clause (LOW_CTX_T *ctx, MOID_T *clause_mode); +tree a68_finish_serial_clause (LOW_CTX_T ctx, MOID_T *clause_mode, tree parent_block); +tree a68_lower_label (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_labeled_unit (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_completer (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_initialiser_series (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_serial_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_loop_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_conformity_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_case_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_enquiry_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_conditional_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_unit_list (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_access_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_collateral_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_parallel_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_closed_clause (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_enclosed_clause (NODE_T *p, LOW_CTX_T ctx); + +/* a68-low-coercions.cc */ + +tree a68_lower_dereferencing (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_rowing (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_widening (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_deproceduring (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_proceduring (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_voiding (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_uniting (NODE_T *p, LOW_CTX_T ctx); + +/* a68-low-decls.cc */ + +tree a68_lower_mode_declaration (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_variable_declaration (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_identity_declaration (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_procedure_declaration (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_procedure_variable_declaration (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_declarer (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_declaration_list (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_priority_declaration (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_brief_operator_declaration (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_operator_declaration (NODE_T *p, LOW_CTX_T ctx); + +/* a68-low.cc */ + +tree a68_lower_top_tree (NODE_T *p); +tree a68_lower_tree (NODE_T *p, LOW_CTX_T ctx); +tree a68_make_identity_declaration_decl (NODE_T *identifier, const char *module_name = NULL, + bool indicant = false, bool external = false, + const char *extern_symbol = NULL); +tree a68_make_variable_declaration_decl (NODE_T *identifier, const char *module_name = NULL, + bool external = false, + const char *extern_symbol = NULL); +tree a68_make_proc_identity_declaration_decl (NODE_T *identifier, const char *module_name = NULL, + bool indicant = false, bool external = false, + const char *extern_symbol = NULL); +tree a68_make_anonymous_routine_decl (MOID_T *mode); +tree a68_get_skip_tree (MOID_T *m); +tree a68_get_empty (void); +void a68_ref_counts (tree exp, MOID_T *m, int *num_refs, int *num_pointers); +tree a68_consolidate_ref (MOID_T *m, tree expr); +tree a68_lower_alloca (tree type, tree size); +tree a68_lower_malloc (tree type, tree size); +tree a68_checked_indirect_ref (NODE_T *p, tree exp, MOID_T *exp_mode); +tree a68_low_deref (tree exp, NODE_T *p); +tree a68_low_dup (tree exp, bool use_heap = false); +tree a68_low_ascription (MOID_T *mode, tree lhs, tree rhs); +tree a68_low_assignation (NODE_T *p, tree lhs, MOID_T *lhs_mode, tree rhs, MOID_T *rhs_mode); +tree a68_lower_memcpy (tree dst, tree src, tree size); +tree a68_lower_tmpvar (const char *name, tree type, tree init); +tree a68_get_mangled_identifier (const char *name, + const char *mname = NULL, bool internal = false, + bool numbered = false); +tree a68_get_mangled_indicant (const char *name, + const char *mname = NULL, bool internal = false, + bool numbered = false); +char *a68_demangle_symbol (const char *mname, const char *symbol, + bool is_operator = false); +tree a68_low_toplevel_func_decl (const char *name, tree fntype); +tree a68_low_func_param (tree fndecl, const char *name, tree type); + +/* a68-low-builtins.cc */ + +void a68_install_builtins (); + +/* a68-low-unions.c */ + +int a68_united_mode_index (MOID_T *p, MOID_T *q); +tree a68_get_union_skip_tree (MOID_T *m); +tree a68_union_overhead (tree exp); +tree a68_union_set_overhead (tree exp, tree overhead); +tree a68_union_cunion (tree exp); +tree a68_union_alternative (tree exp, int index); +tree a68_union_value (MOID_T *mode, tree exp, MOID_T *exp_mode); +tree a68_union_translate_overhead (MOID_T *from, tree from_overhead, MOID_T *to); +bool a68_union_contains_mode (MOID_T *p, MOID_T *q); + +/* a68-low-units.cc */ + +tree a68_lower_identifier (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_denotation (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_denotation (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_skip (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_nihil (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_empty (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_identity_relation (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_logic_function (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_primary (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_cast (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_secondary (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_slice (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_selection (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_formula (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_monadic_formula (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_tertiary (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_assignation (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_routine_text (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_generator (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_call (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_unit (NODE_T *p, LOW_CTX_T ctx); + +/* a68-low-generator.c */ + +tree a68_low_generator (NODE_T *declarer, MOID_T *mode, + bool heap, LOW_CTX_T ctx); +tree a68_low_gen (MOID_T *m, size_t nbuonds, tree *bounds, + bool use_heap); + +/* a68-low-prelude.c */ + +tree a68_lower_unimplemented (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_assert (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_intabs2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_realabs2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_boolabs2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_charabs2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_not2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_and3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_or3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_xor3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_confirm2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_negate2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_sign2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_realsign2 (NODE_T *p, LOW_CTX_T ctx); + +tree a68_lower_plus_int (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_plus_real (NODE_T *p, LOW_CTX_T ctx); + +tree a68_lower_minus_int (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_minus_real (NODE_T *p, LOW_CTX_T ctx); + +tree a68_lower_mult_int (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_mult_real (NODE_T *p, LOW_CTX_T ctx); + +tree a68_lower_multab3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_div3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_divab3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_rdiv3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_over3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_mod3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_int_eq3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_int_ne3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_int_lt3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_int_le3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_int_gt3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_int_ge3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_real_eq3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_real_ne3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_real_lt3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_real_le3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_real_gt3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_real_ge3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_char_eq3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_char_ne3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_char_lt3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_char_le3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_char_gt3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_char_ge3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bool_eq3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bool_ne3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_plusab3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_minusab3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_overab3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_modab3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_upb2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_upb3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_lwb2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_lwb3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_elems2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_elems3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_entier2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_round2 (NODE_T *p, LOW_CTX_T ctx); + +tree a68_lower_pow_int (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_pow_real (NODE_T *p, LOW_CTX_T ctx); + +tree a68_lower_odd2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_eq3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_ne3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_lt3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_le3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_gt3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_ge3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_plus3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_char_plus3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_plusab3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_mult3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_char_mult3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_multab3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_string_plusto3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_repr2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitelem3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bin2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitabs2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitleng2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitshorten2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bit_eq3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bit_ne3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitnot2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitand3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitior3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitxor3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_shl3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_shr3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bit_eq3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bit_ne3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bit_le3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bit_ge3 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_maxint (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_minint (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_maxbits (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_maxreal (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_minreal (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_smallreal (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitswidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longbitswidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longlongbitswidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_shortbitswidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_shortshortbitswidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_intwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longintwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longlongintwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_shortintwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_shortshortintwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_realwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longrealwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longlongrealwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_expwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longexpwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longlongexpwidth (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_pi (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_nullcharacter (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_flip (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_flop (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_errorchar (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_blank (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_eofchar (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_replacementchar (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_intlengths (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_intshorths (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitslengths (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_bitsshorths (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_reallengths (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_realshorths (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_infinity (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_minusinfinity (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_maxabschar (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_sqrt (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_sqrt (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_sqrt (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_tan (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_tan (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_tan (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_sin (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_sin (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_sin (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_cos (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_cos (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_cos (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_acos (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_acos (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_acos (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_asin (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_asin (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_asin (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_atan (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_atan (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_atan (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_ln (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_ln (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_ln (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_log (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_log (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_log (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_exp (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_exp (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_long_long_exp (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_reali (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longreali (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longlongreali (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_inti (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longinti (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longlonginti (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_re2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_im2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_conj2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_shortenint2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_lengint2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_lengreal2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_shortenreal2 (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_random (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longrandom (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_longlongrandom (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_setexitstatus (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixargc (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixargv (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixputchar (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixputs (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfputc (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfputs (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixgetenv (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfconnect (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfopen (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfcreate (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfclose (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfsize (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixlseek (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixseekcur (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixseekend (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixseekset (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixstdinfiledes (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixstdoutfiledes (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixstderrfiledes (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfileodefault (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfileordwr (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfileordonly (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfileowronly (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfileotrunc (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixerrno (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixperror (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixstrerror (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixgetchar (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfgetc (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixgets (NODE_T *p, LOW_CTX_T ctx); +tree a68_lower_posixfgets (NODE_T *p, LOW_CTX_T ctx); + +/* a68-exports.cc */ + +MOIF_T *a68_moif_new (const char *module_name); +void a68_moif_free (MOIF_T *moif); +void a68_do_exports (NODE_T *p); + +/* a68-imports.cc */ + +MOIF_T *a68_open_packet (const char *module); + +/* a68-parser-debug.cc */ + +void a68_dump_parse_tree (NODE_T *p, bool tables = false, bool levels = false); +void a68_dump_modes (MOID_T *m); +void a68_dump_moif (MOIF_T *moif); + +#endif /* ! __A68_H__ */ diff --git a/gcc/algol68/ga68.vw b/gcc/algol68/ga68.vw new file mode 100644 index 00000000000..54511c927fb --- /dev/null +++ b/gcc/algol68/ga68.vw @@ -0,0 +1,1845 @@ +{ ga68.vw - The GNU Algol 68 strict language -*- vw -*- + + Copyright (C) 2025 Jose E. Marchesi + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. } + +{ This file contains an annotated description of the syntax of the GNU + Algol 68 strict language. GNU Algol 68 aims to be a super-language + of Algol 68. + + Extension to the strict Revised Report incorporated into GNU Algol + 68 are: + + [US] This is the GNU68-2025-001-unsafe GNU extension. It adds an + unsafe clause that marks a controlled clause as containing + unsafe constructs which are known by the programmer, and makes + the compiler to avoid certain diagnostics. See the GNU Algol + 68 Compiler manual for more information. + + [SC] This is the GNU68-2025-003-andth-orel GNU extension. It adds + two units that act as pseudo-operators providing logical AND + and OR functions with short-circuited elaboration. See the GNU + Algol 68 Compiler manual for more information. + + [MR] A modules and separated compilation system based on the modules + system recomended by IFIP Working Group 2.1 Standing + Subcommittee on Algol 68 Support, described in: + + A Modules and Separate Compilation Facility for Algol 68 by + Lindsey and Boom. + + [NC] This is the GNU68-2025-005-nestable-comments GNU extension. It + adds support for nestable block comments. + + The metaproduction rules, hyper-rules and hyper-alternatives + introduced by each extension are clearly marked in the sections + below. You can easily search for them using the extensions tags in + the list above. For example, to look for the extensions introduced + by the modules and separated compilation system, search for [MR]. + + The few deviations to the RR Algol 68 are clearly marked as well in + this specification. + + A complete description of the semantics of the Algol 68 subset of + the described language and the extensions is not included in this + file. The reader is referred to the Revised Report and other + documentation corresponding to the extensions, like the GNU Algol 68 + compiler manual. + + The sectioning and the enumeration of metaproduction rules and of + hyper-rules, including cross-references, are the same than in the + Report. The annotations and pragmatics added between curly brackets + explain the meaning of the rules and how they describe the syntax of + the language. Note that thanks to the expressive power of VW + grammars the syntax expressed by this description covers much more + than what is usually expressed by context-free grammars in the + descriptions of other languages that typically use some variant of + the BNF notation. + + Sample code in examples and pragmatics is expressed using the UPPER + stropping regime. + + This file is better browsed using the Emacs vw-mode, which provides + automatic indentation, font-lock, and other facilities like the + hiding of annotations an the following of cross-references. See the + vw-mode manual for more information, including a primer on VW + grammars and the formal description used in both the original Report + and this file. } + +1 Language and metalanguage + +1.2 General metaproduction rules + +1.2.1 Metaproduction rules of modes + +A) MODE :: PLAIN ; STOWED ; REF to MODE ; PROCEDURE ; + UNITED ; MU definition of MODE ; MU application. +B) PLAIN :: INTREAL ; boolean ; character. +C) INTREAL :: SIZETY integral ; SIZETY real. +D) SIZETY :: long LONGSETY ; short SHORTSETY ; EMPTY. +E) LONGSETY :: long LONGSETY ; EMPTY. +F) SHORTSETY :: short SHORTSETY ; EMPTY. +G) EMPTY :: . +H) STOWED :: structured with FIELDS mode ; + FLEXETY ROWS of MODE. +I) FIELDS :: FIELD ; FIELDS FIELD. +J) FIELD :: MODE field TAG{942A}. +K) FLEXETY :: flexible ; EMPTY. +L) ROWS :: row ; ROWS row. +M) REF :: reference ; transient reference. +N) PROCEDURE :: procedure PARAMETY yielding MOID. +O) PARAMETY :: with PARAMETERS ; EMPTY. +P) PARAMETERS :: PARAMETER ; PARAMETERS PARAMETER. +Q) PARAMETER :: MODE parameter. +R) MOID :: MODE ; void. +S) UNITED :: union of MOODS mode. +T) MOODS :: MOOD ; MOODS MOOD. +U) MOOD :: PLAIN ; STOWED ; reference to MODE ; PROCEDURE ; void. +V) MU :: muTALLY. +W) TALLY :: i ; TALLY i. + +1.2.2 Metaproduction rules associated with phrases and coercion + +{ Extensions: + [MR] access + [US] unsafe } + +A) ENCLOSED :: closed ; collateral ; parallel ; CHOICE{34A} ; + loop ; access ; unsafe. +B) SOME :: SORT MOID NEST. +C) SORT :: strong ; firm ; meek ; weak ; soft. + +{ Modules are activated by means of access-clauses. } + +1.2.3 Metaproduction rules associated with nests + +{ Extensions: + [MR] MODSETY, MOD, MODS, REVSETY, REVS, REV, + TAU, INKSETY, INKS, INK } + +A) NEST :: LAYER ; NEST LAYER. +B) LAYER :: new DECSETY LABSETY INKSETY. +C) DECSETY :: DECS ; EMPTY. +D) DECS :: DEC ; DECS DEC. +E) DEC :: MODE TAG{942A} ; priority PRIO TAD{942F} ; + MOID TALLY TAB{942D} ; DUO TAD{942F} MONO TAM{492K} ; + MOD. +F) PRIO :: i ; ii ; iii ; + iii i ; iii ii ; iii iii ; + iii iii i ; iii iii ii ; iii iii iii. +G) MONO :: procedure with PARAMETER yielding MOID. +H) DUO :: procedure with PARAMETER1 PARAMETER2 yielding MOID. +I) LABSETY :: LABS ; EMPTY. +J) LABS :: LAB ; LABS LAB. +K) LAB :: label TAG{942A}. +L) MODSETY :: MODS ; EMPTY. +M) MODS :: MOD ; MODS MOD. +N) MOD :: module REVS TAB. +O) REVSETY :: REVS ; EMPTY. +P) REVS :: REV ; REVS REV. +Q) REV :: TAU reveals DECSETY INKS. +R) TAU :: MU. +S) INKSETY :: INKS ; EMPTY. +T) INKS :: INK ; INKS INK. +U) INK :: invoked TAU. + +{ The primal environment is just 'new'. } + +1.3 General hyper-rules + +1.3.1 Syntax of general predicates + +A) NOTION :: ALPHA ; NOTION ALPHA. +B) ALPHA :: a ; b ; c ; d ; e ; f ; g ; h ; i ; j; + k ; l ; m ; n ; o ; p ; q ; r ; s ; t; + u ; v ; w ; x ; y ; z. +C) NOTETY :: NOTION ; EMPTY. +D) THING :: NOTION ; + (NOTETY1) NOTETY2 ; + THING (NOTETY1) NOTETY2. +E) WHETHER :: where ; unless. + +a) where true : EMPTY. +b) unless false : EMPTY. +c) where THING1 and THING2 : where THING1, where THING2. +d) where THING1 or THING2 : where THING1 ; where THING2. +e) unless THING1 and THING2 : unless THING1; unless THING2. +f) unless THING1 or THING2 : unless THING1, unless THING2. +g) WHETHER (NOTETY1) is (NOTETY2) : + WHETHER (NOTETY1) begins with (NOTETY2){h,i,j} + and (NOTETY2) begins with (NOTETY1){h,i,j}. +h) WHETHER (EMPTY) begins with (NOTION){g,j} : + WHETHER false{b,-}. +i) WHETHER (NOTETY1) begins with (EMPTY){g,j} : + WHETHER true{a,-}. +j) WHETHER (ALPHA1 NOTETY1) begins with + (ALPHA2 NOTETY2){g,j,m} : + WHETHER (ALPHA1) coincides with (ALPHA2) in + (abcdefghijklmnopqrstuvwxyz){k,l,-} + and (NOTETY1) begins with (NOTETY2){h,i,j}. +k) where (ALPHA) coincides with (ALPHA) in (NOTION){j} : + where true{a}. +l) unless (ALPHA1) coincides with (ALPHA2) in (NOTION){j} : + where (NOTION) contains (ALPHA1 NOTETY ALPHA2){m} + or (NOTION) contains (ALPHA2 NOTETY ALPHA1){m}. +m) WHETHER (ALPHA NOTETY) contains (NOTION){l,m} : + WHETHER (ALPHA NOTETY) begins with (NOTION){j} + or (NOTETY) contains (NOTION){m,n}. +n) WHETHER (EMPTY) contains (NOTION){m} : WHETHER false{b,-}. + +1.3.3 Syntax of general constructions + +A) STYLE :: brief ; bold ; style TALLY. + +a) NOTION option : NOTION ; EMPTY. +b) NOTION sequence{b} : NOTION ; NOTION, NOTION sequence{b}. +c) NOTION list{c} : + NOTION ; NOTION, and also{94f} token, NOTION list{c}. +d) NOTETY STYLE pack : + STYLE begin{94f,-} token, NOTETY, STYLE end{94f,-} token. +e) NOTION STYLE bracket : + STYLE sub{94f,-} token, NOTION, STYLE bus{94f,-} token. +f) THING1 or alternatively THING2 : THING1 ; THING2. + +2 The computer and the program + +2.2 The program + +2.2.1 Syntax + +a) program : program token, strong integral new closed clause{31a}. + +{ The value yielded by the elaboration of the program is the exit + status returned by the process to the operating system upon + termination. This is a slight deviation from the Report, which + instead specifies: + + a) program : strong void new closed clause. + + and mandates that the production tree of a particular program should + be akin to the production of the program in the strict language. } + +3 Clauses + +3.0.1 Syntax + +{ Extensions: + [MR] "NEST module text publishing REVS defining LAYER", + "NEST LAYER1 LAYER2 module series with DECSETY + without DECSETY", + "SOID NEST access clause" } + +a) *phrase : SOME unit{32d} ; NEST declaration of DECS{41a}. +b) *SORT MODE expression : SORT MODE NEST UNIT{5A}. +c) *statement : strong void NEST UNIT{5A}. +d) *MOID constant : MOID NEST DEFIED identifier with TAG{48a,b} ; + MOID NEST denoter{80a}. +e) *MODE variable : + reference to MODE NEST DEFIED identifier with TAG{48a,b}. +f) *NEST range : + SOID NEST serial clause defining LAYER{32a} ; + SOID NEST chooser CHOICE STYLE clause{34b} ; + SOID NEST case part of choice using UNITED{34i} ; + NEST STYLE repeating part with DEC{35e} ; + NEST STYLE while do part{35f} ; + PROCEDURE NEST routine text{541a,b} ; + NEST module text publishing REVS defining LAYER{49c,-} ; + NEST LAYER1 LAYER2 module series + with DECSETY without DECSETY1{49d} ; + SOID NEST access clause{36a}. + +{ The rules b and c establish a precise definition of "expressions" + and "statements". The former are units yielding values of a mode + other than VOID in any context. The later are units in a strong + context with a-posteriori mode of VOID, that get voided. } + +{ The rules d and e establish a precise definition of "constants" and + "variables". The former are either a denotation or an identifier of + some mode. The second are identifiers of a "reference to" mode. } + +{ The rule f introduces a paranotion for all the constructs that + introduce new ranges. } + +3.1 Closed clauses + +3.1.1 Syntax + +A) SOID :: SORT MOID. +B) PACK :: STYLE pack. + +a) SOID NEST closed clause{22a,5D,551a,A341h,A349a} : + SOID NEST serial clause defining LAYER{32a} PACK. + +{ Examples: + a) BEGIN x := 1; y := 2 END } + +3.2 Serial clauses + +3.2.1 Syntax + +{ Extensions: + [MR] "establishing clause" } + +a) SOID NEST serial clause defining new PROPSETY{31a,34f,1,35h} : + SOID NEST new PROPSETY series with PROPSETY{b}. +b) SOID NEST series with PROPSETY{a,b,35c} : + strong void NEST unit{d}, go on{94f} token, + SOID NEST series with PROPSETY{b} ; + where (PROPSETY) is (DECS DECSETY LABSETY), + NEST declaration of DECS{41a}, go on{94f} token, + SOID NEST series with DECSETY LABSETY{b} ; + where (PROPSETY) is (LAB LABSETY), + NEST label definition of LAB{c}, + SOID NEST series with LABSETY{b} ; + where (PROPSETY) is (LAB LABSETY) + and SOID balances SOID1 and SOID2{3}, SOID1 NEST unit{d}, + completion{94f} token, NEST label definition of LAB{c}, + SOID2 NEST series with LABSETY{b} ; + where (PROPSETY) is (EMPTY), + SOID NEST unit{d}. +c) NEST label definition of label TAG{b} : + label NEST defining identifier with TAG{48a}, label{94f} token. +d) SOME unit{b,33b,g,34i,35d,46m,n,521c,532e,541a,b,543c,A34Ab,c,d} : + SOME UNIT{5A,-}. +e) WHETHER SORT MOID balances + SORT1 MOID1 an SORT2 MOID2{b,33b,34d,h} : + WHETHER SORT balances SORT1 and SORT2{f} + and MOID balances MOID1 and MOID2{g}. +f) WHETHER SORT balances SORT1 and SORT2{e,522a} : + where (SORT1) is (strong), WHETHER (SORT2) is (SORT) ; + where (SORT2) is (strong), WHETHER (SORT1) is (SORT). +g) WHETHER MOID balances MOID1 and MOID2{3} : + where (MOID1) is (MOID2), WHETHER (MOID) is (MOID1) ; + where (MOID1) is (transient MOID2), + WHETHER (MOID) is (MOID1) ; + where (MOID2) is (transient MOID1), + WHETHER (MOID) is (MOID2). + +h) *SOID unitary clause : SOID NEST unit{d}. +i) *establishing clause : + SOID NEST serial clause defining LAYER{32a} ; + MODE NEST enquiry clause defining LAYER{34c}. + +{ The paranotion establishing-clause encompasses both module-texts and + revelations. } + +{ Examples: + b) read (x1); REAL s:= 0; + sum: FOR i TO n DO (x1[i] > 0 | s :+= x1[i] | nonpos) OD EXIT + nonpos: print (s) + + REAL s := 0; + sum: FOR i TO n DO (x1[i] > 0 | s :+= x1[i] | nonpos) OD EXIT + nonpos: print (s) + + sum: FOR i TO n DO (x1[i] > 0 | s :+= x1[i] | nonpos) OD EXIT + nonpos: print (s) + + FOR i TO n DO (x1[i] > 0 | s :+= x1[i] | nonpos) OD EXIT + nonpos: print (s) + c) sum: + d) print (s) } + +3.3 Collateral and parallel clauses + +3.3.1 Syntax + +a) strong void NEST collateral clause{5D,551a} : + strong void NEST joined portrait{b} PACK. +b) SOID NEST joined portrait{a,b,c,d,34g} : + were SOID balances SOID1 and SOID2{32e}, + SOID1 NEST unit{32d}, and also{94f} token, + SOID2 NEST unit{32d} + or alternatively SOID2 NEST joined portrait{b}. +c) strong void NEST parallel clause{5D,551a} : + parallel{94f} token, strong void NEST joined portrait{b} PACK. +d) strong ROWS of MODE NEST collateral clause{5D,551a} : + where (ROWS) is (row), + strong MODE NEST joined portrait{b} PACK ; + where (ROWS) is (row ROWS1), + strong ROWS1 of MODE NEST joined portrait{b} PACK ; + EMPTY PACK. +e) strong structured with + FIELDS FIELD mode NEST collateral clause{5D,551a} : + NEST FIELDS FIELD portrait{f} PACK. +f) NEST FIELDS FIELD portrait{3,f} : + NEST FIELDS portrait{f,g}, an also{94f} token, + NEST FIELD portrait{g}. +g) NEST MODE field TAG portrait{f} : strong MODE NEST unit{32d}. + +h) *structure display : + strong structured with FIELDS FIELD mode NEST collateral clause{e}. +i) *row display : + strong ROWS of MODE NEST collateral clause{d}. +j) *display : strong STOWED NEST collateral clause{d,e}. +k) *vacuum : EMPTY PACK. + +3.4 Choice clauses + +3.4.1 Syntax + +A) CHOICE :: choice using boolean ; CASE. +B) CASE :: choice using intgral ; choice using UNITED. + +a) SOID NEST1 CHOICE clause{5D,551a,A341h,A349a} : + CHOICE STYLE start{91a,-}, + SOID NEST1 chooser CHOICE STYLE clause{b}, + CHOICE STYLE finish{91e,-}. +b) SOID NEST1 chooser choice using MODE STYLE clause{a,l} : + MODE NEST1 enquiry clause defining LAYER2{c,-}, + SOID NEST1 LAYER2 alternate choice using MODE STYLE clause{d}. +c) MODE NEST1 enquiry clause defining new DECSETY2{b,35g} : + meek MODE NEST1 new DESETY2 series with DECSETY2{32b}. +d) SOID NEST2 alternate CHOICE STYLE clause{b} : + SOID NEST2 in CHOICE STYLE clause{e} ; + where SOID balances SOID1 and SOID2{32e}, + SOID1 NEST2 in CHOICE STYLE clause{3}, + SOID2 NEST2 out CHOICE STYLE clause{l}. +e) SOID NEST2 in CHOICE STYLE clause{d} : + CHOICE STYLE in{91b,-}, SOID NEST2 in part of CHOICE{f,g,h}. +f) SOID NEST2 in part of choice using boolean{e} : + SOID NEST2 serial clause defining LAYER3{32a}. +g) SOID NEST2 in part of choice using integral{e} : + SOID NEST2 joined portrait{33b}. +h) SOID NEST2 in part of choice using UNITED{e,h} : + SOID NEST2 case part of choice using UNITED{i} ; + where SOID balances SOID1 and SOID2{32e}, + SOID1 NEST2 case part of choice using UNITED{i}, + and also{94f} token, + SOID2 NEST2 in part of choice using UNITED{h}. +i) SOID NEST2 case part of choice using UNITED{h} : + MOID NEST2 LAYER3 specification defining LAYER3{jk,-}, + where MOID unites to UNITED{64b}, + SOID NEST2 LAYER3 unit{32d}. +j) MODE NEST3 specification defining new MODE TAG3{i} : + NEST3 declarative defining new MODE TAG3{541e} brief pack, + colon{94f} token. +k) MOID NEST3 specification defining new EMPTY{i} : + formal MOID NEST3 declarer{46b} brief pack, colon{94f} token. +l) SOID NEST2 out CHOICE STYLE clause{d} : + CHOICE STYLE out{91d,-}, + SOID NEST2 serial lause defining LAYER3{32a} ; + CHOICE STYLE again{91c,-}, + SOID NEST2 chooser CHOICE2 STYLE clause{b}, + where CHOICE2 may follow CHOICE{m}. +m) WHETHER choice using MODE2 may follow choice using MODE1{l} : + where (MODE1) is (MOOD), WHETHER (MODE2) is (MODE1) ; + where (MODE1) begins with (union of), + WHETHER (MODE2) begins with (union of). + +n) *SOME choice clause : SOME CHOICE clause{a}. +o) *SOME conditional clause : SOME choice using boolean clause{a}. +p) *SOME case clause : SOME choice using integral clause{a}. +q) *SOME conformity clause : SOME choice using UNITED clause{a}. + +3.5 Loop clauses + +3.5.1 Syntax + +A) FROBYT :: from ; by ; to. + +a) strong void NEST1 loop clause{5D,551a} : + NEST1 STYLE for part defining new integral TAG2{b}, + NEST1 STYLE intervals{c}, + NEST1 STYLE repeating part with integral TAG2{e}. +b) NEST1 STYLE for part defining new integral TAG2{a} : + STYLE for{94g,-} token, + integral NEST1 new integral TAG2 defining identifier + with TAG2{48a} ; + where (TAG2) is (letter aleph), EMPTY. +c) NEST1 STYLE intervals{a} : + NEST1 STYLE from part{d} option, + NEST1 STYLE by part{d} option, + NEST1 STYLE to part{d} option. +d) NEST1 STYLE FROBYT part{c} : + STYLE FROBYT{94g,-} token, meek integral NEST1 unit{32d}. +e) NEST1 STYLE repeating part with DEC2{a} : + NEST1 new DEC2 STYLE while do part{f} ; + NEST1 new DEC2 STYLE do part{h}. +f) NEST2 STYLE while do part{e} : + NEST2 STYLE while part defining LAYER3{g}, + NEST2 LAYER3 STYLE do part{h}. +g) NEST2 STYLE while part defining LAYER3{f} : + STYLE while{94g,-} token, + boolean NEST2 enquiry clause defining LAYER3{34c,-}. +h) NEST3 STYLE do part{3,f} : + STYLE do{94g,-} token, + strong void NEST3 serial clause defining LAYER4{32a}, + STYLE od{94g,-} token. + +3.6 Access clauses + +{ Extensions: + [MR] GMR } + +{ Access clauses contain a controlled-clause, which is an + enclosed-clause. } + +3.6.1 Syntax + +a) SOID NEST access clause{5D,551a,A341h,A349a} : + NEST revelation publishing EMPTY defining LAYER{b}, + SOID NEST LAYER ENCLOSED clause{a,31a,33a,c,d,e,34a,35a,-}. +b) NEST revelation publishing REVSETY + defining new DECSETY INKSETY{a,49c} : + access{94d} token, + NEST joined module call publishing REVSETY revealing REVS{c}, + where DECSETY INKS revealed by REVS{e,f} + and NEST filters INKSETY out of INKS{h}. +c) NEST joined module call publishing REVSETY revealing RES{b,c} : + NEST moule call publishing REVSETY revealing REVS{d,-} ; + where (REVSETY) is (REVSETY1 REVSETY2) + an (REVS) is (REVS1 REVS2), + NEST module call publishing REVSETY1 revealing REVS1{d,-}, + and also{94f} token, + NEST joined module call publishing REVSETY2 revealing REVS2{c}. +d) NEST module call publishing REVSETY revealing REVS{c} : + where (REVSETY) is (EMPTY), + module REVS NEST applied module indication with TAB{48b} ; + where (REVSETY) is (REVS), + public{94d} token, + module REVS NEST applied module indication with TAB{48b}. +e) WHETHER DECSETY1 DECSETY2 INKS1 INKSETY2 revealed by + TAU reveals DECSETY1 INKS1 REVSETY3 + TAU reveals DECSETY1 INKS1 REVSETY4{b,e,f} : + WHETHER DECSETY DECSETY2 INKS1 INKSETY2 revealed by + TAU reveals DECSETY1 INKS1 REVSETY3 REVSETY4{e,f}. +f) WHETHER DECSETY1 DECSETY2 INKS1 INKSETY2 revealed by + TAU reveals DECSETY1 INKS1 REVSETY2{b,e,f} : + WHETHER DECSETY2 INKSETY2 revealed by REVSETY2 + and DECSETY1 independent DECSETY2{71a,b,c}. +g) WHETHER EMPTY revealed by EmPTY{e,f} : WHETHER true. +h) WHETHER NEST filters INKSETY1 out of INKSETY INK{b} : + unless INK ientified in NEST{72a}, + WHETHER (INKSETY) is (INKSETY2 INK) + and NEST INK filers INKSETY2 out of INKSETY{h,i} ; + where INK identified in NEST{72a}, + WHETHER NEST filters INKSETY1 out of INKSETY{h,i}. +i) WHETHER NEST filters EMPTY out of EMPTY{h} : WHETHER true. + +{ Examples: + a) ACCESS A, B (gets (f, a); puts (a)) + b) ACCESS A, B + c) A, B + d) A + PUB B } + +{ In rule b, the 'invoke TAU's enveloped by 'INKS' represent those + modules which might need to be invoked at any module-call whose + applied-module-indication identified a particular + defining-module-indication, whereas those enveloped by 'INKSETY' + represent only those which need invocation in the particular + context, the remainder having already being elaborated, as can be + determined statically from the 'NEST'. The presence of 'INKSETY' in + the nest of all descendent constructs of the access-clause ensures + that all modules now invoked will never be invoked again within + those descendents. } + +{ Rule f ensures the independence of declarations revealed by one + revelation; thus + + MODULE A = DEF PUB REAL x FED, B = DEF PUB REAL x FED; + ACCESS A, B (x) + + is not produced. However, rule e allows a given declaration to be + revealed by two public accesses of the same module, as in + + MODULE A = DEF PUB REAL x FED; + MODULE B = ACCESS PUB A DEF REAL y FED, + C = ACCESS PUB A DEF REAL z FED; + ACCESS B C (x + y + z) + + in which the module-definitions for both B and C reveal x, by virtue + of the PUB A in their constituent revelations. } + +{ Note that a particular-program may now consist of a + joined-label-definition followed by an access-clause. The + defining-module- indications identified thereby would be in the + library-prelude or the user-prelude. } + +3.7 Unsafe clauses + +{ Extensions: [US] } + +{ Unsafe clauses contain a controlled-clause, which is an enclosed-clause. } + +3.7.1 Syntax + +a) SOID NEST unsafe clause : + unsafe{94f} token, SOID NEST ENCLOSED clause{a,31a,33a,c,d,e,34a,35a,-}. + +{ Examples: + a) UNSAFE (ptr := dst) } + +4 Declarations, declarers and indicators + +4.1 Declarations + +4.1.1 Syntax + +{ Extensions: + [MR] module + "declaration with DECSETY without DECSETY1" } + +A) COMMON :: mode ; priority ; MODINE identity ; + reference to MODINE variable ; MODINE operation ; + PARAMETER ; MODE FIELDS ; module. + { MODINE :: MODE ; routine. } + +a) NEST declaration of DECS{a,32b} : + NEST COMMON declaration of DECS{42a,43a,44a,e,45a,-} ; + where (DECS) is (DECS1 DECS2), + NEST COMMON declaration of DECS1{42a,43a,44a,e,45a,-}, + and also{94f} token, NEST declaration of DECS2{a}. +b) NEST COMMON joined definition of PROPS PROP{b,42a,43a,44a,e,45a,46e,541e} : + NEST COMON joined definition of PROPS{b,c}, + and also{94f} token, + NEST COMMON joined definition of PROP{c}. +c) NEST COMMON joined definition of PROP{b,42a,43a,44a,e,45a,46e,541e} : + NEST COMMON definition of PROP{42b,43b,44c,f,45c,46f,541f,-}. + +d) *definition of PROP : + NEST COMMON definition of PROP{42b,43b,44c,f,45c,46f,541f} ; + NEST label definition of PROP{32}. +e) NEST declaration with DECSETY without DECSETY1{49e} : + where (DECSETY without DECSETY1) is (EMPTY without DECS1), + NEST COMMON declaration of DECS1{42a,43a,44a,e,45a,49a,-} ; + where (DECSETY without DECSETY1) is (DECS without EMPTY), + public{94d} token, + NEST COMMON declaration of DECS{42a,43a,44a,e,45a,49a,-} ; + where (DECSETY without DECSETY1) is + (DECSETY without DECS1 DECSETY2), + NEST COMMON declaration of DECS1{42a,43a,44a,e,45a,49a,-}, + and also{94f} token, + NEST declaration with DECSETY without DECSETY2{e} ; + where (DECSETY without DECSETY1) is + (DECS DECSETY3 without DECSETY1), + public{94d} token, + NEST COMMON declaration of DECS{42a,43a,44a,e,45a,49a,-}, + and also{94f} token, + NEST declaration with DECSETY3 without DECSETY1{e}. + +{ Rule e determines how a "NEST declaration with DECSETY without + DECSETY1" results into two groups of declarations. The declarations + in 'DECSETY' are public and syntactically preceded by PUB. The + declarations in 'DECSETY1 are non-public and are not marked by + PUB. } + +4.2 Mode declarations + +4.2.1 Syntax + +a) NEST mode declaration of DECS{41a} : + mode{94d} token, NEST mode joined definition of DECS{41b,c}. +b) NEST mode definition of MOID TALLY TAB{41c} : + where (TAB) is (bold TAG) or (NEST) is (new LAYER), + MOID TALLY NEST defining mode indication with TAB{48a}, + is defined as{94d} token, + actual MOI TALLY NEST declarer{c}. +c) actual MOID TALLY1 NEST declarer{b} : + where (TALLY1) is (i), + actual MOID NEST declarator{46c,d,g,h,o,s,-} ; + where (TALLY1) is (TALLY2 i), + MOID TALLY2 NEST applied mode indication with TAB2{48b}. + +{ The use of TALLY excludes circular chains of mode-definitions such + as `mode a = b, b = a'. } + +4.3 Priority declarations + +4.3.1 Syntax + +a) NEST priority declaration of DECS{41a} : + priority{94d} token, NEST priority joined definition of DECS{41b,c}. +b) NEST priority definition of priority PRIO TAD{41c} : + priority PRIO NEST definining operator with TAD{48a}, + is defined as{94d} token, DIGIT{94b} token, + where DIGIT counts DIGIT{94b} token, + where DIGIT counts PRIO{c,d}. + {DIGIT :: digit zero ; digit one ; digit two ; digit three ; + digit four ; digit five ; digit six ; digit seven ; + digit eight ; digit nine.} +c) WHETHER DIGIT1 counts PRIO i{b,c} : + WHETHER DIGIT2 counts PRIO{c,d}, + where (digit one igit two digit three digit four + digit five digit six digit seven digit eight digit nine) + contains (DIGIT2 DIGIT1). +d) WHETHER digit one counts i{b,c} : WHETHER true. + +4.4 Identifier declarations + +4.4.1 Syntax + +A) MODINE :: MODE ; routine. +B) LEAP :: local ; heap ; primal. + +a) NEST MODINE identity declaration of DECS{41a} : + formal MODINE NEST declarer{b,46b}, + NEST MODINE identity joined definition of DECS{41b,c}. +b) VICTAL routine NEST declarer{a,523b} : procedure{94d} token. +c) NEST MODINE identity definition of MODE TAG{41c} : + MODE NEST defining identifier with TAG{48a}, + is defined as{94d} token, MODE NEST source for MODINE{d}. +d) MODE NEST source for MODINE{c,f,45c} : + where (MODINE) is (MODE), MODE NEST source{521c} ; + where (MODINE) is (routine), MODE NEST routine text{541a,b,-}. +e) NEST reference to MODINE variable declaration of DECS{41a} : + reference to MODINE NEST LEAP sample generator{523b}, + NEST reference to MODINE variable joined definition of DECS{41b,c}. +f) NEST reference to MODINE variable definition + of reference to MODE TAG{41c} : + reference to MODE NEST defining identifier with TAG{48a}, + becomes{94c} token, MODE NEST soure for MODINE{d} ; + where (MODINE) is (MODE), + reference to MODE NEST defining identifier with TAG{48a}. + +g) *identifier declaration : + NEST MODINE identity declaration of DECS{a} ; + NEST reference to MODINE variable declaration of DECS{e}. + +4.5 Operation declarations + +4.5.1 Syntax + +A) PRAM :: DUO ; MONO. +B) TAO :: TAD ; TAM. + +a) NEST MODINE operation delarations of DECS{41a} : + operator{94d} token, formal MODINE NEST plan{b,46p,-}, + NEST MODINE operation joined definition of DECS{41b,c}. +b) formal routine NEST plan{a} : EMPTY. +c) NEST MODINE operation definition of PRAM TAO{41c} : + PRAM NEST defining operator with TAO{48a}, + is defined as{94d} token, PRAM NEST source for MODINE{44d}. + +4.6 Declarers + +4.6.1 Syntax + +A) VICTAL :: VIRACT ; formal. +B) VIRACT :: virtual ; actual. +C) MOIDS :: MOID ; MOIDS MOID. + +a) VIRACT MOID NEST declarer{c,e,g,h,523a,b} : + VIRACT MOID NEST declarator{c,d,g,h,o,s,-} ; + MOID TALLY NEST applied mode indication with TAB{48b,-}. +b) formal MOID NEST declarer{e,h,p,r,u,34k,44a,541a,b,e,551a} : + where MOID deflexes to MOID{47a,b,c,-}, + formal MOID NEST declarator{c,d,h,o,s,-} ; + MOID1 TALLY NEST applied mode indication with TAB{48b,-}, + where MOID1 deflexes to MOID{47a,b,c,-}. +c) VICTAL reference to MODE NEST declarator{a,b,42c} : + reference to{94d} token, virtual MODE NEST declarer{a}. +d) VICTAL structured with FIELDS mode NEST declarator{a,b,42c} : + structure{94d} token, + VICTAL FIELDS NEST portrayer of FIELDS{e} brief pack. +e) VICTAL FIELDS NEST portrayer of FIELDS1{d,e} : + VICTAL MODE NEST declarer{a,b}, + NEST MODE FIELDS joined definition of FIELDS1{41b,c} ; + where (FIELDS1) is (FIELDS2 FIELDS3), + VICTAL MODE NEST declarer{a,b}, + NEST MODE FIELDS joined definition of FIELDS2{41b,c}, + and also{94f} token, + VICTAL FIELDS NEST portrayer of FIELDS3{e}. +f) NEST MODE FIELDS definition of MODE field TAG{41c} : + MODE field FIELDS defining field selector with TAG{48c}. +g) VIRACT flexible ROWS of MODE NEST declarator{a,42c} : + flexible{94d} token, VIRACT ROWS of MODE NEST declarer{a}. +h) VICTAL ROWS of MODE NEST declarator{a,b,42c} : + VICTAL ROWS NEST rower{i,j,k,l} STYLE bracket, + VICTAL MODE NEST declarer{a,b,}. +i) VICTAL row ROWS NEST rower{h,i} : + VICTAL row NEST rower{j,k,l}, and also{94f} token, + VICTAL ROWS NEST rower{i,j,k,l}. +j) actual row NEST rower{h,i} : + NEST lower bound{m}, up to{94f} token, NEST upper bound{n} ; + NEST upper bound{n}. +k) virtual row NEST rower{h,i} : up to{94f} token option. +l) formal row NEST rower{h,i} : up to{94f} token option. +m) NEST lower bound{j,532f,g} : meek integral NEST unit{32d}. +n) NEST upper bound{j,532f} : meek integral NEST unit{32d}. +o) VICTAL PROCEDURE NEST declarator{a,b,42c} : + procedure{94d} token, formal PROCEDURE NEST plan{p}. +p) formal procedure PARAMETY yieling MOID NEST plan{o,45a} : + where (PARAMETY) is (EMPTY), formal MOID NEST declarer{b} ; + PARAMETERS NEST joined declarer{q,r} brief pack, + formal MOID NEST declarer{b}. +q) PARAMETERS PARAMETER NEST joined declarer{p,q} : + PARAMETERS NEST joined declarer{q,r}, and also{94f} token, + PARAMETER NEST joined declarer{r}. +r) MODE parameter NEST joined declarer{p,q} : + formal MODE NEST declarer{b}. +s) VICTAL union of MOODS1 MOOD1 mode NEST declarator{a,b,42c} : + unless EMPTY with MOODS1 MOOD1 incestuous{47f}, + union of{94d} token, + MOIDS NEST joined declarer{t,u} brief pack, + where MOIDS ravels to MOODS2{47g} + and safe MOODS1 MOOD1 subset of safe MOODS2{73l} + and safe MOODS2 subset of safe MOODS1 MOOD1{731,m}. +t) MOIDS MOID NEST joined declarer{s,t} : + MOIDS NEST joined declarer{t,u}, an also{94f} token, + MOID NEST joined declarer{u}. +u) MOID NEST joined declarer{s,t} : formal MOID NEST declarer{b}. + +4.7 Relationships between modes + +4.7.1 Syntax + +A) NONSTOWED :: PLAIN ; REF to MODE ; PROCEDURE ; UNITED ; void. +B) MOODSETY :: MOODS ; EMPTY. +C) MOIDSETY :: MOIDS ; EMPTY. + +a) WHETHER NONSTOWED deflexes to NONSTOWED{b,e,46b,521c,62a,71n} : + WHETHER true. +b) WHETHER FLEXETY ROWS of MODE1 deflexes to ROWS of MODE2{b,e,46b,521c,62a,71n} : + WHETHER MODE1 deflexes to MODE2{a,b,c,-}. +c) WHETHER structured with FIELDS1 mode deflexes to + structured with FIELDS2 mode{b,e,46b,521c,62a,71n} : + WHETHER FIELDS1 deflexes to FIELDS2{d,e,-}. +d) WHETHER FIELDS1 FIELD1 deflexes to FIELDS2 FIELD2{c,d} : + WHETHER FIELDS1 deflexes to FIELDS2{d,e,-} + and FIELD1 deflexes to FIELD2{e,-}. +e) WHETHER MODE1 field TAG deflexes to MODE2 field TAG{c,d} : + WHETHER MODE1 deflexes to MODE2{a,b,c,-}. + +f) WHETHER MOODSETY1 with MOODSETY2 inestuous{f,46s} : + where (MOODSETY2) is (MOOD MOODSETY3), + WHETHER MOODSETY1 MOOD with MOODSETY3 incestuous{f} + or MOOD is firm union of MOODSETY1 MOODSETY3 mode{71m} ; + where (MOODSETY2) is (EMPTY), WHETHER false. + +g) WHETHER MOIDS ravels to MOODS{g,46s} : + where (MOIDS) is (MOODS), WHETHER true ; + where (MOIDS) is + (MOODSETY union of MOODS1 mode MOIDSETY), + WHETHER MOODSETY MOODS1 MOIDSETY ravels to MOODS{g}. + +{ The hyperrules from a) to e) implement a predicate deflexes-to that + determines whether a given mode deflexes to another mode. Any + non-stowed mode deflexes to any other non-stowed mode. A row mode + deflexes to another row mode if the ranks of the modes are the same + and the mode of the former's elements deflexes to the mode of the + later's elements. A structured mode deflexes to another structured + mode if they have the same number of fields with the same tags and + their modes deflex. } + +{ The hyperrule f) implements a predicate that determines whether two + provided sets of moods are incestuous, i.e. whether they contain + modes which are firmly related. } + +{ The hyperrule g) determines whether a set of moods and + united modes may be ravelled. } + +4.8 Indicators and field selectors + +4.8.1 Syntax + +{ Extensions: + [MR] INK, "module indication", "module REVS", "invoked", TAU } + +A) INDICATOR :: identifier ; mode indication ; operator ; + module indication. +B) DEFIED :: defining ; applied. +C) PROPSETY :: PROPS ; EMPTY. +D) PROPS :: PROP ; PROPS PROP. +E) PROP :: DEC ; LAB ; FIELD ; INK. +F) QUALITY :: MODE ; MOID TALLY ; DYADIC ; label ; MODE field ; + module REVS ; invoked. +G) TAX :: TAG ; TAB ; TAD ; TAM ; TAU. + +a) QUALITY NEST new PROPSETY1 QUALITY TAX PROPSETY2 + defining INDICATOR with TAX{32c,35b,42b,43b,44c,f,45c,541f} : + where QUALITY TAX independent PROPSETY1 PROPSETY2{71a,b,c}, + TAX{942A,D,F,K} token. +b) QUALITY NEST applied INDICATOR with TAX{42c,46a,b,5D,542a,b,544a} : + where QUALITY TAX identified in NEST{72a}, + TAX{942A,D,F,K} token. +c) MODE field PROPSETY1 MODE field TAG PROPSETY2 defining + field selector with TAG{46f} : + where MODE field TAG independent PROPSETY1 PrOPSETY2{71a,b,c}, + TAX{942A} token. +d) MODE field FIELDS applied field selector with TAG{531a} : + where MODE field TAG resides in FIELDS{72b,c,-}, + TAG{942A} token. + +e) *QUALITY NEST DEFIED indicator with TAX : + QUALITY NEST DEFIED INDICATOR with TAX{a,b}. +f) *MODE DEFIED field seletor with TAG : + MODE field FIELDS DEFIED field selector with TAG{c,d}. + +{ MODs are introduced into a nest by module-declarations. + INKs are introduced into a nest by module-calls. } + +{ Modules are ascribed to module-indications by means of + module-declarations. } + +4.9 Module declarations + +4.9.1 Syntax + +a) NEST1 module declaration of MODS{41a,e} : + module{94d} token, + NEST1 module joined definition of MODS{41b,c}. +b) NEST1 module definition of module RESETY REV TAB{41c} : + where (REV) is (TAU reveals DECSETY invoked TAU) + and (TAB) is (bold TAG), + where (NEST1) is (NOTION1 invoked TAU NOTETY2), + unless (NOTION1 NOTETY2) contains (invoked TAU), + module REVSETY REV NEST1 defining module indication with TAB{48a}, + is defined as{94d} token, + NEST1 module text publishing REVSETY REV defining LAYER{c,-}. +c) NEST1 module text + publishing REVSETY TAU reveals DECSETY INKSETY INK + defining new DECSETY1 DECSETY INK{b} : + where (INKSETY) is (EMPTY) and (REVSETY) is (EMPTY), + def{94d} token, + NEST1 new new DECSETY1 DECSETY INK module series + with DECSETY without DECSETY1{d}, + fed{94d} token ; + NEST1 revelation publishing REVSETY defining LAYER{36b}, + def{94d} token, + NEST1 LAYER new DECSETY1 DECSETY INK module series + with DECSETY without DECSETY1{d}, + fed{94d} token, + where (LAYER) is (new DECSETY2 INKSETY). +d) NEST3 module series with DECSETY without DECSETY1{c} : + NEST3 module prelude with DECSETY without DECSETY1{e}, + NEST3 module postlude{f} option. +e) NEST3 module prelude with DECSETY1 without DECSETY2{d,e} : + strong void NEST3 unit{32d}, go on{94f} token, + NEST3 module prelude with DECSETY1 without DECSETY2{e} ; + where (DECSETY1 without DECSETY2) is + (DECSETY3 DECSETY4 without DECSETY5 DECSETY6>, + NEST3 declaration with DECSETY3 without DECSETY5{41e}, + go on{94f} token, + NEST3 module prelude with DECSETY4 without DECSETY6{e} ; + where (DECSETY1 without DECSETY2) is (EMPTY without EMPTY), + strong void NEST3 unit{32d} ; + NEST3 declaration with DECSETY1 without DECSETY2{41e}. +f) NEST3 module postlude{d} : + postlude{94d} token, strong void NEST3 series with EMPTY{32b}. + +g) *module text : + NEST module text publishing REVS defining LAYER{c}. + +{ Examples: + a) MODULE A = DEF STRING s; gets (s); + PUB STRING t = "file"+s, PUB REAL a FED, + B = ACCESS A DEF PUB INT fd; + fopen (fd, file o rdonly) + POSTLUDE close (f) FED + + b) A = DEF STRING s; gets (s); + PUB STRING t = "file"+s, PUB REAL a FED + + B = ACCESS A DEF PUB FILE f; + fopen (fd, file o rdonly) + POSTLUDE close (f) FED + + c) DEF STRING s; gets (s); + PUB STRING t = "file"+s, PUB REAL a FED + + ACCESS A DEF PUB FILE f; + fopen (fd, file o rdonly) + POSTLUDE close (f) FED + + d) STRING s; gets (s); PUB STRING t = "file"+s, PUB real a + + PUB FILE f; fopen (fd, file o rdonly) POSTLUDE close (f) + + e) STRING s; gets (s); PUB STRING t = "file"+s, PUB real a + + PUB FILE f; fopen (fd, file o rdonly) + + f) POSTLUDE close (f) } + +{ Note that the EMPTY (for PROPSETY) in rule f enforces that a module + postlude cannot contain declarations, labels or module accesses. + Only units are allowed. } + +{ Rule b ensures that a unique 'TAU' is associated with each + module-text accessible from any given point in the program. This is + used to ensure that an invoke ATU' can be identified in the nest of + all descendent constructs of any access-clause or module-text which + invokes that module-text. + + In general, a module-text-publishing-REVS-defining-LAYER T makes + 'LAYER' visible within itself, and makes the properties revealed by + 'REVS' visible wherever T is accessed. 'LAYER' includes both a + 'DECSETY' corresponding to its public declarations and an INK' which + links T to its unique associated 'TAU' and signifies in the nest + that T is now known to be invoked. REVS' always reveals 'DECSETY + INKSETY INK' (but not 'DECSETY1'), where INKSETY' signifies the + invocation of any other modules accessed by T. 'REVS' may also + reveal the publications of the other modules accessed by T if their + module-calls within T contained a public-token. } + +5 Units + +5.1 Syntax + +{ Extensions: + [MR] formal hole, virtual hole } + +A) UNIT{32d} :: + assignation{521a} coercee ; identity relation{522a} coercee ; + routine text{541a,b} coercee ; jump{544a} ; skip{552a} ; + and function{57a} ; or function{57b} ; + formal hole{561b} ; virtual hole{561a} ; + TERTIARY{B}. +B) TERTIARY{A,521b,522a} :: + ADIC formula{542a,b} coercee ; nihil ; + SECONDARY{C}. +C) SECONDARY{B,531a,542c} :: + LEAP generator{523a} coercee ; selection{531a} coercee ; + PRIMARY{D}. +D) PRIMARY{C,532a,543a} :: + slice{532a} coercee ; call{543a} coercee ; + format text{A341a} coercee ; + applied identifier with TAG{48b} coercee ; + ENCLOSED clause{31a,33a,c,d,e,34a,35a}. + +a) *SOME hip : + SOME jump{544a} : SOME skip{552a} ; SOME nihil{524a}. + +5.2 Units associated with names + +5.2.1 Assignations + +5.2.1.1 Syntax + +a) REF to MODE NEST assignation{5A} : + REF to MODE NEST destination{b}, becomes{94c} token, + MODE NEST source{c}. +b) REF to MODE NEST destination{a} : + soft REF to MODE NEST TERTIARY{5B}. +c) MODE1 NEST source{a,44d} : + strong MODE2 NEST unit{32d}, + where MODE1 deflexes to MODE2{47a,b,c,-}. + +5.2.2 Identity relations + +5.2.2.1 Syntax + +a) boolean NEST identity relation{5A} : + where soft balances SORT1 and SORT2{32f}, + SORT1 reference to MODE NEST TERTIARY1{5B}, + identity relator{b}, + SORT2 reference to MODE NEST TERTIARY2{5B}. +b) identity relator{a} : is{94f} token ; is not{94f} token. + +5.2.3 Generators + +5.2.3.1 Syntax + +a) reference to MODE NEST LEAP generator{5C} : + LEAP{94d,-} token, actual MODE NEST declarer{46a}. +b) reference to MODINE NEST LEAP sample generator{44e} : + LEAP{94d,-} token, actual MODINE NEST declarer{44b,46a} ; + where (LEAP) is (local), actual MODINE NEST declarer{44b,46a}. + +5.2.4 Nihils + +5.2.4.1 Syntax + +a) strong reference to MODE NEST nihil{5B} : + nil{94f} token. + +5.3 Units associated with stowed values + +5.3.1 Selections + +5.3.1.1 Syntax + +A) REFETY :: REF to ; EMPTY. +B) REFLEXETY :: REF to ; REF to flexible ; EMPTY. + +a) REFETY MODE1 NEST selection{5C} : + MODE1 field FIELDS applied field selector with TAG{48d}, + of{94f} token, weak REFLEXETY ROWS of structured with + FIELDS mode NEST SECONDARY{5C}, + where (REFETY) is derived from (REFLEXETY){b,c,-}. +b) WHETHER (transient reference to) is derived from + (REF to flexible){a,532,66a} : + WHETHER true. +c) WHETHER (REFETY) is derived from (REFETY){a,532a,66a} : + WHETHER true. + +5.3.2 Slices + +5.3.2.1 Syntax + +A) ROWSETY :: ROWS ; EMPTY. + +a) REFETY MODE1 NEST slice{5D} : + weak REFLEXETY ROWS1 of MODE1 NEST PRIMARY{5D}, + ROWS1 leaving EMPTY NEST indexer{b,c,-} STYLE bracket, + where (REFETY) is derived from (REFLEXETY){531b,c,-} ; + where (MODE1) is (ROWS2 of MODE2), + weak REFLEXETY ROWS1 of MODE2 NEST PRIMARY{5D}, + ROWS1 leaving ROWS2 NEST indexer{b,d,-} STYLE bracket, + where (REFETY) is derived from (REFLEXETY){531b,c,-}. +b) row ROWS leaving ROWSETY1 ROWSETY2 NEST indexer{a,b} : + row leaing ROWSETY1 NEST indexer{c,d,-}, and also{94f} token, + ROWS leaving ROWSETY2 NEST indexer{b,c,d,-}. +c) row leaving EMPTY NEST indexer{a,b} : NEST subscript{3}. +d) row leaving row NEST indexer{a,b} : + NEST trimmer{f} ; NEST revised lower bound{g} option. +e) NEST subscript{c} : meek integral NEST unit{32d}. +f) NEST trimmer{d} : + NEST lower bound{46m} option, up to{94f} token, + NEST upper bound{46n} option, + NEST revised lower bound{g} option. +g) NEST revised lower bound{d,f} : + at{94f} token, NEST lower bound{46m}. + +h) *trimscript : + NEST subscript{e} ; NEST trimmer{f}; + NEST revised lower bound{g} option. +i) *indexer : + ROWS leaving ROWSETY NEST indexer{b,c,d}. +j) *boundscript : + NEST subscript{e} ; NEST lower bound{46m} ; + NEST upper bound{46n} ; NEST revised lowe bound{g}. + +5.4 Units associated with routines + +5.4.1 Routine texts + +5.4.1.1 Syntax + +a) procedure yielding MOID NEST1 routine text{44d,5A} : + formal MOID NEST1 declarer{46b}, routine{94f} token, + strong MOID NEST1 unit{32d}. +b) procedure with PARAMETERS yielding + MOID NEST1 routine text{44d,5A} : + NEST1 new DECS2 declarative defining + new DECS2{e} brief pack, + where DECS2 like PARAMETERS{c,d,-}, + formal MOID NEST1 declarer{46b}, routine{94f} token, + strong MOID NEST1 new DECS2 unit{32d}. +c) WHETHER DECS DEC like PARAMETERS PARAMETER{b,c} : + WHETHER DECS like PARAMETERS{c,d-} + and DEC like PARAMETER{d,-}. +d) WHETHER MODE TAG like MODE parameters{b,c} : + WHETHER true. +e) NEST2 declarative defining new DECS2{b,e,34j} : + formal MODE NEST2 declarer{46b}, + NEST2 MODE parameter joined definition of DECS2{41b,c} ; + where (DECS2) is (DECS3 DECS4), + formal MODE NEST2 declarer{46b}, + NEST2 MODE parameter joind definition of DECS3{41b,c}, + and also{94f} token, NEST2 declarative defining new DECS4{3}. +f) NEST2 MODE parameter efinition of MODE TAG2{41c} : + MDOE NEST2 defining identifier with TAG2{48a}. + +g) *formal MODE parameter : + NEST MODE parameter definition of MODE TAG{f}. + +5.4.2 Formulas + +5.4.2.1 Syntax + +A) DYADIC :: priority PRIO. +B) MONADIC :: priority iii iii iii i. +C) ADIC :: DYADIC ; MONADIC. +D) TALLETY :: TALLY ; EMPTY. + +a) MOID NEST DYADIC formula{c,5B} : + MODE1 NEST DYADIC TALLETY operand{c,-}, + procedure with MODE1 parameter MODE2 parameter + yielding MOID NEST applied operator with TAD{48b}, + where DYADIC TAD identified in NEST{72a}, + MODE2 NEST DYADIC TALLY operand{c,-}. +b) MOID NEST MONADIC formula{c,5B} : + procedure with MODE parameter yielding MOID + NEST applied operator ith TAM{48b}, + MODE NEST MONADIC operand{c}. +c) MODE NEST ADIC operand{a,b} : + firm MODE NEST ADIC formula{a,b} coercee{61b} ; + where (ADIC) is (MONADIC), firm MODE NEST SECONDARY{5C}. + +d) *MOID formula : MOID NEST ADIC formula{a,b}. +e) *DUO dyadic operator with TAD : + DUO NEST DEFIED operator with TAD{48a,b}. +f) *MONO monadic operator with TAM : + MONO NEST DEFIED operator with TAM{48a,b}. +g) *MODE operand : MODE NEST ADIC operand{c}. + +5.4.3 Calls + +5.4.3.1 Syntax + +a) MOID NEST call{5D} : + meek procedure with PARAMETERS yielding MOID NEST PRIMARY{5D}, + actual NEST PARAMETERS{b,c} brief pack. +b) actual NEST PARAMETERS PARAMETER{a,b} : + actual NEST PARAMETERS{b,c}, and also{94f} token, + actual NEST PARAMETER{c}. +c) actual NEST MODE parameter{a,b} : strong MODE NEST unit{32d}. + +5.4.4 Jumps + +5.4.4.1 Syntax + +a) strong MOID NEST jump{5A} : + go to{b} option, + label NEST applied identifier with TAG{48b}. +b) go to{a} : STYLE go to{94f,-} token ; + STYLE go{94f,-} token, STYLE to symbol{94g,-}. + +5.5 Units associated with values of any mode + +5.5.1 Casts + +5.5.1.1 Syntax + +a) MOID NEST cast{5D} : + formal MOID NEST declarer{46b}, + strong MOID NEST ENCLOSED clause{31a,33c,d,e,34a,35a,-}. + +5.5.2 Skips + +5.5.2.1 Syntax + +a) strong MOID NEST skip{5A} : skip{94f} token. + +5.6 Holes + +5.6.1 Syntax + +A) LANGUAGE :: algol sixty eight ; fortran ; c language ; cpp language. +B) ALGOL68 :: algol sixty eight. +C) FORTRAM :: fortran. +D) CLANG :: c language. +E) CPPLANG :: cpp language. +F) DLANG :: d language. + +a) strong MOID NEST virtual hole{5A} : + virtual nest symbol, strong MOID NEST closed clause{31a}. +b) strong MOID NEST formal hole{5A} : + formal nest{94d} token, MOID LANGUAGE indication{e,f,-}, + hole indication{d}. +c) MOID NEST actual hole{A6a} : + strong MOID NEST ENCLOSED clause{31a,33a,c,34a,35a,36a,-}. +d) hole indication{b} : + character denotation{814a} ; row of character denotation{83a}. +e) MOID ALGOL68 indication{b} : EMPTY. +f) MOID FORTRAN indication{b} : bold letter f letter o letter r letter t + letter r letter a letter n token. +g) MOID CLANG indication{b} : bold letter c letter l letter a letter n + letter g. +e) MOID CPPLANG indication{b} : bold letter c letter p letter p letter l + letter a letter n letter g. +f) MOID DLANG indication{b} : bold letter d letter l letter a letter n + letter g. + +{ Since no representation is provided for the virtual-nest-symbol, the + user is unable to construct virtual-holes for himself, but a + mechanism is provided (10.6.2.a) for constructing them out of + formal- and actual-holes. } + +5.7 Short-circuit logical functions + +{ Extensions: [SC] } + +{ The short-circuit logical functions are pseudo-operators providing + logical AND and OR functions with short-circuited elaboration. } + +5.7.1 Syntax + +a) boolean NEST and function{5A} : + meek boolean NEST TERTIARY1, andth{94c} token, meek boolean NEST TERTIARY2. + +b) boolean NEST or function{5A} : + meek boolean NEST TERTIARY1, orel{94c} token, meek boolean NEST TERTIARY2. + +c) *boolean NEST short circuit function : + boolean NEST and function{a} ; boolean NEST or function{b}. + +{ Examples: + a) UPB str > 2 ANDTH str[3] /= "x" + b) error = 0 OREL (print ("error"); stop; SKIP) } + +6 Coercion + +6.1 Coercees + +6.1.1 Syntax + +A) STRONG{a,66a} :: + FIRM{B} ; widened to{65a,b,c,d} ; rowed to{66a} ; + voided for{67a,b}. +B) FIRM{A,b} :: MEEK{C} ; united to{64a}. +C) MEEK{B,c,d,64a,63a,64a,65a,b,c,d} :: + unchanged from{f} ; dereferenced to{62a} ; deprocedured to{63a}. +D) SOFT{e,63b} :: + unchanged from{f} ; softly deprocedured to{63b}. +E) FORM :: MORF ; COMORF. +F) MORF :: + NEST selection ; NEST slice ; NEST routine text ; + NEST ADIC formula ; NEST call ; + NEST applied identifier with TAG. +G) COMORF :: + NEST assignation ; NEST identity relation ; + NEST LEAP generator ; NEST cast ; NEST denoter ; + NEST format text. + +a) strong MOID FORM coercee{5A,B,C,D,A341i} : + where (FORM) is (MORF), STRONG{A} MOID MORF ; + where (FORM) is (COMORF), STRONG{A} MOID COMORF, + unless (STRONG MOID) is (deprocedured to void). +b) firm MODE FORM coercee{5A,B,C,D,542c} : FIRM{B} MODE FORM. +c) meek MODE FORM coercee{5A,B,C,D} : MEEK{C} MOID FORM. +d) weak REFETY STOWED FORM coercee{5A,B,C,D} : + MEEK{C} REFETY STOWED FORM, + unless (MEEK) is (dereferenced to) + and (REFETY) is (EMPTY). +e) soft MODE FORM coercee{5A,B,C,D} : SOFT{D} MODE FORM. +f) unchanged from MOID FORM{C,D,67a,b} : MOID FORM. + +g) *SORT MOID coercee : SORT MOID FORM coercee{a,b,c,d,e}. +h) *MOID coercend : MOID FORM. + +{ Examples: + a) 3.14 (in x := 3.14) + b) 3.14 (in x + 3.14) + c) sin (in sin (x)) + d) x1 (in x1[2] := 3.14) + e) x (in x := 3.14) } + +6.2 Dereferencing + +6.2.1 Syntax + +a) dereferenced to{61C} MODE1 FORM : + MEEK{61C} REF to MODE2 FORM, + where MODE2 deflexes to MODE1{47a,b,c,-}. + +{ Examples: + a) x in (real (x)) } + +6.3 Deproceduring + +6.3.1 Syntax + +a) deprocedured to{61C,67a} MOID FORM : + MEEK{61C} procedure yielding MOID FORM. +b) softly deprocedured to{61D} MODE FORM : + SOFT{61D} procedure yielding MODE FORM. + +{ Examples: + a) random (in real (random)) + b) x or y (in x or y := 3.14, given + PROC x or y = REF REAL: (random < .5 | x | y)) } + +6.4 Uniting + +6.4.1 Syntax + +a) united to{64B} UNITED FORM : + MEEK{61C} MOID FORM, + where MOID unites to UNITED{b}. +b) WHETHER MOID1 unites to MOID2{a,34i,71m} : + where MOID1 equivalent MOID2{73a}, WHETHER false ; + unless MOID1 equivalent MOID2{73a}, + WHETHER safe MOODS1 subset of safe MOODS2{73l,m,n}, + where (MOODS1) is (MOID1) + or (union of MOODS1 mode) is (MOID1), + where (MOODS2) is (MOIDS2) + or (union of MOODS2 mode) is (MOIDS2). + +{ Examples: + a) x (in uir := x) + u (in UNION(CHAR,INT,VOID)(u), in a reach containing + UNION(INt,VOID) u := EMPTY) } + +6.5 Widening + +6.5.1 Syntax + +A) BITS :: structured with + row of boolean field SITHETY letter aleph mode. +B) BYTES :: structured with + row of character field SITHETY letter aleph mode. +C) SITHETY :: LENGTH LENGTHETY ; SHORT SHORTHETY ; EMPTY. +D) LENGTH :: letter l letter o letter n letter g. +E) SHORT :: letter s letter h letter o letter r letter t. +F) LENGTHETY :: LENGTH LENGTHETY ; EMPTY. +G) SHORTHETY :: SHORT SHORTHETY ; EMPTY. + +a) widened to{b,61A} SIZETY real FORM : + MEEK{61C} SIZETY integral FORM. +b) widened to{61A} structured with SIZETY real field letter r letter e + SIZETY real field letter i letter m mode FORM : + MEEK{61C} SIZETY real FORM ; + widened to{a} SIZETY real FORM. +c) widened to{61A} row of boolean FORM : MEEK{61C} BIT FORM. +d) widened to{61A} row of character FORM : MEEK{61C} BYTES FORM. + +{ Examples: + a) 1 (in x := 1) + b) 1.0 (in z := 1.0) + 1 (in z := 1) + c) 2r101 (in []BOOL(2r101)) + d) r (in []CHAR(r)) } + +6.6 Rowing + +6.6.1 Syntax + +a) rowed to{61A} REFETY ROWS1 of MODE FORM : + where (ROWS1) is (row), + STRONG{61A} REFLEXETY MODE FORM, + where (REFETY) is derived from (REFLEXETY){531b,c,-} ; + where (ROWS1) is (row ROWS2), + STRONG{61A} REFLEXETY ROWS2 of MODE FORM, + where (REFETY) is derived from (REFLEXETY){531b,c,-}. + +{ Examples: + a) 4.13 (in [1:1]REAL b1 := 4.13) + x1 (in [1:1,1:n]REAL b2 := x1) } + +6.7 Voiding + +6.7.1 Syntax + +A) NONPROC :: PLAIN ; STOWED ; REF to NONPROC ; + procedure with PARAMETERS yielding MOID ; UNITED. + +a) voided to{61A} void MORF : + deprocedured to{63a} NONPROC MORF ; + unchanged from{61f} NONPROC MORF. +b) voided to{61A} void COMORF : + unchanged from{61f} MODE COMORF. + +{ Examples: + a) random (in SKIP; random;) + next random (last random) + (in SKIP; next random (lat random);) + b) PROC VOID (pp) (in PROC PROC VOID pp = PROC VOID : (print (1); + VOID : print (2)); PROC VOID (pp);) } + +8 Denotations + +8.1 Plain denotations + +8.1.0.1 Syntax + +A) SIZE:: long ; short. +B) *NUMERAL :: fixed point numeral ; variable point numeral ; + floating point numeral. + +a) SIZE INTREAL denotation{a,80a} : + SIZE symbol{94d}, INTREAL, denotation{a,811a,812a}. + +b) *plain denotation : + PLAIN denotation{a,811a,812a,813a,814a} ; void denotation{815a}. + +{ Example: + a) LONG 0 } + +8.1.1 Integral denotations + +8.1.1.1 Syntax + +a) integral denotation{80a,810a} : fixed point numeral{b}. +b) fixed point numeral{a,812c,d,f,i,A341h} : digit cypher{c} sequence. +c) digit cypher{b} : DIGIT symbol{94b}. + +{ Examples: + a) 4096 + b) 4096 + c) 4 } + +8.1.2 Real denotations + +8.1.2.1 Syntax + +a) real denotation{80a,810a} : + variable point numeral{b} ; floating point numeral{e}. +b) variable point numeral{a,f} : + integral part{c} option, fractional part{d}. +c) integral part{b} : fixed point numeral{811b}. +d) fractional part{b} : point symbol{94b}, fixed point numeral{811b}. +e) floating point numeral{a} : stagnant part{f}, exponent part{g}. +f) stagnant part{e} : + fixed point numeral{811b} : variable point numeral{b}. +g) exponent part{e} : + times ten to the power choice{h}, power of then{i}. +h) times ten to the power choice{g} : + times ten to the power symbol{94b} ; letter e symbol{94a}. +i) power of ten{g}: plusminus{j} option, fixed point numeral{811b}. +j) plusminus{i} : plus symbol{94c} ; mius symbol{94c}. + +{ Examples: + a) 0.00123 + 1.23e-3 + b) 0.00123 + c) 0 + d) .00123 + e) 1.23e-3 + f) 123 + 1.23 + g) E-3 + h) E + i) -3 + j) + + - } + +8.1.3 Boolean denotations + +8.1.3.1 Syntax + +a) boolean denotation{80a} : true{94b} symbol ; false{94b} smbol. + +{ Examples: + a) TRUE + FALSE } + +8.1.4 Character denotations + +8.1.4.1 Syntax + +a) character denotation{80a} : + quote{94b} symbol, string item{b}, quote sybol{94b}. +b) string item{a,83b} : + character glyph{c} ; quote image symbol{94f} ; other string item{d}. +c) character glyph{b,92c} : + LETTER symbol{94a} ; DIGIT symbol{94b} ; + point sybol{94b} ; open symbol{94f} ; close symbol{94f} ; + comma symbol{94b} ; space symbol{94b} ; + plus symbol{94c} ; minus symbol{94c}. + +{ A production rule may be added for the notion 'other string item' + each of whose alternatives is a symbol 1.1.3.1.f which is different + from any terminal production of 'character glyph' and which is not + 'quote symbol' } + +{ Examples: + a) "a" + b) a + "" + ? + c) a 1 . ( ) , . space + - } + +8.1.5 Void denotation + +5.1.5.1 Syntax + +a) void denotation{80a} : empty{94b} symbol. + +{ Example: + a) EMPTY } + +8.2 Bits denotations + +8.2.1 Syntax + +A) RADIX :: radix two ; radix four ; radix eight ; radix sixteen. + +a) structured with row of boolean field + LENGTH LENGTHETY letter aleph mode denotation{a,80a} : + long{94d} symbol, structured with row of boolean field + LENGTHETY letter aleph mode denotation{a,c}. +b) structured with row of boolean field + SHORT SHORTHTETY letter aleph mode denotation{b,80a} : + short{94d} symbol, + structured with row of boolean field SHORTHETY letter aleph mode denotation{b,c}. +c) structured wih row of boolean field + letter aleph mode denotation{a,b,80a} : + RADIX{d,e,f,g}, letter r symbol{94a}, RADIX digit{h,i,j,k} sequence. +d) radix two{c,A347b} : digit two{94b} symbol. +e) radix four{c,A347b} : digit four{94b} symbol. +f) radix eight{c,A347b} : digit eight{94b} symbol. +g) radix sixteen{c,A347b} : digit one symbol{94b}, digit six symbol{94b}. +h) radix two digit{c,i} : digit zero symbol{94b} ; digit one symbol{94b}. +i) radix four digit{c,j} : + radix two digit{h} ; digit two symbol{94b} ; + digit three symbol{94b}. +j) raidx eight digit{c,k} : + radix four digit{i} ; digit four symbol{94b} ; + digit five symbol{94b} ; digit six symbol{94b} ; + digit seven symbol{94b}. +k) radix sixteen digit{c} : + radix eight digit{j} ; digit eight symbol{94b} ; + digit nine symbol{94b} ; letter a symbol{94a} ; + letter b symbol{94a} ; letter e symbol{94a} ; letter d symbol{94a} ; + letter e symbol{94a} ; letter f symbol{94a}. + +l) *bits denotation : BITS denotation{a,b,c}. +m) *radix digit : RADIX digit{h,i,j,k}. + +{ Examples: + a) LONG 2r101 + b) SHORT 16rffff + c) 8r231 } + +8.3 String denotations + +8.3.1 Syntax + +a) row of character denotation{80a} : + quote{94b} symbol, string{b} option, quote symbol{94b}. +b) string{a} : string item{814b}, string item{814b} sequence. + +c) *string denotation : row of charater denotation{a}. + +{ Examples: + a) "abc" + b) abc } + +9 Tokens and symbols + +9.1 Tokens + +{ Tokens are symbols possibly preceded by pragments. } + +9.1.1 Syntax + +a) CHOICE STYLE start{34a} : + where (CHOICE) is (choice using boolean), + STYLE if{94f,-} token ; + where (CHOICE) is (CASE), STYLE case{94f,-} token. +b) CHOICE STYLE in{34e} : + where (CHOICE) is (choice using boolean), + STYLE then{94f,-} token ; + where (CHOICE) is (CASE), STYLE in{94f,-} token. +c) CHOICE STYLE again{34l} : + where (CHOICE) is (choice using boolean), + STYLE else if{94f,-} token ; + where (CHOICE) is (CASE), STYLE ouse{94f,-} token. +d) CHOICE STYLE out{34l} : + where (CHOICE) is (choice using boolean), + STYLE else{94f,-} token ; + where (CHOICE) is (CASE), STYLE out{94f,-} token. +e) CHOICE STYLE finish{34a} : + whre (CHOICE) is (choice using boolean), + STYLE fi{94f,-} token ; + where (CHOICE) is (CASE), STYLE esac{94f,-} token. +f) NOTION token : + pragment{92a} sequence option, + NOTION symbol{94a,b,c,d,e,f,g,h}. + +g) *token : NOTION token{f}. +h) *symbol : NOTION symbol{94a,b,c,d,e,f,g,h}. + +9.2 Comments and pragmats + +9.2.1 Syntax + +{ Extensions: + [NC] nestable comments. } + +A) PRAGMENT :: pragmat ; comment. + +a) pragment{80a,91f,A341b,h,A348a,b,c,A349a,A34Ab} : PRAGMENT{b}. +b) PRAGMENT{a} : + STYLE PRAGMENT symbol{94h,-}, + STYLE PRAGMENT item{c} sequence option, + STYLE PRAGMENT symbol{94h,-} ; + STYLE nestable comment{d}. +c) STYLE PRAGMENT item{b} : + character glyph{814c} ; STYLE other PRAGMENT item{d}. +d) STYLE nestable comment{b} : + STYLE comment begin symbol{94h,-}, + STYLE nestable comment contents{e} sequence, + STYLE comment end symbol{94h,-}. +e) STYLE nestable comment contents{d} : + STYLE nestable comment item{c} sequence option, + STYLE nestable comment{d} option. +f) STYLE nestable comment item{e} : + character glyph{814c} ; STYLE other nestable comment item{d}. + +{ A production rule may be added for each notion designated by 'STYLE + other PRAGMENT item' each of whose alternatives is a symbol + different from any terminal production of 'character glyph', and + such that no terminal production of any 'STYLE other PRAGMENT item' + is the corresponding 'STYLE PRAGMENT symbol'. This allows to nest + different comment or pragmat for example. } + +9.4 The reference language + +9.4.1 Representations of symbols + +{ Extensions: + [CS] andth symbol, orel symbol + [MR] access symbol, module symbol, def symbol, public symbol, + postlude symbol, formal nest symbol, egg symbol + [US] unsafe symbol } + +{ This section of the Report doesn't describe syntax, but lists all + the different symbols along with their representation in the + reference language. We only include here symbols corresponding to + the GNU extensions implemented by this compiler. } + + symbol representation + +c) andth symbol{57a} ANDTH + orel symbol{57b} OREL +d) module symbol{49a} MODULE + access symbol{36b} ACCESS + def symbol{49c} DEF + fed symbol{49c} FED + public symbol{36d,41e} PUB + postlude symbol{49f} POSTLUDE + formal nest symbol{56b} NEST + egg symbol{A6a,c} EGG +f) unsafe symbol{37a} UNSAFE +h) bold comment begin symbol{92a} NOTE + bold comment end symbol{92a} ETON + brief comment begin symbol{92a} { + brief comment end symbol{92a} } + +10.1.1 Syntax + +{ Extensions: + [MR] user, user task } + +A) EXTERNAL :: user. + +f) NEST1 user task{d} : + NEST2 particular prelude with DECS{c}, + NEST2 user prelude with MODSETY{c}, + NEST2 particular program{g} PACK, go on{94f} token, + NEST2 particualr poslude{i}, + where (NEST2) is (NEST1 new DECS MODSETY STOP). + +10.6 Packets + +10.6.1 Syntax + +a) MOID NEST new MODSETY ALGOL68 stuffing packet{A7a} : + egg{94d} token, hole indication{56d}, is defined as{94d} token, + MOID NEST new MODSETY actual hole{56c}. + +{ b) Note that the rules for "MOID NEST new MODSETY LANGUAGE stuffing + packets" for other languages are not explicitly included in the + syntax. These rules conceptually transform all such + LANGUAGE-stuffing-packets into ALGOL68-stuffing-packets with the + same meaning. } + +c) NEST new MODSETY1 MODS definition module packet of MODS{A7a} : + egg{94d} token, hole indication{56d}, is defined as{94d} token, + NEST new MODSETY1 MODS module declaration of MODS{49a}, + where MODS absent from NEST{e}. +d) new LAYER1 new DECS MODSETY1 MODS STOP + prelude packet of MODS{A7a} : + new LAYER1 new DECS MODSETY1 MODS STOP + module declaration of MODS{4a}, + where MODS absent from new LAYER1{e}. +e) WHETHER MODSETY MOD absent from NEST{c,d} : + WHETEHR MODSETY absent from NEST{e,f} + and MOD independent PROPSETY{71a,b,c}, + where PROPSETY collected properties from NEST{g,h}. +f) WHETHER EMPTY absent from NEST{e} : + WHETHER true. +g) WHETHER PROPSETY1 PROPSETY2 collected properties from + NEST new PROPSETY2{e,g} : + WHETHER PROPSETY1 collected properties from NEST {g,h}. +h) WHETHER EMPTY collected properties from new EMPTY{e,g} : + WHETHER true. + +i) *NEST new PROPSETY packet : + MOID NEST new PROPSETY LANGUAGE stuffing packet{a,b} ; + NEST new PROPSETY definition module packet of MODS{c} ; + NEST new PROPSETY particular program{A1g} ; + NEST new PROPSETY prelude packet of MODS{d}. +j) *letter symbol : LETTER symbol{94a}. +k) *digit symbol : DIGIT symbol{94b}. + +{ Examples: + + a) EGG "abc" = ACCESS A,B (x := 1; y := 2; print (x+y)) + c) EGG "abc" = MODULE A = DEF PUB REAL x FED + d) MODULE B = DEF PUB REAL y FED + + The thre examples above would form a compatible collection of + packets when taken in conjunction with the particular-program BEGIN + NEST "abc" END } + +{ In rule a above, 'MODSETY' envelops the 'MOD's defined by al the + definition-module-packets that are being stuffed along with the + stuffing-packet. + + In rules c and d, 'MODSETY1' need only envelop the 'MOD's for those + modules actually accessed from within that packet. + + The semantics related to packets are only defined if, for a + collection of packets being stuffed together, all the 'MOD's + enveloped by the various 'MODSETY1's are enveloped by 'MODSETY'. } + +{ A stuffing packet contains the definition of an actual-hole. For + Algol 68 this consists on an enclosed-clause. For other values of + the metanotion 'LANGUAGE' it is different, and it is expected to be + translated somehow to an equivalent Algol 68 definition, + conceptually naturally. + + A definition module packet contains the definition of an actual-hole + which consists in one or more joined module declarations, with the + restriction that none of the declared modules shall exist in the + static environment at the formal-hole. + + A prelude packet contains one or more joined module declarations. } + +10.7 Compilation systems + +{ An implementtion of Algol 68 in which packets of a collection are + compiled into a collection of object-modules should conform to the + provisions of this section. } + +10.7.1 Syntax + +{ Note that we use the notion "compilation unit" rather than the + original "compilation input" used in the IFIP modules definition. } + +A) *LAYERS :: LAYER ; LAYERS LAYER. + +a) compilation unit : + MOID NEST new MODSETY LANGUAGE stuffing packet{A6a,b}, + MOID NEST hole interface{d}, + joined module interface with MODSETY{b,c} ; + NEST new MODSETY1 MODS definition module packet of MODS{A6c}, + MOID NEST hole interface{d}, + joined module interface with MODSETY1{b,c}, + module interface with MODS{d} option ; + new LAYER1 new DECS MODSETY STOP particular program{A1g}, + { void new LAYER1 new DECS STOP hole interface,} + unless (DECS) contains (MODULE), + joined module interface with MODSETY{b,c} ; + new LAYER1 new DECS MODSETY1 MODS STOP + prelude packet of MODS{A6d}, + { void new LAYER1 new DECS STOP hole interface,} + unless (DECS) contains (module), + joined module interface with MODSETY1{b,c}, + module interface with MODS{d} option. +b) joined module interface with MODS MODSETY{a,b} : + module interface with MODS{d}, + joined module interface with MODSETY{b,c}. +c) joined module inteface with EMPTY{a,b} : EMPTY. + +{ A compilation-unit is either a stuffing packet, a definition module + packet, a particular program, or a prelude packet. The packets + shall be accompanied by the required hole and module interface + information. } + +{ d) Hyper-rules for "MOID NEST hole interface", "module interface + with MODS" and "MOID NEST object module". The terminal + productions will most likely be in some cryptic notation + understood only by the compiler, i.e. the interface data. } + +{ The inclusion of the hypernotions "void new LAYER1 new DECS STOP + hole interface" within pragmatic remarks in rule a is intended to + signify that this information (which describes the standard + environment) must clearly be available to the compiler, but that it + may well not be provided in the form of an explicit + hole-interface. } -- 2.47.3