snapshot of project "byacc", label t20230521

This commit is contained in:
Thomas E. Dickey 2023-05-21 19:59:32 +00:00
parent b8ded32537
commit e2328dabf9
No known key found for this signature in database
GPG Key ID: CC2AF4472167BE03
15 changed files with 1467 additions and 700 deletions

63
CHANGES
View File

@ -1,3 +1,62 @@
2023-05-21 Thomas E. Dickey <dickey@invisible-island.net>
* VERSION, package/byacc.spec, package/debian/changelog,
package/mingw-byacc.spec, package/pkgsrc/Makefile:
bump
* configure: regen
* aclocal.m4:
updates for CF_INSTALL_MAN from reflex, which needs the symbolic link feature
* aclocal.m4:
improve install-man by adding sed commands for --program-transform-name
2023-05-19 Thomas E. Dickey <dickey@invisible-island.net>
* makefile.in: use CF_INSTALL_MAN
* aclocal.m4:
add CF_INSTALL_MAN, to begin refactoring install rule for manpage
* configure: regen
* configure.in: use CF_INSTALL_MAN
2023-05-18 Thomas E. Dickey <dickey@invisible-island.net>
* error.c, defs.h, reader.c:
allow @1 or $@ with a warning if no %locations was given
2023-05-17 Thomas E. Dickey <dickey@invisible-island.net>
* reader.c: clear pointer in end_ainfo() after freeing it.
2023-05-16 Thomas E. Dickey <dickey@invisible-island.net>
* reader.c: report errors in %define as "unexpected value"
* reader.c:
add/use macros begin_ainfo() and end_ainfo() to reduce clutter
* defs.h, error.c: add function unexpected_value()
* reader.c:
recognize bison's "%define api.pure" as an alternative to "%pure-parser"
* reader.c:
add %nterm as an alias for %type, since bison made that confusion.
* reader.c:
ensure that filler_buf and prefix_buf are initialized for the special case
where they are empty (report by Martin Jansa, cf: 20230219)
* output.c:
make test-differences smaller when compiling with YY_NO_LEAKS by replacing
a blank line with the generated #define rather than adding 3 lines.
* reader.c: gcc-warnings
2023-05-15 Thomas E. Dickey <dickey@invisible-island.net>
* VERSION, package/byacc.spec, package/debian/changelog,
@ -21,6 +80,10 @@
* defs.h: rename no_space() to on_error()
2023-04-03 Thomas E. Dickey <dickey@invisible-island.net>
* aclocal.m4: resync with my-autoconf: CF_GCC_VERSION CF_XOPEN_SOURCE
2023-02-26 Thomas E. Dickey <dickey@invisible-island.net>
* mstring.c, reader.c: yak-indent

View File

@ -1,4 +1,4 @@
MANIFEST for byacc, version t20230515
MANIFEST for byacc, version t20230521
--------------------------------------------------------------------------------
MANIFEST this file
ACKNOWLEDGEMENTS original version of byacc - 1993

View File

@ -1 +1 @@
20230515
20230521

343
aclocal.m4 vendored
View File

