[COMMITTED] algol68: enable bold taggles only if -std=gnu68

Jose E. Marchesi jemarch@gnu.org
Sat Apr 19 18:55:52 GMT 2025


---
 gcc/algol68/a68-lang.cc                       |  2 +-
 gcc/algol68/a68-parser-scanner.cc             |  8 +-
 gcc/algol68/ga68.texi                         | 86 +++++++++++++++++++
 .../algol68/compile/bold-taggle-1.a68         |  5 ++
 .../algol68/compile/error-bold-taggle-1.a68   |  5 ++
 5 files changed, 103 insertions(+), 3 deletions(-)
 create mode 100644 gcc/testsuite/algol68/compile/bold-taggle-1.a68
 create mode 100644 gcc/testsuite/algol68/compile/error-bold-taggle-1.a68

diff --git a/gcc/algol68/a68-lang.cc b/gcc/algol68/a68-lang.cc
index c7819684a60..436e5915a3d 100644
--- a/gcc/algol68/a68-lang.cc
+++ b/gcc/algol68/a68-lang.cc
@@ -521,7 +521,7 @@ a68_init_options_struct (struct gcc_options *opts)
   /* Enable run-time bounds checking by default.  */
   OPTION_BOUNDS_CHECKING (&A68_JOB) = 1;
   opts->x_flag_a68_assert = 1;
-  /* Allow GNU extensions by dfault.  */
+  /* Allow GNU extensions by default.  */
   OPTION_STRICT (&A68_JOB) = 0;
 }
 
