mirror of
https://forge.sourceware.org/marek/gcc.git
synced 2026-02-22 03:47:02 -05:00
Most of the standard prelude is implemented in a combination of code
lowered by the front-end (standard operators, contants, etc) and
functions provided by the libga68 run-time library, to which the
former libcalls. Until now, all the support routines in libga68 were
written in C. However, many of the transput facilities are better
implemented in Algol 68.
The Revised Report includes a reference implementation (code listing)
of many of the standard routines. This implementation, however, makes
use of an "extended" program notation in order to denote certain
notions to avoid repetitive code. Therefore this commit includes
sppp, a build-time pre-processor written in awk that is only intended
to be used internally by the libga68 run-time library. This
preprocessor allows us to write code like:
proc subwhole = (Number v, int width) string:
case v in
{iter L {short short} {short} {} {long} {long long}}
{iter S {LENG LENG} {LENG} {} {SHORTEN} {SHORTEN SHORTEN}}
({L} int x):
begin string s, {L} int n := x;
while dig_char ({S} (n MOD {L} 10)) +=: s;
n %:= {L} 10; n /= {L} 0
do ~ od;
(UPB s > width | width * errorchar | s)
end
{reti {,}}
esac;
Resulting in cases for short short int, short int, int, long int and
long long int being macro-expanded in the routine's conformance
clause.
This commit also adds the necessary infrastructure for writing Algol
68 code in the libga68 library, including the ability of having
modules exported by libga68. An implementation of some of the
transput routines is also provided in standard.a68: whole, fixed,
float, string_to_L_real, char_in_string, L_int_width, L_real_width and
L_exp_with.
The build system changes include the backport of the Automake Algol 68
support, which is in a released version of Automake but not in the
version used for GCC, to libga68/m4/autoconf.m4.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
ChangeLog
* Makefile.def (flags_to_pass): Rename GA68, GA68FLAGS,
GA68_FOR_TARGET, GA68FLAGS_FOR_TARGET to A68, A68FLAGS,
A68_FOR_TARGET and A68FLAGS_FOR_TARGET.
* Makefile.tpl: Use A68, A68FLAGS, A68_FOR_BUILD and
A68_FOR_TARGET rather than GA68, GA68FLAGS, GA68_FOR_BUILD and
GA68_FOR_TARGET.
* Makefile.in: Regenerate.
* configure.ac: Set A68_FOR_BUILD rather than GA68_FOR_BUILD, and
invoke ACX_PROG_A68 rather than ACX_PROG_GA68.
Subst A68_FOR_BUILD rather than GA68_FOR_BUILD.
Subst A68 and A68FLAGS rather than GA68 and GA68FLAGS.
Set A68_FOR_TARGET rather than GA68_FOR_TARGET.
* configure: Regenerate.
* config-ml.in: Handle A68FLAGS and define A68 in sub-configures.
config/ChangeLog
* acx.m4: Define ACX_PROG_A68 rather than ACX_PROG_GA68.
(ACX_PROG_A68): Set A68 rather than GA68.
gcc/algol68/ChangeLog
* a68-lang.cc (a68_init_options): Add an entry to A68_MODULE_FILES
to map module Transput to the basename ga68.
gcc/testsuite/ChangeLog
* algol68/execute/char-in-string-1.a68: New test.
libga68/ChangeLog
* m4/autoconf.m4: New file.
* configure.ac: Expand AC_PROG_A68.
* configure: Regenerate.
* Makefile.am: Add rules to build Algol 68 sources and to
build the transput module.
* Makefile.in: Regenerate.
* acinclude.m4: Include m4/autoconf.m4.
* sppp.awk: New file.
* transput.a68.in: Likewise.
132 lines
3.5 KiB
Plaintext
132 lines
3.5 KiB
Plaintext
#
|
|
# Minimal autoconf support for the Algol 68 language.
|
|
# Adapted from the Algol 68 language support files.
|
|
#
|
|
|
|
# ------------------- #
|
|
# Language selection.
|
|
# ------------------- #
|
|
|
|
# AC_LANG(A68)
|
|
# ------------
|
|
AC_LANG_DEFINE([Algol 68], [a68], [A68], [A68], [],
|
|
[ac_ext=a68
|
|
ac_compile='$A68 -c $A68FLAGS conftest.$ac_ext >&AS_MESSAGE_LOG_FD'
|
|
ac_link='$A68 -o conftest$ac_exeext $A68FLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AS_MESSAGE_LOG_FD'
|
|
ac_compiler_gnu=yes
|
|
])
|
|
|
|
# AC_LANG_A68
|
|
# -----------
|
|
AU_DEFUN([AC_LANG_A68], [AC_LANG(Algol 68)])
|
|
|
|
# ------------------- #
|
|
# Producing programs.
|
|
# ------------------- #
|
|
|
|
# AC_LANG_PROGRAM(Algol 68)([PROLOGUE], [BODY])
|
|
# ---------------------------------------------
|
|
m4_define([AC_LANG_PROGRAM(Algol 68)],
|
|
[$1
|
|
begin $2 m4_ifnblank([$2],[;])
|
|
skip
|
|
end])
|
|
|
|
# _AC_LANG_IO_PROGRAM(Algol 68)
|
|
# -----------------------------
|
|
# Produce source that performs I/O.
|
|
m4_define([_AC_LANG_IO_PROGRAM(Algol 68)],
|
|
[AC_LANG_PROGRAM([],
|
|
[if int fd = fcreate ("conftest.out", 8r0777); fd = -1
|
|
then perror ("error creating conftest.out")
|
|
elif fclose (fd) = -1 then perror ("error closing conftest.out")
|
|
fi
|
|
])])
|
|
|
|
# AC_LANG_CALL(Algol 68)(PROLOGUE, FUNCTION)
|
|
# ------------------------------------------
|
|
# Avoid conflicting decl of main.
|
|
m4_define([AC_LANG_CALL(Algol 68)],
|
|
[AC_LANG_PROGRAM([],[])])
|
|
|
|
# AC_LANG_FUNC_LINK_TRY(Algol 68)(FUNCTION)
|
|
# -----------------------------------------
|
|
# Try to link a program which calls FUNCTION.
|
|
m4_define([AC_LANG_FUNC_LINK_TRY(Algol 68)],
|
|
[AC_LANG_PROGRAM([],[])])
|
|
|
|
# AC_LANG_BOOL_COMPILE_TRY(Algol 68)(PROLOGUE, EXPRESSION)
|
|
# --------------------------------------------------------
|
|
# Return a program which is valid if EXPRESSION is nonzero.
|
|
m4_define([AC_LANG_BOOL_COMPILE_TRY(Algol 68)],
|
|
[AC_LANG_PROGRAM([], [@<:@$2@:>@INT test multiple;
|
|
0])])
|
|
|
|
# AC_LANG_INT_SAVE(Algol 68)(PROLOGUE, EXPRESSION)
|
|
# ------------------------------------------------
|
|
m4_define([AC_LANG_INT_SAVE(Algol 68)],
|
|
[AC_LANG_PROGRAM([
|
|
proc itoa = (int i) string:
|
|
begin if i = 0
|
|
then "0"
|
|
else int n := ABS i;
|
|
string res;
|
|
while n /= 0
|
|
do int rem = n %* 10;
|
|
res := (REPR (rem > 9 | (rem - 10) + ABS "a"
|
|
| rem + ABS "0")
|
|
+ res);
|
|
n %:= 10
|
|
od;
|
|
(i < 0 | "-" + res | res)
|
|
fi
|
|
end;
|
|
|
|
int ret := 0;
|
|
int fd = fopen ("conftest.val", file o wronly)/
|
|
(fd = -1 | ret := 1; stop);
|
|
(fputs (fd, itoa ($2)) = 0 | ret := 1; stop)
|
|
])])
|
|
|
|
# ---------------------- #
|
|
# Looking for compilers. #
|
|
# ---------------------- #
|
|
|
|
# AC_LANG_COMPILER(Algol 68)
|
|
# --------------------------
|
|
AC_DEFUN([AC_LANG_COMPILER(Algol 68)],
|
|
[AC_REQUIRE([AC_PROG_A68])])
|
|
|
|
# AC_PROG_A68
|
|
# ------------
|
|
AN_MAKEVAR([A68], [AC_PROG_A68])
|
|
AN_PROGRAM([ga68], [AC_PROG_A68])
|
|
AC_DEFUN([AC_PROG_A68],
|
|
[AC_LANG_PUSH(Algol 68)dnl
|
|
AC_ARG_VAR([A68], [Algol 68 compiler command])dnl
|
|
AC_ARG_VAR([A68FLAGS], [Algol 68 compiler flags])dnl
|
|
_AC_ARG_VAR_LDFLAGS()dnl
|
|
m4_ifval([$1],
|
|
[AC_CHECK_TOOLS(A68, [$1])],
|
|
[AC_CHECK_TOOL(A68, ga68)
|
|
if test -z "$A68"; then
|
|
if test -n "$ac_tool_prefix"; then
|
|
AC_CHECK_PROG(A68, [${ac_tool_prefix}ga68], [$ac_tool_prefix}ga68])
|
|
fi
|
|
fi
|
|
if test -z "$A68"; then
|
|
AC_CHECK_PROG(A68, ga68, ga68, , , false)
|
|
fi
|
|
])
|
|
|
|
# Provide some information about the compiler.
|
|
_AS_ECHO_LOG([checking for _AC_LANG compiler version])
|
|
set X $ac_compile
|
|
ac_compiler=$[2]
|
|
_AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
|
|
m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
|
|
m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
|
|
A68FLAGS="-g -O2"
|
|
AC_LANG_POP(Algol 68)dnl
|
|
])# AC_PROG_A68
|