@ -1,4 +1,4 @@
dnl $Id: aclocal.m4,v 1.60 2023/02/20 16:15:46 tom Exp $
dnl $Id: aclocal.m4,v 1.64 2023/05/21 19:57:27 tom Exp $
dnl Macros for byacc configure script (Thomas E. Dickey)
dnl ---------------------------------------------------------------------------
dnl Copyright 2004-2022,2023 Thomas E. Dickey
@ -717,7 +717,7 @@ rm -rf ./conftest*
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_GCC_VERSION version: 8 updated: 2019/09/07 13:38:36
dnl CF_GCC_VERSION version: 9 updated: 2023/03/05 14:30:13
dnl --------------
dnl Find version of gcc, and (because icc/clang pretend to be gcc without being
dnl compatible), attempt to determine if icc/clang is actually used.
@ -726,7 +726,7 @@ AC_REQUIRE([AC_PROG_CC])
GCC_VERSION=none
if test "$GCC" = yes ; then
AC_MSG_CHECKING(version of $CC)
GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^.*(GCC[[^)]]*) //' -e 's/^.*(Debian[[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
GCC_VERSION="`${CC} --version 2>/dev/null | sed -e '2,$d' -e 's/^[[^(]]*([[^)]][[^)]]*) //' -e 's/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
test -z "$GCC_VERSION" && GCC_VERSION=unknown
AC_MSG_RESULT($GCC_VERSION)
fi
@ -985,6 +985,151 @@ if test x$cf_cv_gnu_library = xyes; then
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_INSTALL_MAN version: 5 updated: 2023/05/21 15:53:07
dnl --------------
dnl Call this to generate a script "install-man" which uses the detected
dnl manpage-format to compress the resulting manpage. Providing this as a
dnl macro simplifies including the script in different programs.
dnl
dnl The generated script assumes that the program can be renamed, using two
dnl symbols in the manpage, e.g.,
dnl .ds N Yacc
dnl .ds n yacc
dnl which are later used as \*N and \*n, as well as a special case in the
dnl synopsis to work around limitations of makewhatis.
dnl
dnl Script parameters:
dnl $1 = input file
dnl $2 = output filename
dnl
dnl or (uninstall):
dnl $1 = output filename
AC_DEFUN([CF_INSTALL_MAN],
[
AC_REQUIRE([AC_ARG_PROGRAM])
AC_REQUIRE([AC_PROG_INSTALL])
AC_REQUIRE([AC_LN_S])
AC_REQUIRE([CF_MANPAGE_FORMAT])
cf_install_man=install-man
ac_config_files="$ac_config_files $cf_install_man"
cf_install_man=$cf_install_man.in
echo [$]as_me: creating $cf_install_man
cat >[$]cf_install_man <<"CF_EOF"
#!/bin/sh
# generated by CF_INSTALL_MAN
LANG=C; export LANG
LC_ALL=C; export LC_ALL
LC_CTYPE=C; export LC_CTYPE
LANGUAGE=C; export LANGUAGE
INSTALL="@INSTALL@"
INSTALL_DATA="@INSTALL_DATA@"
usage() {
cat <<EOF
Usage: install-man [[-l]] [[source]] target
EOF
exit 1
}
failed() {
echo "?? [$]*" >&2
exit 1
}
test [$]# != 0 || usage
OPTS=
case "x[$]1" in
(x-l)
OPTS="link"
shift
;;
(x-*)
usage
;;
esac
source=
if test [$]# = 2 ; then
source=[$]1; shift
target=[$]1
elif test [$]# = 1 ; then
test -n "$OPTS" && usage
target=[$]1
else
usage
fi
origin_name=`echo "$source" |sed -e 's%^.*/%%' -e 's%\..*%%'`
actual_name=`echo "$origin_name" |sed '@program_transform_name@'`
leading_cap=`echo "$actual_name" | sed -e 's%^\(.\).*$%\1%' | tr a-z A-Z``echo "$actual_name" | sed -e 's%^.%%'`
capitalized=`echo "$actual_name" | tr a-z A-Z`
cf_tmpdir=`mktemp -d`
trap 'rm -rf "$cf_tmpdir"; exit 1' 1 2 3 15
trap 'rm -rf "$cf_tmpdir"; exit 0' 0
if test -n "$source" ; then
suffix=
test -n "@cf_manpage_so_strip" && suffix=".@cf_manpage_so_strip@"
if test "x$OPTS" = xlink ; then
source_dir=`echo "$source" | sed -e "s%/[[^/]]*$%%"`
target_dir=`echo "$target" | sed -e "s%/[[^/]]*$%%"`
sourcelink="${source}${suffix}"
targetfile="${target}${suffix}"
targetlink="${target_dir}/${sourcelink}"
if test ! -d "$target_dir" ; then
failed "target directory does not exist: $target_dir"
elif test ! -f "$targetfile" ; then
failed "target file does not exist: $targetfile"
elif test "$source" != "$source_dir" ; then
failed "unexpected directory for source-link: $source_dir"
fi
test -f "$targetlink" && failed "already exists $targetlink"
( cd "$target_dir" && @LN_S@ "`echo "$targetfile" | sed -e 's%^.*/%%'`" "$sourcelink" )
test -f "$targetlink" || failed "cannot create $targetlink"
target="$targetlink"
else
echo "** installing $source to $target"
interim="$cf_tmpdir"/"`basename $source`"
if test "x$origin_name" != "x$actual_name" ; then
sed \
-e "/^.ds N/s%N.*%N $leading_cap%" \
-e "/^.ds n/s%n.*%n $actual_name%" \
-e "/^\.TH/s%[[ ]][[ ]]*[[^ ]][[^ ]]*% $capitalized%" \
-e "/^\.SH[[ ]][[ ]]*NAME/,/[[ ]]\\\\-[[ ]]/s%^\\\\\\*[[Nn]]%$actual_name%" \
"$source" >"$interim" || exit 1
diff -c "$source" "$interim"
else
cp "$source" "$interim" || exit 1
fi
if test -n "@cf_manpage_compress@" ; then
@cf_manpage_compress@ "$interim"
source="${interim}${suffix}"
fi
if test -d "$target" ; then
target="$target"/"$source"
else
test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@"
fi
$INSTALL_DATA "$source" "$target" || exit 1
fi
echo "...installed $target"
else
echo "** removing $target"
test -n "@cf_manpage_compress@" && target="${target}.@cf_manpage_so_strip@"
if test -f "$target" ; then
rm -f "$target"
echo "...removed $target"
else
echo "...not found"
fi
fi
exit 0
CF_EOF
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_INTEL_COMPILER version: 9 updated: 2023/02/18 17:41:25
dnl -----------------
dnl Check if the given compiler is really the Intel compiler for Linux. It
@ -1123,6 +1268,162 @@ AC_SUBST(ETAGS)
AC_SUBST(MAKE_UPPER_TAGS)
AC_SUBST(MAKE_LOWER_TAGS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_MANPAGE_FORMAT version: 18 updated: 2023/05/19 18:35:02
dnl -----------------
dnl Option to allow user to override automatic configuration of manpage format.
dnl There are several special cases:
dnl
dnl compress - man checks for, can display compressed files
dnl bzip2 - man checks for, can display bzip2'd files
dnl gzip - man checks for, can display gzip'd files
dnl xz - man checks for, can display xz'd files
dnl
dnl BSDI - files in the cat-directories are suffixed ".0"
dnl formatted - installer should format (put files in cat-directory)
dnl catonly - installer should only format, e.g., for a turnkey system.
dnl
dnl There are other configurations which this macro does not test, e.g., HPUX's
dnl compressed manpages (but uncompressed manpages are fine, and HPUX's naming
dnl convention would not match our use).
AC_DEFUN([CF_MANPAGE_FORMAT],
[
AC_REQUIRE([CF_PATHSEP])
AC_MSG_CHECKING(format of man-pages)
AC_ARG_WITH(manpage-format,
[ --with-manpage-format specify manpage-format: gzip/compress/bzip2/xz,
BSDI/normal and optionally formatted/catonly,
e.g., gzip,formatted],
[MANPAGE_FORMAT=$withval],
[MANPAGE_FORMAT=unknown])
test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=unknown
MANPAGE_FORMAT=`echo "$MANPAGE_FORMAT" | sed -e 's/,/ /g'`
cf_unknown=
case "$MANPAGE_FORMAT" in
(unknown)
if test -z "$MANPATH" ; then
MANPATH="/usr/man:/usr/share/man"
fi
# look for the 'date' man-page (it is most likely to be installed!)
MANPAGE_FORMAT=
cf_preform="no"
cf_catonly="yes"
cf_example="date"
IFS="${IFS:- }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
for cf_dir in $MANPATH; do
test -z "$cf_dir" && cf_dir=/usr/man
for cf_name in $cf_dir/man*/$cf_example.[[01]]* $cf_dir/cat*/$cf_example.[[01]]* $cf_dir/man*/$cf_example $cf_dir/cat*/$cf_example
do
cf_test=`echo "$cf_name" | sed -e 's/*//'`
if test "x$cf_test" = "x$cf_name" ; then
case "$cf_name" in
(*.bz2) MANPAGE_FORMAT="$MANPAGE_FORMAT bzip2";;
(*.xz) MANPAGE_FORMAT="$MANPAGE_FORMAT xz";;
(*.gz) MANPAGE_FORMAT="$MANPAGE_FORMAT gzip";;
(*.Z) MANPAGE_FORMAT="$MANPAGE_FORMAT compress";;
(*.0) MANPAGE_FORMAT="$MANPAGE_FORMAT BSDI";;
(*) MANPAGE_FORMAT="$MANPAGE_FORMAT normal";;
esac
case "$cf_name" in
($cf_dir/man*)
cf_catonly=no
;;
($cf_dir/cat*)
cf_preform=yes
;;
esac
break
fi
# if we found a match in either man* or cat*, stop looking
if test -n "$MANPAGE_FORMAT" ; then
cf_found=no
test "$cf_preform" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT formatted"
test "$cf_catonly" = yes && MANPAGE_FORMAT="$MANPAGE_FORMAT catonly"
case "$cf_name" in
($cf_dir/cat*)
cf_found=yes
;;
esac
test "$cf_found" = yes && break
fi
done
# only check the first directory in $MANPATH where we find manpages
if test -n "$MANPAGE_FORMAT" ; then
break
fi
done
# if we did not find the example, just assume it is normal
test -z "$MANPAGE_FORMAT" && MANPAGE_FORMAT=normal
IFS="$ac_save_ifs"
;;
(*)
for cf_option in $MANPAGE_FORMAT; do
case "$cf_option" in
(xz|bzip2|gzip|compress|BSDI|normal|formatted|catonly)
;;
(*)
cf_unknown="$cf_unknown $cf_option"
;;
esac
done
;;
esac
AC_MSG_RESULT($MANPAGE_FORMAT)
if test -n "$cf_unknown" ; then
AC_MSG_WARN(Unexpected manpage-format $cf_unknown)
fi
cf_manpage_format=no
cf_manpage_inboth=no
cf_manpage_so_strip=
cf_manpage_compress=
for cf_item in $MANPAGE_FORMAT
do
case "$cf_item" in
(catonly)
cf_manpage_format=yes
cf_manpage_inboth=no
;;
(formatted)
cf_manpage_format=yes
cf_manpage_inboth=yes
;;
(compress)
cf_manpage_so_strip="Z"
cf_manpage_compress=compress
;;
(gzip)
cf_manpage_so_strip="gz"
cf_manpage_compress=gzip
;;
(bzip2)
cf_manpage_so_strip="bz2"
cf_manpage_compress=bzip2
;;
(xz)
cf_manpage_so_strip="xz"
cf_manpage_compress=xz
;;
esac
done
AC_SUBST(cf_manpage_format)
AC_SUBST(cf_manpage_inboth)
AC_SUBST(cf_manpage_so_strip)
AC_SUBST(cf_manpage_compress)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_MIXEDCASE_FILENAMES version: 9 updated: 2021/01/01 16:53:59
@ -1254,6 +1555,22 @@ case ".$with_cflags" in
esac
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PATHSEP version: 8 updated: 2021/01/01 13:31:04
dnl ----------
dnl Provide a value for the $PATH and similar separator (or amend the value
dnl as provided in autoconf 2.5x).
AC_DEFUN([CF_PATHSEP],
[
AC_MSG_CHECKING(for PATH separator)
case "$cf_cv_system_name" in
(os2*) PATH_SEPARATOR=';' ;;
(*) ${PATH_SEPARATOR:=':'} ;;
esac
ifelse([$1],,,[$1=$PATH_SEPARATOR])
AC_SUBST(PATH_SEPARATOR)
AC_MSG_RESULT($PATH_SEPARATOR)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PATH_SYNTAX version: 18 updated: 2020/12/31 18:40:20
dnl --------------
dnl Check the argument to see that it looks like a pathname. Rewrite it if it
@ -1760,7 +2077,7 @@ CF_NO_LEAKS_OPTION(valgrind,
[USE_VALGRIND])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_XOPEN_SOURCE version: 64 updated: 2023/02/18 17:41:25
dnl CF_XOPEN_SOURCE version: 66 updated: 2023/04/03 04:19:37
dnl ---------------
dnl Try to get _XOPEN_SOURCE defined properly that we can use POSIX functions,
dnl or adapt to the vendor's definitions to get equivalent functionality,
@ -1769,6 +2086,18 @@ dnl
dnl Parameters:
dnl $1 is the nominal value for _XOPEN_SOURCE
dnl $2 is the nominal value for _POSIX_C_SOURCE
dnl
dnl The default case prefers _XOPEN_SOURCE over _POSIX_C_SOURCE if the
dnl implementation predefines it, because X/Open and most implementations agree
dnl that the latter is a legacy or "aligned" value.
dnl
dnl Because _XOPEN_SOURCE is preferred, if defining _POSIX_C_SOURCE turns
dnl that off, then refrain from setting _POSIX_C_SOURCE explicitly.
dnl
dnl References:
dnl https://pubs.opengroup.org/onlinepubs/007904975/functions/xsh_chap02_02.html
dnl https://docs.oracle.com/cd/E19253-01/816-5175/standards-5/index.html
dnl https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html
AC_DEFUN([CF_XOPEN_SOURCE],[
AC_REQUIRE([AC_CANONICAL_HOST])
AC_REQUIRE([CF_POSIX_VISIBLE])
@ -1808,7 +2137,7 @@ case "$host_os" in
cf_xopen_source="-D_SGI_SOURCE"
cf_XOPEN_SOURCE=
;;
(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys)
(linux*gnu|linux*gnuabi64|linux*gnuabin32|linux*gnueabi|linux*gnueabihf|linux*gnux32|uclinux*|gnu*|mint*|k*bsd*-gnu|cygwin|msys|mingw*)
CF_GNU_SOURCE($cf_XOPEN_SOURCE)
;;
(minix*)
@ -1860,8 +2189,8 @@ case "$host_os" in
cf_save_xopen_cppflags="$CPPFLAGS"
CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
# Some of these niche implementations use copy/paste, double-check...
if test "$cf_cv_xopen_source" != no ; then
CF_VERBOSE(checking if _POSIX_C_SOURCE inteferes)
if test "$cf_cv_xopen_source" = no ; then
CF_VERBOSE(checking if _POSIX_C_SOURCE interferes with _XOPEN_SOURCE)
AC_TRY_COMPILE(CF__XOPEN_SOURCE_HEAD,CF__XOPEN_SOURCE_BODY,,[
AC_MSG_WARN(_POSIX_C_SOURCE definition is not usable)
CPPFLAGS="$cf_save_xopen_cppflags"])

1417
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
dnl Process this file with 'autoconf' to produce a 'configure' script
dnl $Id: configure.in,v 1.28 2023/02/02 00:14:51 tom Exp $
dnl $Id: configure.in,v 1.29 2023/05/19 07:58:43 tom Exp $
AC_PREREQ(2.52.20200802)
AC_REVISION($Revision: 1.28 $)
AC_REVISION($Revision: 1.29 $)
AC_INIT(main.c)
AC_CONFIG_HEADER(config.h:config_h.in)
@ -60,6 +60,8 @@ AC_SUBST(SKELETON)
CF_ENABLE_WARNINGS(Wwrite-strings,yes)
CF_DISABLE_ECHO
CF_DISABLE_LEAKS
CF_MANPAGE_FORMAT
CF_INSTALL_MAN
CF_WITH_MAN2HTML
AC_TYPE_MODE_T

51
defs.h
View File

@ -1,4 +1,4 @@
/* $Id: defs.h,v 1.72 2023/05/11 07:43:15 tom Exp $ */
/* $Id: defs.h,v 1.74 2023/05/18 21:28:05 tom Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@ -122,6 +122,7 @@ typedef enum
,NONPOSIX_DEBUG
/* other bison "extensions", some useful */
,HACK_DEFINE
,ERROR_VERBOSE
,EXPECT
,EXPECT_RR
@ -470,41 +471,45 @@ struct ainfo
char *a_cptr;
};
extern void arg_number_disagree_warning(int a_lineno, char *a_name);
extern void arg_type_disagree_warning(int a_lineno, int i, char *a_name);
extern GCC_NORETURN void at_error(int a_lineno, char *a_line, char *a_cptr);
extern void arg_number_disagree_warning(int a_lineno, const char *a_name);
extern void arg_type_disagree_warning(int a_lineno, int i, const char *a_name);
extern GCC_NORETURN void at_error(int a_lineno, const char *a_line, const char *a_cptr);
extern void at_warning(int a_lineno, int i);
extern GCC_NORETURN void bad_formals(void);
extern void default_action_warning(char *s);
extern void default_action_warning(const char *s);
extern void destructor_redeclared_warning(const struct ainfo *);
extern GCC_NORETURN void dollar_error(int a_lineno, char *a_line, char *a_cptr);
extern void dislocations_warning(void);
extern GCC_NORETURN void dollar_error(int a_lineno, const char *a_line, const char *a_cptr);
extern void dollar_warning(int a_lineno, int i);
extern GCC_NORETURN void fatal(const char *msg);
extern GCC_NORETURN void illegal_character(char *c_cptr);
extern GCC_NORETURN void illegal_tag(int t_lineno, char *t_line, char *t_cptr);
extern GCC_NORETURN void illegal_character(const char *c_cptr);
extern GCC_NORETURN void illegal_tag(int t_lineno, const char *t_line, const char *t_cptr);
extern GCC_NORETURN void missing_brace(void);
extern GCC_NORETURN void no_grammar(void);
extern GCC_NORETURN void on_error(void);
extern GCC_NORETURN void open_error(const char *filename);
extern GCC_NORETURN void over_unionized(char *u_cptr);
extern GCC_NORETURN void over_unionized(const char *u_cptr);
extern void prec_redeclared(void);
extern void reprec_warning(char *s);
extern void reprec_warning(const char *s);
extern void restarted_warning(void);
extern void retyped_warning(char *s);
extern void revalued_warning(char *s);
extern void start_requires_args(char *a_name);
extern GCC_NORETURN void syntax_error(int st_lineno, char *st_line, char *st_cptr);
extern void retyped_warning(const char *s);
extern void revalued_warning(const char *s);
extern void start_requires_args(const char *a_name);
extern GCC_NORETURN void syntax_error(int st_lineno, const char *st_line, const char *st_cptr);
extern GCC_NORETURN void terminal_lhs(int s_lineno);
extern GCC_NORETURN void terminal_start(char *s);
extern GCC_NORETURN void tokenized_start(char *s);
extern GCC_NORETURN void undefined_goal(char *s);
extern void undefined_symbol_warning(char *s);
extern GCC_NORETURN void terminal_start(const char *s);
extern GCC_NORETURN void tokenized_start(const char *s);
extern GCC_NORETURN void undefined_goal(const char *s);
extern void undefined_symbol_warning(const char *s);
extern GCC_NORETURN void unexpected_EOF(void);
extern void unknown_arg_warning(int d_lineno, const char *dlr_opt,
const char *d_arg, const char *d_line,
extern void unknown_arg_warning(int d_lineno,
const char *dlr_opt,
const char *d_arg,
const char *d_line,
const char *d_cptr);
extern GCC_NORETURN void unknown_rhs(int i);
extern void unsupported_flag_warning(const char *flag, const char *details);
extern GCC_NORETURN void unexpected_value(const struct ainfo *);
extern GCC_NORETURN void unterminated_action(const struct ainfo *);
extern GCC_NORETURN void unterminated_comment(const struct ainfo *);
extern GCC_NORETURN void unterminated_string(const struct ainfo *);
@ -512,11 +517,11 @@ extern GCC_NORETURN void unterminated_text(const struct ainfo *);
extern GCC_NORETURN void unterminated_union(const struct ainfo *);
extern void untyped_arg_warning(int a_lineno, const char *dlr_opt, const char *a_name);
extern GCC_NORETURN void untyped_lhs(void);
extern GCC_NORETURN void untyped_rhs(int i, char *s);
extern GCC_NORETURN void used_reserved(char *s);
extern GCC_NORETURN void untyped_rhs(int i, const char *s);
extern GCC_NORETURN void used_reserved(const char *s);
extern GCC_NORETURN void unterminated_arglist(const struct ainfo *);
extern void wrong_number_args_warning(const char *which, const char *a_name);
extern void wrong_type_for_arg_warning(int i, char *a_name);
extern void wrong_type_for_arg_warning(int i, const char *a_name);
/* graph.c */
extern void graph(void);

64
error.c
View File

@ -1,4 +1,4 @@
/* $Id: error.c,v 1.15 2023/05/11 07:45:34 tom Exp $ */
/* $Id: error.c,v 1.17 2023/05/18 21:38:35 tom Exp $ */
/* routines for printing error messages */
@ -71,7 +71,7 @@ print_pos(const char *st_line, const char *st_cptr)
}
void
syntax_error(int st_lineno, char *st_line, char *st_cptr)
syntax_error(int st_lineno, const char *st_line, const char *st_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", syntax error\n",
myname, st_lineno, input_file_name);
@ -79,6 +79,15 @@ syntax_error(int st_lineno, char *st_line, char *st_cptr)
done(1);
}
void
unexpected_value(const struct ainfo *a)
{
fprintf(stderr, "%s: e - line %d of \"%s\", unexpected value\n",
myname, a->a_lineno, input_file_name);
print_pos(a->a_line, a->a_cptr);
done(1);
}
void
unterminated_comment(const struct ainfo *a)
{
@ -116,7 +125,7 @@ declaration\n", myname, a->a_lineno, input_file_name);
}
void
over_unionized(char *u_cptr)
over_unionized(const char *u_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", too many %%union \
declarations\n", myname, lineno, input_file_name);
@ -125,7 +134,7 @@ declarations\n", myname, lineno, input_file_name);
}
void
illegal_tag(int t_lineno, char *t_line, char *t_cptr)
illegal_tag(int t_lineno, const char *t_line, const char *t_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal tag\n",
myname, t_lineno, input_file_name);
@ -134,7 +143,7 @@ illegal_tag(int t_lineno, char *t_line, char *t_cptr)
}
void
illegal_character(char *c_cptr)
illegal_character(const char *c_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal character\n",
myname, lineno, input_file_name);
@ -143,7 +152,7 @@ illegal_character(char *c_cptr)
}
void
used_reserved(char *s)
used_reserved(const char *s)
{
fprintf(stderr,
"%s: e - line %d of \"%s\", illegal use of reserved symbol \
@ -152,7 +161,7 @@ used_reserved(char *s)
}
void
tokenized_start(char *s)
tokenized_start(const char *s)
{
fprintf(stderr,
"%s: e - line %d of \"%s\", the start symbol %s cannot be \
@ -161,14 +170,14 @@ declared to be a token\n", myname, lineno, input_file_name, s);
}
void
retyped_warning(char *s)
retyped_warning(const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the type of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
void
reprec_warning(char *s)
reprec_warning(const char *s)
{
fprintf(stderr,
"%s: w - line %d of \"%s\", the precedence of %s has been \
@ -176,14 +185,14 @@ redeclared\n", myname, lineno, input_file_name, s);
}
void
revalued_warning(char *s)
revalued_warning(const char *s)
{
fprintf(stderr, "%s: w - line %d of \"%s\", the value of %s has been \
redeclared\n", myname, lineno, input_file_name, s);
}
void
terminal_start(char *s)
terminal_start(const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", the start symbol %s is a \
token\n", myname, lineno, input_file_name, s);
@ -237,7 +246,7 @@ end of the current rule\n", myname, a_lineno, input_file_name, i);
}
void
dollar_error(int a_lineno, char *a_line, char *a_cptr)
dollar_error(int a_lineno, const char *a_line, const char *a_cptr)
{
fprintf(stderr, "%s: e - line %d of \"%s\", illegal $-name\n",
myname, a_lineno, input_file_name);
@ -245,6 +254,13 @@ dollar_error(int a_lineno, char *a_line, char *a_cptr)
done(1);
}
void
dislocations_warning(void)
{
fprintf(stderr, "%s: e - line %d of \"%s\", expected %%locations\n",
myname, lineno, input_file_name);
}
void
untyped_lhs(void)
{
@ -254,7 +270,7 @@ untyped_lhs(void)
}
void
untyped_rhs(int i, char *s)
untyped_rhs(int i, const char *s)
{
fprintf(stderr, "%s: e - line %d of \"%s\", $%d (%s) is untyped\n",
myname, lineno, input_file_name, i, s);
@ -270,7 +286,7 @@ unknown_rhs(int i)
}
void
default_action_warning(char *s)
default_action_warning(const char *s)
{
fprintf(stderr,
"%s: w - line %d of \"%s\", the default action for %s assigns an \
@ -279,14 +295,14 @@ undefined value to $$\n",
}
void
undefined_goal(char *s)
undefined_goal(const char *s)
{
fprintf(stderr, "%s: e - the start symbol %s is undefined\n", myname, s);
done(1);
}
void
undefined_symbol_warning(char *s)
undefined_symbol_warning(const char *s)
{
fprintf(stderr, "%s: w - the symbol %s is undefined\n", myname, s);
}
@ -309,7 +325,7 @@ end of the current rule\n", myname, a_lineno, input_file_name, i);
}
void
at_error(int a_lineno, char *a_line, char *a_cptr)
at_error(int a_lineno, const char *a_line, const char *a_cptr)
{
fprintf(stderr,
"%s: e - line %d of \"%s\", illegal @$ or @N reference\n",
@ -329,7 +345,7 @@ unterminated_arglist(const struct ainfo *a)
}
void
arg_number_disagree_warning(int a_lineno, char *a_name)
arg_number_disagree_warning(int a_lineno, const char *a_name)
{
fprintf(stderr, "%s: w - line %d of \"%s\", number of arguments of %s "
"doesn't agree with previous declaration\n",
@ -346,7 +362,7 @@ bad_formals(void)
}
void
arg_type_disagree_warning(int a_lineno, int i, char *a_name)
arg_type_disagree_warning(int a_lineno, int i, const char *a_name)
{
fprintf(stderr, "%s: w - line %d of \"%s\", type of argument %d "
"to %s doesn't agree with previous declaration\n",
@ -354,8 +370,10 @@ arg_type_disagree_warning(int a_lineno, int i, char *a_name)
}
void
unknown_arg_warning(int d_lineno, const char *dlr_opt, const char *d_arg, const char
*d_line, const char *d_cptr)
unknown_arg_warning(int d_lineno, const char *dlr_opt,
const char *d_arg,
const char *d_line,
const char *d_cptr)
{
fprintf(stderr, "%s: w - line %d of \"%s\", unknown argument %s%s\n",
myname, d_lineno, input_file_name, dlr_opt, d_arg);
@ -379,7 +397,7 @@ wrong_number_args_warning(const char *which, const char *a_name)
}
void
wrong_type_for_arg_warning(int i, char *a_name)
wrong_type_for_arg_warning(int i, const char *a_name)
{
fprintf(stderr,
"%s: w - line %d of \"%s\", wrong type for default argument %d to %s\n",
@ -388,7 +406,7 @@ wrong_type_for_arg_warning(int i, char *a_name)
}
void
start_requires_args(char *a_name)
start_requires_args(const char *a_name)
{
fprintf(stderr,
"%s: w - line %d of \"%s\", start symbol %s requires arguments\n",

View File

@ -1,4 +1,4 @@
# $Id: makefile.in,v 1.25 2022/11/06 21:03:11 tom Exp $
# $Id: makefile.in,v 1.26 2023/05/19 23:16:31 tom Exp $
#
# UNIX template-makefile for Berkeley Yacc
@ -99,7 +99,7 @@ all : $(THIS)$x
install: all installdirs
$(INSTALL_PROGRAM) $(THIS)$x $(bindir)/$(actual_bin)
- $(INSTALL_DATA) $(srcdir)/$(THIS).1 $(mandir)/$(actual_man)
@ $(SHELL) ./install-man $(srcdir)/$(THIS).1 $(mandir)/$(actual_man)
installdirs:
mkdir -p $(bindir)
@ -107,7 +107,7 @@ installdirs:
uninstall:
- rm -f $(bindir)/$(actual_bin)
- rm -f $(mandir)/$(actual_man)
@ $(SHELL) ./install-man $(mandir)/$(actual_man)
################################################################################
.SUFFIXES : .c $o .i .skel
@ -135,7 +135,7 @@ clean :: mostlyclean
- rm -f $(THIS)$x
distclean :: clean
- rm -f config.log config.cache config.status config.h makefile man2html.tmp
- rm -f config.log config.cache config.status config.h makefile man2html.tmp install-man*
- rm -f $(testdir)/yacc/test-* $(testdir)/btyacc/test-*
realclean :: distclean

View File

@ -1,4 +1,4 @@
/* $Id: output.c,v 1.100 2022/01/09 18:03:56 tom Exp $ */
/* $Id: output.c,v 1.101 2023/05/16 21:19:48 tom Exp $ */
#include "defs.h"
@ -1623,21 +1623,14 @@ output_pure_parser(FILE * fp)
if (fp == code_file)
++outline;
fprintf(fp, "#define YYPURE %d\n", pure_parser);
putc_code(fp, '\n');
}
#if defined(YY_NO_LEAKS)
static void
output_no_leaks(FILE * fp)
{
putc_code(fp, '\n');
if (fp == code_file)
++outline;
fputs("#define YY_NO_LEAKS 1\n", fp);
#else
putc_code(fp, '\n');
}
#endif
}
static void
output_trailing_text(void)
@ -2092,9 +2085,6 @@ output(void)
output_prefix(fp);
output_pure_parser(fp);
#if defined(YY_NO_LEAKS)
output_no_leaks(fp);
#endif
output_stored_text(fp);
output_stype(fp);
#if defined(YYBTYACC)

View File

@ -1,12 +1,12 @@
Summary: public domain Berkeley LALR Yacc parser generator
%global AppVersion 2.0
%global AppPatched 20230515
%global AppPatched 20230521
%global AltProgram byacc2
%global UseProgram yacc
# $Id: byacc.spec,v 1.73 2023/05/15 23:34:59 tom Exp $
# $Id: byacc.spec,v 1.74 2023/05/21 19:59:32 tom Exp $
Name: byacc
Version: %{AppVersion}.%{AppPatched}
Release: 1

View File

@ -1,4 +1,4 @@
byacc (1:2.0.20230515) unstable; urgency=low
byacc (1:2.0.20230521) unstable; urgency=low
* maintenance updates

View File

@ -1,11 +1,11 @@
Summary: public domain Berkeley LALR Yacc parser generator
%global AppVersion 2.0
%global AppPatched 20230515
%global AppPatched 20230521
%global UseProgram yacc
# $Id: mingw-byacc.spec,v 1.50 2023/05/15 23:34:59 tom Exp $
# $Id: mingw-byacc.spec,v 1.51 2023/05/21 19:59:32 tom Exp $
Name: byacc
Version: %{AppVersion}.%{AppPatched}
Release: 1

View File

@ -1,7 +1,7 @@
# $NetBSD: Makefile,v 1.24 2021/08/14 01:04:32 mef Exp $
#
DISTNAME= byacc-20230515
DISTNAME= byacc-20230521
CATEGORIES= devel
MASTER_SITES= https://invisible-mirror.net/archives/byacc/
DIST_SUBDIR= byacc-20220101

183
reader.c
View File

@ -1,4 +1,4 @@
/* $Id: reader.c,v 1.96 2023/05/15 23:34:53 tom Exp $ */
/* $Id: reader.c,v 1.104 2023/05/18 21:18:17 tom Exp $ */
#include "defs.h"
@ -32,6 +32,17 @@
fprintf_lineno(f, 1, ""); \
fprintf(f, "break;\n")
#define begin_ainfo(data, offset) do { \
data.a_lineno = lineno; \
data.a_line = dup_line(); \
data.a_cptr = data.a_line + (cptr - line - offset); \
} while (0)
#define end_ainfo(data) do { \
FREE(data.a_line); \
memset(&data, 0, sizeof(data)); \
} while (0)
static void start_rule(bucket *bp, int s_lineno);
#if defined(YYBTYACC)
static void copy_initial_action(void);
@ -52,7 +63,7 @@ char unionized;
char *line; /* current input-line */
char *cptr; /* position within current input-line */
static int linesize; /* length of current input-line */
static size_t linesize; /* length of current input-line */
typedef struct
{
@ -290,7 +301,7 @@ save_line(void)
if (!must_save)
{
must_save = 1;
save_area.line_used = (cptr - line);
save_area.line_used = (size_t)(cptr - line);
}
}
@ -323,7 +334,7 @@ get_line(void)
if (must_save > 0)
{
save_area.line_data = TMALLOC(char, linesize);
save_area.line_used = (cptr - line);
save_area.line_used = (size_t)(cptr - line);
save_area.line_size = linesize;
NO_SPACE(save_area.line_data);
memcpy(save_area.line_data, line, linesize);
@ -335,7 +346,7 @@ get_line(void)
do
{
int c;
int i;
size_t i;
if (saw_eof || (c = getc(f)) == EOF)
{
@ -411,9 +422,8 @@ skip_comment(void)
{
char *s;
struct ainfo a;
a.a_lineno = lineno;
a.a_line = dup_line();
a.a_cptr = a.a_line + (cptr - line);
begin_ainfo(a, 0);
s = cptr + 2;
for (;;)
@ -421,7 +431,7 @@ skip_comment(void)
if (*s == '*' && s[1] == '/')
{
cptr = s + 2;
FREE(a.a_line);
end_ainfo(a);
return;
}
if (*s == '\n')
@ -523,6 +533,7 @@ keywords[] = {
{ "binary", NONASSOC },
{ "code", XCODE },
{ "debug", NONPOSIX_DEBUG },
{ "define", HACK_DEFINE },
#if defined(YYBTYACC)
{ "destructor", DESTRUCTOR },
#endif
@ -539,6 +550,7 @@ keywords[] = {
{ "locations", LOCATIONS },
#endif
{ "nonassoc", NONASSOC },
{ "nterm", TYPE },
{ "parse-param", PARSE_PARAM },
{ "pure-parser", PURE_PARSER },
{ "right", RIGHT },
@ -661,9 +673,8 @@ copy_string(int quote)
{
struct mstring *temp = msnew();
struct ainfo a;
a.a_lineno = lineno;
a.a_line = dup_line();
a.a_cptr = a.a_line + (cptr - line - 1);
begin_ainfo(a, 1);
for (;;)
{
@ -672,7 +683,7 @@ copy_string(int quote)
mputc(temp, c);
if (c == quote)
{
FREE(a.a_line);
end_ainfo(a);
return msdone(temp);
}
if (c == '\n')
@ -713,9 +724,8 @@ copy_comment(void)
else if (c == '*')
{
struct ainfo a;
a.a_lineno = lineno;
a.a_line = dup_line();
a.a_cptr = a.a_line + (cptr - line - 1);
begin_ainfo(a, 1);
mputc(temp, c);
++cptr;
@ -727,7 +737,7 @@ copy_comment(void)
{
mputc(temp, '/');
++cptr;
FREE(a.a_line);
end_ainfo(a);
return msdone(temp);
}
if (c == '\n')
@ -880,9 +890,8 @@ copy_text(void)
FILE *f = text_file;
int need_newline = 0;
struct ainfo a;
a.a_lineno = lineno;
a.a_line = dup_line();
a.a_cptr = a.a_line + (cptr - line - 2);
begin_ainfo(a, 2);
if (*cptr == '\n')
{
@ -932,7 +941,7 @@ copy_text(void)
if (need_newline)
putc('\n', f);
++cptr;
FREE(a.a_line);
end_ainfo(a);
return;
}
/* FALLTHRU */
@ -975,9 +984,10 @@ copy_union(void)
size_t filler_len = 0;
int in_prefix = 1;
a.a_lineno = lineno;
a.a_line = dup_line();
a.a_cptr = a.a_line + (cptr - line - 6);
prefix_buf[0] = '\0';
filler_buf[0] = '\0';
begin_ainfo(a, 6);
if (unionized)
over_unionized(cptr - 6);
@ -1059,7 +1069,7 @@ copy_union(void)
puts_both(" YYSTYPE;\n");
}
puts_both("#endif /* !YYSTYPE_IS_DECLARED */\n");
FREE(a.a_line);
end_ainfo(a);
return;
}
goto loop;
@ -1426,9 +1436,8 @@ get_literal(void)
char *s;
bucket *bp;
struct ainfo a;
a.a_lineno = lineno;
a.a_line = dup_line();
a.a_cptr = a.a_line + (cptr - line);
begin_ainfo(a, 0);
quote = *cptr++;
cinc = 0;
@ -1521,7 +1530,7 @@ get_literal(void)
}
cachec(c);
}
FREE(a.a_line);
end_ainfo(a);
n = cinc;
s = TMALLOC(char, n);
@ -1888,6 +1897,82 @@ declare_argtypes(bucket *bp)
}
#endif
static int
scan_blanks(void)
{
int c;
do
{
c = next_inline();
if (c == '\n')
{
++cptr;
return 0;
}
else if (c == ' ' || c == '\t')
++cptr;
else
break;
}
while (c == ' ' || c == '\t');
return 1;
}
static int
scan_ident(void)
{
int c;
cinc = 0;
for (c = *cptr; IS_IDENT(c); c = *++cptr)
cachec(c);
cachec(NUL);
return cinc;
}
static void
hack_defines(void)
{
struct ainfo a;
if (!scan_blanks())
return;
begin_ainfo(a, 0);
if (!scan_ident())
{
end_ainfo(a);
}
if (!strcmp(cache, "api.pure"))
{
end_ainfo(a);
scan_blanks();
begin_ainfo(a, 0);
scan_ident();
if (!strcmp(cache, "false"))
pure_parser = 0;
else if (!strcmp(cache, "true")
|| !strcmp(cache, "full")
|| *cache == 0)
pure_parser = 1;
else
unexpected_value(&a);
end_ainfo(a);
}
else
{
unexpected_value(&a);
}
while (next_inline() != '\n')
++cptr;
}
static void
declare_types(void)
{
@ -2046,6 +2131,10 @@ read_declarations(void)
tflag = 1;
break;
case HACK_DEFINE:
hack_defines();
break;
case POSIX_YACC:
/* noop for bison compatibility. byacc is already designed to be posix
* yacc compatible. */
@ -2129,9 +2218,7 @@ copy_args(int *alen)
char c, quote = 0;
struct ainfo a;
a.a_lineno = lineno;
a.a_line = dup_line();
a.a_cptr = a.a_line + (cptr - line - 1);
begin_ainfo(a, 1);
while ((c = *cptr++) != R_PAREN || depth || quote)
{
@ -2175,7 +2262,7 @@ copy_args(int *alen)
}
if (alen)
*alen = len;
FREE(a.a_line);
end_ainfo(a);
return msdone(s);
}
@ -2827,9 +2914,7 @@ copy_action(void)
Value_t *offsets = NULL, maxoffset;
bucket **rhs;
a.a_lineno = lineno;
a.a_line = dup_line();
a.a_cptr = a.a_line + (cptr - line);
begin_ainfo(a, 0);
if (last_was_action)
insert_empty_rule();
@ -3023,10 +3108,8 @@ copy_action(void)
{
if (!locations)
{
int l_lineno = lineno;
char *l_line = dup_line();
char *l_cptr = l_line + (cptr - line);
syntax_error(l_lineno, l_line, l_cptr);
dislocations_warning();
locations = 1;
}
if (cptr[1] == '$')
{
@ -3095,7 +3178,7 @@ copy_action(void)
goto loop;
}
end_case(f);
FREE(a.a_line);
end_ainfo(a);
if (maxoffset > 0)
FREE(offsets);
return;
@ -3115,7 +3198,7 @@ copy_action(void)
if (depth > 0)
goto loop;
end_case(f);
free(a.a_line);
end_ainfo(a);
if (maxoffset > 0)
FREE(offsets);
return;
@ -3157,7 +3240,7 @@ copy_action(void)
}
#endif
end_case(f);
free(a.a_line);
end_ainfo(a);
if (maxoffset > 0)
FREE(offsets);
return;
@ -3203,9 +3286,7 @@ get_code(struct ainfo *a, const char *loc)
else
syntax_error(lineno, line, cptr);
a->a_lineno = lineno;
a->a_line = dup_line();
a->a_cptr = a->a_line + (cptr - line);
begin_ainfo((*a), 0);
depth = 0;
loop:
@ -3243,10 +3324,8 @@ get_code(struct ainfo *a, const char *loc)
{
if (!locations)
{
int l_lineno = lineno;
char *l_line = dup_line();
char *l_cptr = l_line + (cptr - line);
syntax_error(l_lineno, l_line, l_cptr);
dislocations_warning();
locations = 1;
}
msprintf(code_mstr, "%s", loc);
cptr += 2;
@ -3311,7 +3390,7 @@ copy_initial_action(void)
struct ainfo a;
initial_action = get_code(&a, "yyloc");
free(a.a_line);
end_ainfo(a);
}
static void
@ -3393,7 +3472,7 @@ copy_destructor(void)
else
break;
}
free(a.a_line);
end_ainfo(a);
free(code_text);
}