diff --git a/gcc/algol68/a68-parser-scanner.cc b/gcc/algol68/a68-parser-scanner.cc
index be75069e09b..7cffaba6027 100644
--- a/gcc/algol68/a68-parser-scanner.cc
+++ b/gcc/algol68/a68-parser-scanner.cc
@@ -1357,22 +1357,26 @@ get_next_token (bool in_format,
 
   if (ISUPPER (c))
     {
+      /* Bold taggles are enabled only in gnu68.  */
+      bool allow_under = !OPTION_STRICT (&A68_JOB);
+
       /* Upper case word - bold tag.  */
       while (ISUPPER (c))
 	{
 	  (sym++)[0] = c;
-	  c = next_char (ref_l, ref_s, false, true);
+	  c = next_char (ref_l, ref_s, false, allow_under);
 	}
       sym[0] = '\0';
       *att = BOLD_TAG;
     }
   else if (ISLOWER (c))
     {
+
       /* Lower case word - identifier.  */
       while (ISLOWER (c) || ISDIGIT (c))
 	{
 	  (sym++)[0] = c;
-	  c = next_char (ref_l, ref_s, true, true);
+	  c = next_char (ref_l, ref_s, true, true /* allow_under */);
 	}
 
       sym[0] = '\0';
diff --git a/gcc/algol68/ga68.texi b/gcc/algol68/ga68.texi
index d9920142481..4e74fe89633 100644
--- a/gcc/algol68/ga68.texi
+++ b/gcc/algol68/ga68.texi
@@ -2601,6 +2601,11 @@ enabled by default.  To disable them the user can select the strict
 Algol 68 standard by passing the option @option{-std=algol68} when
 invoking the compiler.
 
+@menu
+* @code{@B{bin}} and @code{@B{abs}} of negative integral values::
+* Bold taggles::              Using underscores in mode and operator indications.
+@end menu
+
 @node @code{@B{bin}} and @code{@B{abs}} of negative integral values
 @section @code{@B{bin}} and @code{@B{abs}} of negative integral values
 
@@ -2654,6 +2659,87 @@ pattern of the value rather than zero.  Therefore, @code{@B{bin} -
 @B{short} @B{short} 2} yields @code{2r11111110}.  And @code{@B{abs}
 @B{short} @B{short} 2r11111110} yields -2.
 
+@node Bold taggles
+@section Bold taggles
+
+The Algol 68 language establishes that mode indications and operator
+indications consist in a sequence of @dfn{bold letters} and @dfn{bold
+digits}.  In contrast, other constructs like identifiers, field
+selectors and labels are composed of regular or non-bold letters and
+digits.
+
+What is precisely a bold letter or digit, and how it differs from a
+non-bold letter or digit, is not specified by the Report.  This is no
+negligence, but a conscious attempt at abstracting the definition of
+the so-called @dfn{strict language} from its representation.  This
+allows different representations of the same language.
+
+Some representations of Algol 68 are intended to be published in
+books, be it paper or electronic devices, and be consumed by persons.
+These are called @dfn{publication} reference languages.  In
+publication reference languages bold letters and digits are typically
+represented by actual bold alphanumeric typographic marks, or
+sometimes underlined alphanumeric marks.
+
+Other representations of Algol 68 are intended to be automatically
+processed by a computer.  These representations are called
+@dfn{hardware} reference languages.  Typically hardware languages are
+also intended to be written by programmers and processed by other
+programs; these are programming representation languages.
+@xref{Hardware representation}.
+
+Unfortunately, computer systems today usually do not provide readily
+usable bold or underline alphanumeric marks, despite the existence of
+Unicode and modern and sophisticated editing environments.  Thus, the
+hardware representation languages of Algol 68 should resort to a
+technique known as @dfn{stropping} in order to differentiate bold
+letters and digits from non-bold letters and digits.
+
+This compiler supports the stropping regime known as UPPER.  In the
+standard UPPER stropping regime described in the Standard Hardware
+Representation, bold letters are denoted by upper-cased letters and
+bold digits are denoted by immediately following an upper-cased letter
+or another bold digit.  This compiler, however, does not support
+denoting bold digits.
+
+When a bold indication comprises several natural words, it may be a
+little difficult to distinguish them at first sight.  Consider for
+example the following code:
+
+@example
+MODE TREENODE = STRUCT (TREENODEPAYLOAD data, REF TREENODE next),
+     TREENODEPAYLOAD = STRUCT (INT code, REAL average, REAL mean);
+@end example
+
+@noindent
+The mode indications @code{TREENODE} and @code{TREENODEPAYLOAD} can
+indeed be difficult to read.
+
+In order to improve this, this compiler implements a GNU extension
+called @dfn{bold taggles} that allows to use underscore characters
+(@code{_}) within mode and operator indications as a visual aid to
+improve readability.  When this extension is enabled, mode indications
+and operator indications consist in a sequence of the so-called
+@dfn{bold taggles}, which are themselves sequences of one or more bold
+letters or digits optionally terminated by an underscore character.
+
+With bold taggles enabled the program above could have been written as:
+
+@example
+MODE TREE_NODE = STRUCT (TREE_NODE_PAYLOAD data, REF TREE_NODE next),
+     TREE_NODE_PAYLOAD = STRUCT (INT code, REAL average, REAL mean);
+@end example
+
+@noindent
+Which is perhaps more readable for most people.  Note that the
+underscore characters are not really part of the mode or operator
+indication.  Both @code{TREE_NODE} and @code{TREENODE} denote the same
+mode indication.  Note also that, following the definition, constructs
+like @code{FOO__BAR} and @code{_BAZ} are not valid indications.
+
+Bold taggles are automatically enabled when the compiler compiles
+gnu68 programs.  @xref{Dialect options}.
+
 @include gpl_v3.texi
 @include fdl.texi
 
diff --git a/gcc/testsuite/algol68/compile/bold-taggle-1.a68 b/gcc/testsuite/algol68/compile/bold-taggle-1.a68
new file mode 100644
index 00000000000..9afe3a34076
--- /dev/null
+++ b/gcc/testsuite/algol68/compile/bold-taggle-1.a68
@@ -0,0 +1,5 @@
+# { dg-options {-std=gnu68} }  #
+BEGIN MODE FOO_BAR = INT;
+      FOO_BAR foo_bar = 10;
+      SKIP
+END
diff --git a/gcc/testsuite/algol68/compile/error-bold-taggle-1.a68 b/gcc/testsuite/algol68/compile/error-bold-taggle-1.a68
new file mode 100644
index 00000000000..6520d1e0f35
--- /dev/null
+++ b/gcc/testsuite/algol68/compile/error-bold-taggle-1.a68
@@ -0,0 +1,5 @@
+# { dg-options {-std=algol68} }  #
+BEGIN MODE FOO_BAR = INT; # { dg-error "unworthy" }  #
+      FOO_BAR foo_bar = 10;
+      SKIP
+END
-- 
2.30.2



More information about the Algol68 mailing list