[COMMITTED] algol68: allow labels before particular-program and add particular postlude
Jose E. Marchesi
jemarch@gnu.org
Fri Mar 28 12:09:09 GMT 2025
---
gcc/algol68/a68-parser-bottom-up.cc | 11 +++
gcc/algol68/a68-parser-scanner.cc | 5 +
gcc/algol68/ga68.texi | 92 +++++++++++++++----
gcc/testsuite/algol68/README.mcts | 14 ---
gcc/testsuite/algol68/compile/snobol.a68 | 3 +-
gcc/testsuite/algol68/execute/declarer-1.a68 | 3 +-
gcc/testsuite/algol68/execute/goto-5.a68 | 3 +-
gcc/testsuite/algol68/execute/json-1.a68 | 4 +-
gcc/testsuite/algol68/execute/mcts/clau08.a68 | 3 +-
gcc/testsuite/algol68/execute/mcts/coer08.a68 | 3 +-
gcc/testsuite/algol68/execute/mcts/coer09.a68 | 3 +-
gcc/testsuite/algol68/execute/mcts/idef12.a68 | 4 +-
gcc/testsuite/algol68/execute/mcts/null03.a68 | 3 +-
gcc/testsuite/algol68/execute/mcts/null06.a68 | 3 +-
gcc/testsuite/algol68/execute/mcts/oper05.a68 | 4 +-
gcc/testsuite/algol68/execute/mcts/simp02.a68 | 1 +
gcc/testsuite/algol68/execute/mcts/simp04.a68 | 2 +
gcc/testsuite/algol68/execute/undefined-1.a68 | 3 +-
18 files changed, 107 insertions(+), 57 deletions(-)
diff --git a/gcc/algol68/a68-parser-bottom-up.cc b/gcc/algol68/a68-parser-bottom-up.cc
index f0042af1810..95cf9b36df9 100644
--- a/gcc/algol68/a68-parser-bottom-up.cc
+++ b/gcc/algol68/a68-parser-bottom-up.cc
@@ -253,11 +253,21 @@ a68_bottom_up_parser (NODE_T *p)
int error_count_0 = ERROR_COUNT (&A68_JOB);
ignore_superfluous_semicolons (p);
+ /* A program is "label sequence; particular program". */
+ a68_extract_labels (p, SERIAL_CLAUSE);
/* Parse the program itself. */
for (q = p; q != NO_NODE; FORWARD (q))
{
+ bool siga = true;
+
if (SUB (q) != NO_NODE)
reduce_branch (q, SOME_CLAUSE);
+ while (siga)
+ {
+ siga = false;
+ reduce (q, NO_NOTE, &siga, LABEL, DEFINING_IDENTIFIER, COLON_SYMBOL, STOP);
+ reduce (q, NO_NOTE, &siga, LABEL, LABEL, DEFINING_IDENTIFIER, COLON_SYMBOL, STOP);
+ }
}
/* Determine the encompassing enclosed clause. */
for (q = p; q != NO_NODE; FORWARD (q))
@@ -273,6 +283,7 @@ a68_bottom_up_parser (NODE_T *p)
}
/* Try reducing the particular program. */
q = p;
+ reduce (q, NO_NOTE, NO_TICK, PARTICULAR_PROGRAM, LABEL, ENCLOSED_CLAUSE, STOP);
reduce (q, NO_NOTE, NO_TICK, PARTICULAR_PROGRAM, ENCLOSED_CLAUSE, STOP);
if (SUB (p) == NO_NODE || NEXT (p) != NO_NODE)
recover_from_error (p, PARTICULAR_PROGRAM,
diff --git a/gcc/algol68/a68-parser-scanner.cc b/gcc/algol68/a68-parser-scanner.cc
index 1f37cdaac60..a3a817c5c3a 100644
--- a/gcc/algol68/a68-parser-scanner.cc
+++ b/gcc/algol68/a68-parser-scanner.cc
@@ -40,11 +40,16 @@ static void include_files (LINE_T *top);
static const char *
prelude_start[] = {
+ "BEGIN",
+ " BEGIN",
NO_TEXT
};
static const char *
postlude[] = {
+ " END;",
+ " stop: SKIP",
+ "END;",
NO_TEXT
};
diff --git a/gcc/algol68/ga68.texi b/gcc/algol68/ga68.texi
index 69d6e1506ab..032e0bca4c8 100644
--- a/gcc/algol68/ga68.texi
+++ b/gcc/algol68/ga68.texi
@@ -312,16 +312,86 @@ compilation units supported by the compiler.
@section Programs
@cindex program
-An Algol 68 program consists on an enclosed clause, possibly supported
-by previously compiled declarations modules. The form in which a
-program is written is:
+@menu
+* Particular programs:: Programs that go in @file{.a68} files.
+* Program environment:: Environment where particular programs run.
+* Exit status:: How do programs communicate success or failure.
+@end menu
+
+@node Particular programs
+@section Particular programs
+@cindex particular program
+
+An Algol 68 @dfn{particular program} consists on an enclosed clause in
+a strong context with target mode @code{@B{void}}, possibly preceded
+by a set of zero of more labels. For example:
+
+@example
+hello:
+@B{begin} puts ("Hello, world!\n")
+@B{end}
+@end example
+
+@noindent
+Note that the enclosed clause conforming the particular program
+doesn't have to be a closed clause. Consider for example the
+following program, that prints out its command line arguments:
+
+@example
+@B{for} i @B{to} argc
+@B{do} puts (argv (i) + "\n") @B{od}
+@end example
+
+@node Program environment
+@section Program environment
+@cindex program environment
+
+The environment in which particular programs run is expressed here in
+the form of pseudo code:
+
+@example
+(@B{c} standard-prelude @B{c};
+ @B{c} library-prelude @B{c};
+ @B{c} system-prelude @B{c};
+ @B{par} @B{begin} @B{c} system-task-1 @B{c},
+ @B{c} system-task-2 @B{c},
+ @B{c} system-task-n @B{c},
+ @B{c} user-task-1 @B{c},
+ @B{c} user-task-2 @B{c},
+ @B{c} user-task-m @B{c}
+ @B{end})
+@end example
+
+@noindent
+Where each user task consists on:
@example
-enclosed-clause
+(@B{c} particular-prelude @B{c};
+ @B{c} particular-program @B{c};
+ @B{c} particular-postlude @B{c})
@end example
-The enclosed clause is in a strong context with target mode
-@code{@B{void}}.
+The only standard system task described in the report is expressed in
+pseudo-code as:
+
+@example
+@B{do} @B{down} gremlins; unefined; @B{up} bfileprotect @B{od}
+@end example
+
+@noindent
+Which denotes that, once a book (file) is closed, anything may happen.
+Other system tasks may exist, depending on the operating system. In
+general these tasks in the parallel clause denote the fact that the
+operating system is running in parallel (intercalated) with the user's
+particular programs.
+
+The different preludes and postlude provided by this compiler are
+documented in later sections in this manual. Note that the particular
+prelude and postlude are common to all the particular programs.
+
+@node Exit status
+@section Exit status
+@cindex exit status
Some operating systems have the notion of @dfn{exit status} of a
process. In such systems, by default the execution of the particular
@@ -351,16 +421,6 @@ system with a success status:
@B{end}
@end example
-@noindent
-Note that the enclosed clause conforming the particular program
-doesn't have to be a closed clause. Consider for example the
-following program, that prints out its command line arguments:
-
-@example
-@B{for} i @B{to} argc
-@B{do} puts (argv (i) + "\n") @B{od}
-@end example
-
@node Pragmats
@chapter Pragmats
diff --git a/gcc/testsuite/algol68/README.mcts b/gcc/testsuite/algol68/README.mcts
index 629f4b59585..dc3c50b35c4 100644
--- a/gcc/testsuite/algol68/README.mcts
+++ b/gcc/testsuite/algol68/README.mcts
@@ -17,20 +17,6 @@ The test set explores all odd corners of Algol 68.
The tests have been modified in order to accommodate the GNU Algol 68
implementation. Some general adaptations are:
-- The enclosed clause in the particular program in the GNU Algol
- compiler yields an INT value instead of VOID. Tests are adapted to
- this fact, and to the fact they should yield 0 to tell the operating
- system the program ran successfully.
-
-- Some tests rely on the implicit label `stop' defined by the standard
- postlude. Since GNU Algol 68 doesn't provide a standard postlude,
- an equivalent label is added explicitly whenever necessary.
-
-- In standard Algol 68 an optional list of labels can precede the
- enclosed clause conforming the particular program. This is not so
- in GNU Algol 68, so these labels are removed from the tests using
- them. XXX why not supporting this
-
- Many tests in the original MC test set print out expected results so
they can be verified visually. We check for them programmatically
instead making use of the ASSERT construct.
diff --git a/gcc/testsuite/algol68/compile/snobol.a68 b/gcc/testsuite/algol68/compile/snobol.a68
index 24ac7b9132a..4e58b0b77c2 100644
--- a/gcc/testsuite/algol68/compile/snobol.a68
+++ b/gcc/testsuite/algol68/compile/snobol.a68
@@ -1094,6 +1094,5 @@ BEGIN PROC itoa = (INT i) STRING:
END;
interpret ((REF ITEM (prog entry) IS NIL | 1 | find label (prog entry)))
- END; # INTERPRETATION PHASE #
-stop: SKIP
+ END # INTERPRETATION PHASE #
END
diff --git a/gcc/testsuite/algol68/execute/declarer-1.a68 b/gcc/testsuite/algol68/execute/declarer-1.a68
index 34f4fbea449..bd59afdbddf 100644
--- a/gcc/testsuite/algol68/execute/declarer-1.a68
+++ b/gcc/testsuite/algol68/execute/declarer-1.a68
@@ -4,6 +4,5 @@ BEGIN STRING month = CASE 13
"July","Aug","Sept", "Oct", "Nov","Dec",
stop
ESAC;
- ASSERT (FALSE);
-stop: SKIP
+ ASSERT (FALSE)
END
diff --git a/gcc/testsuite/algol68/execute/goto-5.a68 b/gcc/testsuite/algol68/execute/goto-5.a68
index 6dd6b3f0a72..b520f098be7 100644
--- a/gcc/testsuite/algol68/execute/goto-5.a68
+++ b/gcc/testsuite/algol68/execute/goto-5.a68
@@ -15,6 +15,5 @@ BEGIN PROC is prime = (INT m) BOOL:
ASSERT (is prime (71));
ASSERT (is prime (97));
is prime (0);
- ASSERT (FALSE); # Should jump to stop below. #
-stop: ~
+ ASSERT (FALSE) # Should jump to stop in the standard postlude. #
END
diff --git a/gcc/testsuite/algol68/execute/json-1.a68 b/gcc/testsuite/algol68/execute/json-1.a68
index ca5773a8ab3..8527112a38d 100644
--- a/gcc/testsuite/algol68/execute/json-1.a68
+++ b/gcc/testsuite/algol68/execute/json-1.a68
@@ -156,7 +156,5 @@ BEGIN INT exit status := 0;
STRING str = "{""employee"":{""sons"":[""Peter"",""Juanito"",""Mengano""],""city"":""New York"",""age"":30,""name"":""John""}}";
INT end;
JSONVAL json = json from string (str, end);
- ASSERT (json to string (json) = "{""employee"":{""name"":""John"",""age"":30,""city"":""New York"",""sons"":[""Peter"",""Juanito"",""Mengano""]}}");
-stop:
- SKIP
+ ASSERT (json to string (json) = "{""employee"":{""name"":""John"",""age"":30,""city"":""New York"",""sons"":[""Peter"",""Juanito"",""Mengano""]}}")
END
diff --git a/gcc/testsuite/algol68/execute/mcts/clau08.a68 b/gcc/testsuite/algol68/execute/mcts/clau08.a68
index 5285f478600..b305d5715ed 100644
--- a/gcc/testsuite/algol68/execute/mcts/clau08.a68
+++ b/gcc/testsuite/algol68/execute/mcts/clau08.a68
@@ -154,6 +154,5 @@ BEGIN BOOL true; INT a1, a2, a3;
PROC h = VOID: BEGIN SKIP END;
SKIP
-END;
-stop: SKIP
+END
END
diff --git a/gcc/testsuite/algol68/execute/mcts/coer08.a68 b/gcc/testsuite/algol68/execute/mcts/coer08.a68
index 1e7d68bbeeb..aaf3d3f5229 100644
--- a/gcc/testsuite/algol68/execute/mcts/coer08.a68
+++ b/gcc/testsuite/algol68/execute/mcts/coer08.a68
@@ -4,6 +4,5 @@ BEGIN ASSERT ((HEAP INT x := 314;
IN SKIP,
IF x < 0 THEN GOTO stop ELSE REF[]INT: NIL FI,
IF x > 0 THEN x ELSE x +:= 1 FI
- ESAC := 200)[1] = 200);
-stop: SKIP
+ ESAC := 200)[1] = 200)
END
diff --git a/gcc/testsuite/algol68/execute/mcts/coer09.a68 b/gcc/testsuite/algol68/execute/mcts/coer09.a68
index 0e1be22e614..c7b221a51ad 100644
--- a/gcc/testsuite/algol68/execute/mcts/coer09.a68
+++ b/gcc/testsuite/algol68/execute/mcts/coer09.a68
@@ -10,7 +10,6 @@ BEGIN ASSERT (CASE 2
IN LOC REF REF []INT,
LOC INT,
NIL
- ESAC);
+ ESAC)
# TRUE, would you believe. #
-stop: SKIP
END
diff --git a/gcc/testsuite/algol68/execute/mcts/idef12.a68 b/gcc/testsuite/algol68/execute/mcts/idef12.a68
index bc15e78c71c..04642e17d72 100644
--- a/gcc/testsuite/algol68/execute/mcts/idef12.a68
+++ b/gcc/testsuite/algol68/execute/mcts/idef12.a68
@@ -47,7 +47,5 @@ DO DO
EXIT drop:
puts("rter than line three." + "\n" + "End of test");
stop
-OD;
-stop:
- SKIP
+OD
END
diff --git a/gcc/testsuite/algol68/execute/mcts/null03.a68 b/gcc/testsuite/algol68/execute/mcts/null03.a68
index b03c7429250..aa58115f258 100644
--- a/gcc/testsuite/algol68/execute/mcts/null03.a68
+++ b/gcc/testsuite/algol68/execute/mcts/null03.a68
@@ -1,4 +1,3 @@
-BEGIN DO stop OD;
-stop: SKIP
+BEGIN DO stop OD
END
diff --git a/gcc/testsuite/algol68/execute/mcts/null06.a68 b/gcc/testsuite/algol68/execute/mcts/null06.a68
index e7e295833e0..e9dba7ea745 100644
--- a/gcc/testsuite/algol68/execute/mcts/null06.a68
+++ b/gcc/testsuite/algol68/execute/mcts/null06.a68
@@ -1,4 +1,3 @@
-BEGIN BY 0 DO stop OD;
-stop: SKIP
+BEGIN BY 0 DO stop OD
END
diff --git a/gcc/testsuite/algol68/execute/mcts/oper05.a68 b/gcc/testsuite/algol68/execute/mcts/oper05.a68
index 0a3f0320781..ec3de45480a 100644
--- a/gcc/testsuite/algol68/execute/mcts/oper05.a68
+++ b/gcc/testsuite/algol68/execute/mcts/oper05.a68
@@ -3,7 +3,5 @@ BEGIN PRIO +> = 1, +< = 1;
INT cnt := 0;
OP +> = (INT a, b) INT: IF (cnt +:= 1) = 10 THEN stop ELSE a +< b FI;
OP +< = (INT a, b) INT: IF (cnt +:= 1) = 10 THEN stop ELSE a +> b FI;
- 1 +> 2; # loop #
-stop:
- SKIP
+ 1 +> 2 # loop #
END
diff --git a/gcc/testsuite/algol68/execute/mcts/simp02.a68 b/gcc/testsuite/algol68/execute/mcts/simp02.a68
index 0094b3c7b4f..d80d03d355c 100644
--- a/gcc/testsuite/algol68/execute/mcts/simp02.a68
+++ b/gcc/testsuite/algol68/execute/mcts/simp02.a68
@@ -1,4 +1,5 @@
# Test that ranges are correct #
+range_of_variables:
BEGIN INT i, j;
i := 3; j := 4;
BEGIN INT i, k;
diff --git a/gcc/testsuite/algol68/execute/mcts/simp04.a68 b/gcc/testsuite/algol68/execute/mcts/simp04.a68
index cd6b14a0acd..716d385432d 100644
--- a/gcc/testsuite/algol68/execute/mcts/simp04.a68
+++ b/gcc/testsuite/algol68/execute/mcts/simp04.a68
@@ -1,4 +1,6 @@
# Multiple values. #
+multiples:
+structures:
BEGIN [1:100]INT i, j, k;
FOR l TO 100 DO i[l] := j[l] := k[l] := 1 OD;
FOR l TO 100
diff --git a/gcc/testsuite/algol68/execute/undefined-1.a68 b/gcc/testsuite/algol68/execute/undefined-1.a68
index 8f5702a0a10..a9335c37036 100644
--- a/gcc/testsuite/algol68/execute/undefined-1.a68
+++ b/gcc/testsuite/algol68/execute/undefined-1.a68
@@ -5,6 +5,5 @@ BEGIN INT x := 0;
IF j > 20 THEN stop FI;
INT j = x + i;
x +:= 1
- OD;
-stop: SKIP
+ OD
END
--
2.30.2
More information about the Algol68
mailing list