Synchronize on NetBSD-CVS (2013/12/1 12:00:00 UTC)

- Fix for possible unset uid/gid in toproto
 - Fix for default mtree style
 - Update libelf
 - Importing libexecinfo
 - Resynchronize GCC, mpc, gmp, mpfr
 - build.sh: Replace params with show-params.
     This has been done as the make target has been renamed in the same
     way, while a new target named params has been added. This new
     target generates a file containing all the parameters, instead of
     printing it on the console.
 - Update test48 with new etc/services (Fix by Ben Gras <ben@minix3.org)
     get getservbyport() out of the inner loop

Change-Id: Ie6ad5226fa2621ff9f0dee8782ea48f9443d2091
This commit is contained in:
2013-12-06 12:04:52 +01:00
parent ff10274392
commit 84d9c625bf
4655 changed files with 379317 additions and 151059 deletions

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.43 2013/04/28 00:14:14 joerg Exp $
# $NetBSD: Makefile,v 1.45 2013/11/28 22:34:17 christos Exp $
.include <bsd.own.mk>
@@ -27,6 +27,9 @@ SUBDIR+= lutok kyua-testers kyua-cli kyua-atf-compat
.if (${MKLDAP} != "no")
SUBDIR+= openldap
.endif
.if (${MKLIBCXX} != "no")
SUBDIR+= libc++
.endif
.if (${MKLLVM} != "no")
SUBDIR+= llvm
.endif
@@ -34,4 +37,6 @@ SUBDIR+= llvm
SUBDIR+= pcc
.endif
SUBDIR+= nvi
.include <bsd.subdir.mk>

View File

@@ -1,5 +1,8 @@
# $NetBSD: Makefile.inc,v 1.1 2013/03/14 07:10:05 jmmv Exp $
#LSC: For Minix: Ensure NETBSDSRCDIR is set
.include <bsd.own.mk>
TOPDIR= ${NETBSDSRCDIR}/external/bsd/atf
SRCDIR= ${TOPDIR}/dist

View File

@@ -797,7 +797,7 @@ atf_error_t
atf_fs_mkdtemp(atf_fs_path_t *p)
{
atf_error_t err;
char *buf = NULL;
char *buf = NULL; /* MINIX: Complain in -O3 */
if (!check_umask(S_IRWXU, S_IRWXU)) {
err = invalid_umask_error(p, atf_fs_stat_dir_type, current_umask());
@@ -825,7 +825,7 @@ atf_error_t
atf_fs_mkstemp(atf_fs_path_t *p, int *fdout)
{
atf_error_t err;
char *buf = NULL;
char *buf = NULL; /* MINIX: Complain in -O3 */
int fd;
if (!check_umask(S_IRWXU, S_IRWXU)) {

View File

@@ -621,7 +621,7 @@ atf_process_exec_array(atf_process_status_t *s,
void (*prehook)(void))
{
atf_error_t err;
atf_process_child_t c = { .m_pid = 0, .m_stdout = 1, .m_stderr = 2 };
atf_process_child_t c = { .m_pid = 0, .m_stdout = 1, .m_stderr = 2 }; /* MINIX: Complain in -O3 */
struct exec_args ea = { prog, argv, prehook };
PRE(outsb == NULL ||

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.19 2013/03/14 07:10:06 jmmv Exp $
# $NetBSD: Makefile,v 1.20 2013/09/12 17:14:20 joerg Exp $
NOLINT= # defined
@@ -8,11 +8,6 @@ LIB= atf-c++
LIBISCXX= yes
LIBDPLIBS+= atf-c ${.CURDIR}/../libatf-c
.if ${HAVE_GCC} == 4
LIBDPLIBS+= stdc++ ${.CURDIR}/../../../../../gnu/lib/libstdc++-v3_4
.else
LIBDPLIBS+= stdc++ ${.CURDIR}/../../../../../external/gpl3/gcc/lib/libstdc++-v3
.endif
LIBDPLIBS+= m ${.CURDIR}/../../../../../lib/libm

View File

@@ -62,7 +62,7 @@
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the `unmount' function. */
/* #undef HAVE_UNMOUNT */
#define HAVE_UNMOUNT 1
/* Define to 1 if you have the `unsetenv' function. */
#define HAVE_UNSETENV 1

View File

@@ -1,4 +1,4 @@
-- Id: AUTHORS,v 1.1 2010/06/06 20:31:51 tom Exp
-- Id: AUTHORS,v 1.1 2010/06/06 20:31:51 tom Exp
-- vile:txtmode
-- This file is used by a script that collects contributor information and
-- resolves nicknames vs fullnames.

View File

@@ -1,3 +1,311 @@
2013-03-04 Thomas E. Dickey <tom@invisible-island.net>
* package/debian/changelog, VERSION, package/byacc.spec: bump
* aclocal.m4:
adapt tweak from Dave Becket to work around long-ago breakage in "new" autoconf.
* output.c:
fix bogus #include if "-i" is given but not "-d" (report by Richard Mitton).
also while testing that, found a case where the union_file is unused; added
a check for address that.
* test/ftp.output, test/ftp.tab.c, test/ftp.tab.h: regen
* test/ftp.y: fix most compiler warnings for "make check_make"
* test/calc1.tab.c: regen
* test/calc1.y: fix most compiler warnings for "make check_make"
* test/calc.tab.c, test/calc1.tab.c, test/calc2.tab.c, test/calc3.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c, test/quote_calc-s.tab.c, test/quote_calc.tab.c, test/quote_calc2-s.tab.c, test/quote_calc2.tab.c, test/quote_calc3-s.tab.c, test/quote_calc3.tab.c, test/quote_calc4-s.tab.c, test/quote_calc4.tab.c:
regen
* skeleton.c: quiet a gcc conversion-warning in yygrowstack()
* configure: regen
* aclocal.m4:
another fix for CF_GCC_VERSION to handle Debian's modification of gcc message.
2013-02-10 Thomas E. Dickey <tom@invisible-island.net>
* config.sub, config.guess: 2013-02-04
2012-10-03 Thomas E. Dickey <tom@invisible-island.net>
* package/debian/changelog, package/byacc.spec, VERSION: bump
* configure: regen
* configure.in: moved AC_PROG_CC_STDC call into CF_PROG_CC
* aclocal.m4:
moved AC_PROG_CC_STDC call into CF_PROG_CC and (for other uses than byacc)
the CF_PROG_CC macro provides the CF_ANSI_CC_REQD for the 2.13 flavor.
* aclocal.m4, configure.in:
Arian's change dropped my check for misused $CC variable - restore that with
alternate macro CF_PROG_CC.
2012-10-03 Adrian.Bunk
* aclocal.m4:
suggested patch: drop CF_ANSI_CC_REQD, CF_ANSI_CC_CHECK, CF_PROG_EXT since
they are not needed.
2012-10-03 Thomas E. Dickey <tom@invisible-island.net>
* aclocal.m4:
split-out CF_CC_ENV_FLAGS from CF_ANSI_CC_CHECK to avoid losing it in
Adrian's suggested changes.
* aclocal.m4:
CF_CLANG_COMPILER - check if the given compiler is really clang.
* aclocal.m4:
add check for clang to CF_GCC_WARNINGS. modify CF_GCC_WARNINGS to work around
old gcc warning: ncurses change to (try to) use gnatgcc exposed gnatgcc 2.8.1
on my Sarge system (versus 3.3.5 for the normal gcc). The 2.8.1's
pointer-arithmetic checks fell afoul of gcc's misuse of void* in string.h; work
around by excluding that check for pre-3.x compilers.
* aclocal.m4:
modify CF_GCC_ATTRIBUTES so that autoheader is able to see the definitions
provided by this macro. use AC_DEFINE_UNQUOTED() in CF_GCC_ATTRIBUTES rather
than appending to confdefs.h, since long-ago concern about the ability to
pass-through parameterized macros appears to be not a problem, testing with
2.13 and 2.52
2012-10-03 Adrian.Bunk
* aclocal.m4:
add parameter to AC_DEFINE_UNQUOTED() to allow it to be recognized by
autoheader, updated macros:
CF_CHECK_CACHE
CF_DISABLE_LEAKS
CF_MKSTEMP
CF_MIXEDCASE_FILENAMES
CF_NO_LEAKS_OPTION
2012-10-03 Thomas E. Dickey <tom@invisible-island.net>
* aclocal.m4:
move existence-check for mkstemp out of the AC_TRY_RUN, to help with
cross-compiles
2012-10-02 Thomas E. Dickey <tom@invisible-island.net>
* config_h.in:
Adrian Bunk request - replace this with the output from autoheader
2012-09-29 Adrian.Bunk
* configure.in:
suggested change: replace CF_ANSI_CC_REQD by AC_PROG_CC_STDC (since no
check is needed anymore for standard C compilers), drop AC_CONST (same
reason), modify AC_OUTPUT to rely upon template generated by autoheader.
bump requirement to autoconf 2.52.20011201 and drop check for CF_PROG_EXT
as being obsolete with autoconf 2.52x
* configure.in, main.c: drop check for atexit, because it is standard C
* makefile.in: add assignment for datarootdir variable.
2012-05-26 Thomas E. Dickey <tom@invisible-island.net>
* package/debian/changelog, package/byacc.spec, VERSION: bump
* reader.c:
some versions of gcc may warn that bp is not set in mark_symbol, e.g.,
if GCC_NORETURN is not handled; appease the compiler.
* reader.c:
use the declared types Assoc_t and Value_t in some places where compiler only
cared about char versus short.
* reader.c:
use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation
(no object change)
* defs.h:
add fallbacks for GCC_NORETURN and GCC_UNUSED to make it simpler for *BSD
packagers to build without configure script. Also remove duplicate declaration
of pure_parser variable (prompted by patch by Baptiste Daroussin).
Also define new TMALLOC and TREALLOC macros to simplify/replace MALLOC and
REALLOC macros.
* symtab.c:
use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation
(no object change)
2012-05-25 Thomas E. Dickey <tom@invisible-island.net>
* output.c, main.c, verbose.c, mkpar.c, lr0.c:
use TMALLOC() and TREALLOC() macros to simplify allocation/reallocation
(no object change)
2012-01-15 Thomas E. Dickey <tom@invisible-island.net>
* package/debian/copyright: bump
* test/run_make.sh: workaround for breakage due to GNU make 3.82
* test/run_make.sh:
tested with Solaris 10 (bison 1.875) and added scripting to exercise
the /usr/ccs/bin/yacc executable
* test/grammar.tab.c: regen
* test/grammar.y: modify to also build with Solaris yacc
* VERSION, package/debian/changelog, package/byacc.spec: bump
* test/calc1.output, test/calc1.tab.c: regen
* test/calc1.y:
undo the change made to appease bison, since it was only a warning.
* test/pure_calc.tab.c, test/pure_error.tab.c: regen
* test/run_make.sh: another fix for running from top-level directory
* makefile.in:
ensure that check_make rule depends on having byacc built.
* test/run_make.sh: fixes for building from parent directory
* test/pure_error.y, test/pure_calc.y: bison-fixes
* test/calc2.tab.c, test/calc3.tab.c, test/code_error.code.c, test/ftp.tab.c, test/pure_calc.tab.c, test/pure_error.tab.c:
regen
* test/calc2.y, test/calc3.y, test/code_error.y, test/ftp.y:
byacc already declares yyerror
* test/pure_error.y, test/pure_calc.y:
modified to help make the files build with bison
* test/run_make.sh:
supply a "%pure-parser" directive when bison needs it.
* test/code_calc.code.c: regen
* test/code_calc.y: modified to help make the files build with bison
* yacc.1:
in testing, found that %expect did not work as documented for bison.
do not recommend it for portable code.
* test/run_make.sh: workaround breakage in bison's %expect directive
* test/grammar.y: modified to help make the files build with bison
* test/calc1.output, test/calc1.tab.c, test/grammar.tab.c: regen
* test/calc1.y: quiet a spurious warning from bison 2.3
* test/calc1.tab.c: regen
* test/calc1.y: modified to help make the files build with bison
* yacc.1: comment on "-y" and "-P" options.
* yacc.1: comment on portability
* test/ftp.tab.c, test/quote_calc-s.tab.c, test/quote_calc.tab.c, test/quote_calc2-s.tab.c, test/quote_calc3-s.tab.c:
regen
* test/ftp.y: modified to help make the files build with bison
(bison's "-y" option is of no use in providing "yacc" compatibility)
* test/quote_calc2.tab.c, test/quote_calc3.tab.c, test/quote_calc4-s.tab.c, test/quote_calc4.tab.c:
regen
* test/code_calc.y, test/quote_calc2.y, test/quote_calc.y, test/quote_calc4.y, test/quote_calc3.y:
modified to help make the files build with bison
* test/calc.tab.c: regen
* test/calc.y: modified to help make the files build with bison
* test/error.tab.c: regen
* test/error.y: modified to help make the files build with bison
* test/calc2.tab.c, test/calc3.tab.c, test/code_error.code.c: regen
* test/run_make.sh:
check for older bisons which (2.3 for instance) do not support pure parsers
* test/code_error.y, test/calc3.y, test/calc2.y:
modified to help make the files build with bison
* test/run_test.sh: use $opt2 in filenames of the generated files
* test/quote_calc2-s.tab.c, test/quote_calc3-s.tab.c, test/quote_calc4-s.tab.c, test/quote_calc-s.tab.c, test/quote_calc.tab.c, test/quote_calc2.tab.c, test/quote_calc3.tab.c, test/quote_calc4.tab.c:
regen
2012-01-14 Thomas E. Dickey <tom@invisible-island.net>
* test/calc2.tab.c, test/code_calc.code.c, test/code_error.code.c, test/error.tab.c, test/ftp.tab.c, test/grammar.tab.c, test/calc.tab.c, test/calc1.tab.c:
regen
* output.c: Several changes:
a) add YYLEX_PARAM_TYPE, like YYPARSE_PARAM_TYPE, but for yylex.
b) modify definitions for YYLEX_DECL to be more like YYPARSE_DECL,
using YYLEX_PARAM_TYPE and YYLEX_PARAM.
c) add ifdef's around #define's for YYERROR_DECL and YYERROR_CALL,
to help with redefinitions.
* test/pure_calc.tab.c:
modified to help make the files build with bison
* test/run_make.sh:
start work on followup, to check if the generated files build with bison.
* test/pure_calc.y, test/pure_error.tab.c:
modified to help make the files build with bison
* test/calc3.tab.c: regen
* test/quote_calc-s.output, test/quote_calc-s.tab.c, test/quote_calc-s.tab.h, test/quote_calc2-s.output, test/quote_calc2-s.tab.c, test/quote_calc2-s.tab.h, test/quote_calc3-s.output, test/quote_calc3-s.tab.c, test/quote_calc3-s.tab.h, test/quote_calc4-s.output, test/quote_calc4-s.tab.c, test/quote_calc4-s.tab.h:
RCS_BASE
* test/run_test.sh: generate/test with "-s" option applied.
2012-01-13 Thomas E. Dickey <tom@invisible-island.net>
* package/debian/changelog, package/byacc.spec, VERSION: bump
* yacc.1: improve documentation of -s option
* yacc.1: note that yacc ignores -y
* main.c: add -s option to usage message.
* test/quote_calc3.output, test/quote_calc3.tab.c, test/quote_calc4.output, test/quote_calc4.tab.c, test/quote_calc4.tab.h, test/quote_calc3.y, test/quote_calc.tab.h, test/quote_calc.output, test/quote_calc.tab.c, test/quote_calc2.output, test/quote_calc2.tab.c, test/quote_calc2.tab.h, test/quote_calc3.tab.h, test/quote_calc4.y, test/quote_calc.y, test/quote_calc2.y:
RCS_BASE
* configure: regen
* aclocal.m4: resync with my-autoconf, i.e., fixes for CF_XOPEN_SOURCE
2011-12-19 Thomas E. Dickey <tom@invisible-island.net>
* package/debian/changelog, package/byacc.spec, VERSION: bump
* yacc.1, output.c, main.c, defs.h:
add "-s" option to suppress generating #define's based on string contents
in a %token statement. For instance
%token EQLS "Equals"
would generate
#define EQLS 256
#define Equals 257
Simply suppressing the second #define makes the behavior closer to yacc.
(report by Paulo Andrade).
2011-09-08 Thomas E. Dickey <tom@invisible-island.net>
* package/debian/changelog, package/byacc.spec, VERSION: bump

View File

@@ -1,4 +1,4 @@
-- Id: README,v 1.2 2004/03/28 17:24:53 tom Exp
-- Id: README,v 1.2 2004/03/28 17:24:53 tom Exp
The original README is below. I've updated this version of Berkeley Yacc
to make it ANSI C compliant - Thomas Dickey

View File

@@ -1 +1 @@
20110908
20130304

View File

@@ -1,7 +1,7 @@
dnl Id: aclocal.m4,v 1.18 2011/09/05 23:45:06 tom Exp
dnl Id: aclocal.m4,v 1.30 2013/03/05 01:13:39 tom Exp
dnl Macros for byacc configure script (Thomas E. Dickey)
dnl ---------------------------------------------------------------------------
dnl Copyright 2004-2009,2010 Thomas E. Dickey
dnl Copyright 2004-2012,2013 Thomas E. Dickey
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a
dnl copy of this software and associated documentation files (the
@@ -28,6 +28,32 @@ dnl sale, use or other dealings in this Software without prior written
dnl authorization.
dnl ---------------------------------------------------------------------------
dnl ---------------------------------------------------------------------------
dnl CF_ACVERSION_CHECK version: 4 updated: 2013/03/04 19:52:56
dnl ------------------
dnl Conditionally generate script according to whether we're using a given autoconf.
dnl
dnl $1 = version to compare against
dnl $2 = code to use if AC_ACVERSION is at least as high as $1.
dnl $3 = code to use if AC_ACVERSION is older than $1.
define([CF_ACVERSION_CHECK],
[
ifdef([AC_ACVERSION], ,[m4_copy([m4_PACKAGE_VERSION],[AC_ACVERSION])])dnl
ifdef([m4_version_compare],
[m4_if(m4_version_compare(m4_defn([AC_ACVERSION]), [$1]), -1, [$3], [$2])],
[CF_ACVERSION_COMPARE(
AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])),
AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_ACVERSION, [$2], [$3])])])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ACVERSION_COMPARE version: 3 updated: 2012/10/03 18:39:53
dnl --------------------
dnl CF_ACVERSION_COMPARE(MAJOR1, MINOR1, TERNARY1,
dnl MAJOR2, MINOR2, TERNARY2,
dnl PRINTABLE2, not FOUND, FOUND)
define([CF_ACVERSION_COMPARE],
[ifelse(builtin([eval], [$2 < $5]), 1,
[ifelse([$8], , ,[$8])],
[ifelse([$9], , ,[$9])])])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ADD_CFLAGS version: 10 updated: 2010/05/26 05:38:42
dnl -------------
dnl Copy non-preprocessor flags to $CFLAGS, preprocessor flags to $CPPFLAGS
@@ -114,97 +140,6 @@ fi
AC_SUBST(EXTRA_CPPFLAGS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ANSI_CC_CHECK version: 11 updated: 2011/07/01 19:47:45
dnl ----------------
dnl This was originally adapted from the macros 'fp_PROG_CC_STDC' and
dnl 'fp_C_PROTOTYPES' in the sharutils 4.2 distribution.
AC_DEFUN([CF_ANSI_CC_CHECK],
[
# This should have been defined by AC_PROG_CC
: ${CC:=cc}
# Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
# into CC. This will not help with broken scripts that wrap the compiler with
# options, but eliminates a more common category of user confusion.
AC_MSG_CHECKING(\$CC variable)
case "$CC" in #(vi
*[[\ \ ]]-[[IUD]]*)
AC_MSG_RESULT(broken)
AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
# humor him...
cf_flags=`echo "$CC" | sed -e 's/^[[^ ]]*[[ ]]//'`
CC=`echo "$CC" | sed -e 's/[[ ]].*//'`
CF_ADD_CFLAGS($cf_flags)
;;
*)
AC_MSG_RESULT(ok)
;;
esac
AC_CACHE_CHECK(for ${CC:-cc} option to accept ANSI C, cf_cv_ansi_cc,[
cf_cv_ansi_cc=no
cf_save_CFLAGS="$CFLAGS"
cf_save_CPPFLAGS="$CPPFLAGS"
# Don't try gcc -ansi; that turns off useful extensions and
# breaks some systems' header files.
# AIX -qlanglvl=ansi
# Ultrix and OSF/1 -std1
# HP-UX -Aa -D_HPUX_SOURCE
# SVR4 -Xc
# UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes)
for cf_arg in "-DCC_HAS_PROTOS" \
"" \
-qlanglvl=ansi \
-std1 \
-Ae \
"-Aa -D_HPUX_SOURCE" \
-Xc
do
CF_ADD_CFLAGS($cf_arg)
AC_TRY_COMPILE(
[
#ifndef CC_HAS_PROTOS
#if !defined(__STDC__) || (__STDC__ != 1)
choke me
#endif
#endif
],[
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};],
[cf_cv_ansi_cc="$cf_arg"; break])
done
CFLAGS="$cf_save_CFLAGS"
CPPFLAGS="$cf_save_CPPFLAGS"
])
if test "$cf_cv_ansi_cc" != "no"; then
if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
CF_ADD_CFLAGS($cf_cv_ansi_cc)
else
AC_DEFINE(CC_HAS_PROTOS)
fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ANSI_CC_REQD version: 4 updated: 2008/03/23 14:48:54
dnl ---------------
dnl For programs that must use an ANSI compiler, obtain compiler options that
dnl will make it recognize prototypes. We'll do preprocessor checks in other
dnl macros, since tools such as unproto can fake prototypes, but only part of
dnl the preprocessor.
AC_DEFUN([CF_ANSI_CC_REQD],
[AC_REQUIRE([CF_ANSI_CC_CHECK])
if test "$cf_cv_ansi_cc" = "no"; then
AC_MSG_ERROR(
[Your compiler does not appear to recognize prototypes.
You have the following choices:
a. adjust your compiler options
b. get an up-to-date compiler
c. use a wrapper such as unproto])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_ARG_DISABLE version: 3 updated: 1999/03/30 17:24:31
@@ -236,7 +171,33 @@ ifelse([$3],,[ :]dnl
])dnl
])])dnl
dnl ---------------------------------------------------------------------------
dnl CF_CHECK_CACHE version: 11 updated: 2008/03/23 14:45:59
dnl CF_CC_ENV_FLAGS version: 1 updated: 2012/10/03 05:25:49
dnl ---------------
dnl Check for user's environment-breakage by stuffing CFLAGS/CPPFLAGS content
dnl into CC. This will not help with broken scripts that wrap the compiler with
dnl options, but eliminates a more common category of user confusion.
AC_DEFUN([CF_CC_ENV_FLAGS],
[
# This should have been defined by AC_PROG_CC
: ${CC:=cc}
AC_MSG_CHECKING(\$CC variable)
case "$CC" in #(vi
*[[\ \ ]]-[[IUD]]*)
AC_MSG_RESULT(broken)
AC_MSG_WARN(your environment misuses the CC variable to hold CFLAGS/CPPFLAGS options)
# humor him...
cf_flags=`echo "$CC" | sed -e 's/^[[^ ]]*[[ ]]//'`
CC=`echo "$CC" | sed -e 's/[[ ]].*//'`
CF_ADD_CFLAGS($cf_flags)
;;
*)
AC_MSG_RESULT(ok)
;;
esac
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_CHECK_CACHE version: 12 updated: 2012/10/02 20:55:03
dnl --------------
dnl Check if we're accidentally using a cache from a different machine.
dnl Derive the system name, as a check for reusing the autoconf cache.
@@ -259,7 +220,7 @@ else
system_name="`(hostname) 2>/dev/null`"
fi
fi
test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name",[Define to the system name.])
AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
test -z "$system_name" && system_name="$cf_cv_system_name"
@@ -271,7 +232,40 @@ if test ".$system_name" != ".$cf_cv_system_name" ; then
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_DISABLE_ECHO version: 11 updated: 2009/12/13 13:16:57
dnl CF_CLANG_COMPILER version: 1 updated: 2012/06/16 14:55:39
dnl -----------------
dnl Check if the given compiler is really clang. clang's C driver defines
dnl __GNUC__ (fooling the configure script into setting $GCC to yes) but does
dnl not ignore some gcc options.
dnl
dnl This macro should be run "soon" after AC_PROG_CC or AC_PROG_CPLUSPLUS, to
dnl ensure that it is not mistaken for gcc/g++. It is normally invoked from
dnl the wrappers for gcc and g++ warnings.
dnl
dnl $1 = GCC (default) or GXX
dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
dnl $3 = CFLAGS (default) or CXXFLAGS
AC_DEFUN([CF_CLANG_COMPILER],[
ifelse([$2],,CLANG_COMPILER,[$2])=no
if test "$ifelse([$1],,[$1],GCC)" = yes ; then
AC_MSG_CHECKING(if this is really Clang ifelse([$1],GXX,C++,C) compiler)
cf_save_CFLAGS="$ifelse([$3],,CFLAGS,[$3])"
ifelse([$3],,CFLAGS,[$3])="$ifelse([$3],,CFLAGS,[$3]) -Qunused-arguments"
AC_TRY_COMPILE([],[
#ifdef __clang__
#else
make an error
#endif
],[ifelse([$2],,CLANG_COMPILER,[$2])=yes
cf_save_CFLAGS="$cf_save_CFLAGS -Qunused-arguments"
],[])
ifelse([$3],,CFLAGS,[$3])="$cf_save_CFLAGS"
AC_MSG_RESULT($ifelse([$2],,CLANG_COMPILER,[$2]))
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_DISABLE_ECHO version: 12 updated: 2012/10/06 16:30:28
dnl ---------------
dnl You can always use "make -n" to see the actual options, but it's hard to
dnl pick out/analyze warning messages when the compile-line is long.
@@ -286,7 +280,7 @@ dnl
AC_DEFUN([CF_DISABLE_ECHO],[
AC_MSG_CHECKING(if you want to see long compiling messages)
CF_ARG_DISABLE(echo,
[ --disable-echo display "compiling" commands],
[ --disable-echo do not display "compiling" commands],
[
ECHO_LT='--silent'
ECHO_LD='@echo linking [$]@;'
@@ -308,7 +302,7 @@ AC_SUBST(SHOW_CC)
AC_SUBST(ECHO_CC)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_DISABLE_LEAKS version: 6 updated: 2010/07/23 04:14:32
dnl CF_DISABLE_LEAKS version: 7 updated: 2012/10/02 20:55:03
dnl ----------------
dnl Combine no-leak checks with the libraries or tools that are used for the
dnl checks.
@@ -326,12 +320,12 @@ AC_ARG_ENABLE(leaks,
AC_MSG_RESULT($with_no_leaks)
if test "$with_no_leaks" = yes ; then
AC_DEFINE(NO_LEAKS)
AC_DEFINE(YY_NO_LEAKS)
AC_DEFINE(NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
AC_DEFINE(YY_NO_LEAKS,1,[Define to 1 if you want to perform memory-leak testing.])
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_GCC_ATTRIBUTES version: 14 updated: 2010/10/23 15:52:32
dnl CF_GCC_ATTRIBUTES version: 16 updated: 2012/10/02 20:55:03
dnl -----------------
dnl Test for availability of useful gcc __attribute__ directives to quiet
dnl compiler warnings. Though useful, not all are supported -- and contrary
@@ -409,27 +403,27 @@ EOF
test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
cat conftest.h >>confdefs.h
case $cf_attribute in #(vi
noreturn) #(vi
AC_DEFINE_UNQUOTED(GCC_NORETURN,$cf_directive,[Define to noreturn-attribute for gcc])
;;
printf) #(vi
if test "$cf_printf_attribute" = no ; then
cat >>confdefs.h <<EOF
#define GCC_PRINTFLIKE(fmt,var) /* nothing */
EOF
else
cat >>confdefs.h <<EOF
#define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
EOF
cf_value='/* nothing */'
if test "$cf_printf_attribute" != no ; then
cf_value='__attribute__((format(printf,fmt,var)))'
AC_DEFINE(GCC_PRINTF,1,[Define to 1 if the compiler supports gcc-like printf attribute.])
fi
AC_DEFINE_UNQUOTED(GCC_PRINTFLIKE(fmt,var),$cf_value,[Define to printf-attribute for gcc])
;;
scanf) #(vi
if test "$cf_scanf_attribute" = no ; then
cat >>confdefs.h <<EOF
#define GCC_SCANFLIKE(fmt,var) /* nothing */
EOF
else
cat >>confdefs.h <<EOF
#define GCC_SCANFLIKE(fmt,var) __attribute__((format(scanf,fmt,var)))
EOF
cf_value='/* nothing */'
if test "$cf_scanf_attribute" != no ; then
cf_value='__attribute__((format(scanf,fmt,var)))'
AC_DEFINE(GCC_SCANF,1,[Define to 1 if the compiler supports gcc-like scanf attribute.])
fi
AC_DEFINE_UNQUOTED(GCC_SCANFLIKE(fmt,var),$cf_value,[Define to sscanf-attribute for gcc])
;;
unused) #(vi
AC_DEFINE_UNQUOTED(GCC_UNUSED,$cf_directive,[Define to unused-attribute for gcc])
;;
esac
fi
@@ -441,7 +435,7 @@ rm -rf conftest*
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_GCC_VERSION version: 5 updated: 2010/04/24 11:02:31
dnl CF_GCC_VERSION version: 7 updated: 2012/10/18 06:46:33
dnl --------------
dnl Find version of gcc
AC_DEFUN([CF_GCC_VERSION],[
@@ -449,13 +443,13 @@ 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/^[[^0-9.]]*//' -e 's/[[^0-9.]].*//'`"
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.]].*//'`"
test -z "$GCC_VERSION" && GCC_VERSION=unknown
AC_MSG_RESULT($GCC_VERSION)
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_GCC_WARNINGS version: 27 updated: 2010/10/23 15:52:32
dnl CF_GCC_WARNINGS version: 29 updated: 2012/06/16 14:55:39
dnl ---------------
dnl Check if the compiler supports useful warning options. There's a few that
dnl we don't use, simply because they're too noisy:
@@ -478,6 +472,7 @@ AC_DEFUN([CF_GCC_WARNINGS],
[
AC_REQUIRE([CF_GCC_VERSION])
CF_INTEL_COMPILER(GCC,INTEL_COMPILER,CFLAGS)
CF_CLANG_COMPILER(GCC,CLANG_COMPILER,CFLAGS)
cat > conftest.$ac_ext <<EOF
#line __oline__ "${as_me:-configure}"
@@ -553,6 +548,13 @@ then
continue;;
esac
;;
Wpointer-arith) #(vi
case $GCC_VERSION in
[[12]].*)
CF_VERBOSE(feature is broken in gcc $GCC_VERSION)
continue;;
esac
;;
esac
EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
fi
@@ -594,7 +596,7 @@ make an error
test "$cf_cv_gnu_source" = yes && CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_INTEL_COMPILER version: 4 updated: 2010/05/26 05:38:42
dnl CF_INTEL_COMPILER version: 5 updated: 2013/02/10 10:41:05
dnl -----------------
dnl Check if the given compiler is really the Intel compiler for Linux. It
dnl tries to imitate gcc, but does not return an error when it finds a mismatch
@@ -608,6 +610,7 @@ dnl $1 = GCC (default) or GXX
dnl $2 = INTEL_COMPILER (default) or INTEL_CPLUSPLUS
dnl $3 = CFLAGS (default) or CXXFLAGS
AC_DEFUN([CF_INTEL_COMPILER],[
AC_REQUIRE([AC_CANONICAL_HOST])
ifelse([$2],,INTEL_COMPILER,[$2])=no
if test "$ifelse([$1],,[$1],GCC)" = yes ; then
@@ -668,7 +671,7 @@ AC_SUBST(MAKE_UPPER_TAGS)
AC_SUBST(MAKE_LOWER_TAGS)
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_MIXEDCASE_FILENAMES version: 3 updated: 2003/09/20 17:07:55
dnl CF_MIXEDCASE_FILENAMES version: 4 updated: 2012/10/02 20:55:03
dnl ----------------------
dnl Check if the file-system supports mixed-case filenames. If we're able to
dnl create a lowercase name and see it as uppercase, it doesn't support that.
@@ -695,10 +698,10 @@ else
rm -f conftest CONFTEST
fi
])
test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES)
test "$cf_cv_mixedcase" = yes && AC_DEFINE(MIXEDCASE_FILENAMES,1,[Define to 1 if filesystem supports mixed-case filenames.])
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_MKSTEMP version: 7 updated: 2010/08/14 18:25:37
dnl CF_MKSTEMP version: 9 updated: 2012/10/03 04:34:49
dnl ----------
dnl Check for a working mkstemp. This creates two files, checks that they are
dnl successfully created and distinct (AmigaOS apparently fails on the last).
@@ -740,11 +743,13 @@ int main()
}
],[cf_cv_func_mkstemp=yes
],[cf_cv_func_mkstemp=no
],[AC_CHECK_FUNC(mkstemp)
])
],[cf_cv_func_mkstemp=maybe])
])
if test "x$cf_cv_func_mkstemp" = xmaybe ; then
AC_CHECK_FUNC(mkstemp)
fi
if test "x$cf_cv_func_mkstemp" = xyes || test "x$ac_cv_func_mkstemp" = xyes ; then
AC_DEFINE(HAVE_MKSTEMP)
AC_DEFINE(HAVE_MKSTEMP,1,[Define to 1 if mkstemp() is available and working.])
fi
])dnl
dnl ---------------------------------------------------------------------------
@@ -756,14 +761,14 @@ AC_DEFUN([CF_MSG_LOG],[
echo "${as_me:-configure}:__oline__: testing $* ..." 1>&AC_FD_CC
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_NO_LEAKS_OPTION version: 4 updated: 2006/12/16 14:24:05
dnl CF_NO_LEAKS_OPTION version: 5 updated: 2012/10/02 20:55:03
dnl ------------------
dnl see CF_WITH_NO_LEAKS
AC_DEFUN([CF_NO_LEAKS_OPTION],[
AC_MSG_CHECKING(if you want to use $1 for testing)
AC_ARG_WITH($1,
[$2],
[AC_DEFINE($3)ifelse([$4],,[
[AC_DEFINE_UNQUOTED($3,1,"Define to 1 if you want to use $1 for testing.")ifelse([$4],,[
$4
])
: ${with_cflags:=-g}
@@ -858,29 +863,17 @@ fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PROG_EXT version: 10 updated: 2004/01/03 19:28:18
dnl -----------
dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
AC_DEFUN([CF_PROG_EXT],
[
AC_REQUIRE([CF_CHECK_CACHE])
case $cf_cv_system_name in
os2*)
CFLAGS="$CFLAGS -Zmt"
CPPFLAGS="$CPPFLAGS -D__ST_MT_ERRNO__"
CXXFLAGS="$CXXFLAGS -Zmt"
# autoconf's macro sets -Zexe and suffix both, which conflict:w
LDFLAGS="$LDFLAGS -Zmt -Zcrtdll"
ac_cv_exeext=.exe
;;
esac
AC_EXEEXT
AC_OBJEXT
PROG_EXT="$EXEEXT"
AC_SUBST(PROG_EXT)
test -n "$PROG_EXT" && AC_DEFINE_UNQUOTED(PROG_EXT,"$PROG_EXT")
dnl CF_PROG_CC version: 3 updated: 2012/10/06 15:31:55
dnl ----------
dnl standard check for CC, plus followup sanity checks
dnl $1 = optional parameter to pass to AC_PROG_CC to specify compiler name
AC_DEFUN([CF_PROG_CC],[
ifelse($1,,[AC_PROG_CC],[AC_PROG_CC($1)])
CF_GCC_VERSION
CF_ACVERSION_CHECK(2.52,
[AC_PROG_CC_STDC],
[CF_ANSI_CC_REQD])
CF_CC_ENV_FLAGS
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_PROG_LINT version: 2 updated: 2009/08/12 04:43:14
@@ -908,6 +901,45 @@ $1=`echo "$2" | \
-e 's/-[[UD]]'"$3"'\(=[[^ ]]*\)\?[$]//g'`
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_TRY_XOPEN_SOURCE version: 1 updated: 2011/10/30 17:09:50
dnl -------------------
dnl If _XOPEN_SOURCE is not defined in the compile environment, check if we
dnl can define it successfully.
AC_DEFUN([CF_TRY_XOPEN_SOURCE],[
AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
AC_TRY_COMPILE([
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
],[
#ifndef _XOPEN_SOURCE
make an error
#endif],
[cf_cv_xopen_source=no],
[cf_save="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
AC_TRY_COMPILE([
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
],[
#ifdef _XOPEN_SOURCE
make an error
#endif],
[cf_cv_xopen_source=no],
[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
CPPFLAGS="$cf_save"
])
])
if test "$cf_cv_xopen_source" != no ; then
CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
CF_ADD_CFLAGS($cf_temp_xopen_source)
fi
])
dnl ---------------------------------------------------------------------------
dnl CF_UPPER version: 5 updated: 2001/01/29 23:40:59
dnl --------
dnl Make an uppercase version of a variable
@@ -986,7 +1018,7 @@ fi
fi
])dnl
dnl ---------------------------------------------------------------------------
dnl CF_XOPEN_SOURCE version: 37 updated: 2011/08/06 20:32:05
dnl CF_XOPEN_SOURCE version: 43 updated: 2013/02/10 10:41:05
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,
@@ -996,6 +1028,7 @@ dnl Parameters:
dnl $1 is the nominal value for _XOPEN_SOURCE
dnl $2 is the nominal value for _POSIX_C_SOURCE
AC_DEFUN([CF_XOPEN_SOURCE],[
AC_REQUIRE([AC_CANONICAL_HOST])
cf_XOPEN_SOURCE=ifelse([$1],,500,[$1])
cf_POSIX_C_SOURCE=ifelse([$2],,199506L,[$2])
@@ -1013,6 +1046,7 @@ darwin[[0-8]].*) #(vi
;;
darwin*) #(vi
cf_xopen_source="-D_DARWIN_C_SOURCE"
cf_XOPEN_SOURCE=
;;
freebsd*|dragonfly*) #(vi
# 5.x headers associate
@@ -1030,16 +1064,24 @@ hpux*) #(vi
;;
irix[[56]].*) #(vi
cf_xopen_source="-D_SGI_SOURCE"
cf_XOPEN_SOURCE=
;;
linux*|gnu*|mint*|k*bsd*-gnu) #(vi
CF_GNU_SOURCE
;;
mirbsd*) #(vi
# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <arpa/inet.h>
# setting _XOPEN_SOURCE or _POSIX_SOURCE breaks <sys/select.h> and other headers which use u_int / u_short types
cf_XOPEN_SOURCE=
CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
;;
netbsd*) #(vi
cf_xopen_source="-D_NETBSD_SOURCE" # setting _XOPEN_SOURCE breaks IPv6 for lynx on NetBSD 1.6, breaks xterm, is not needed for ncursesw
;;
openbsd[[4-9]]*) #(vi
# setting _XOPEN_SOURCE lower than 500 breaks g++ compile with wchar.h, needed for ncursesw
cf_xopen_source="-D_BSD_SOURCE"
cf_XOPEN_SOURCE=600
;;
openbsd*) #(vi
# setting _XOPEN_SOURCE breaks xterm on OpenBSD 2.8, is not needed for ncursesw
;;
@@ -1052,36 +1094,11 @@ nto-qnx*) #(vi
sco*) #(vi
# setting _XOPEN_SOURCE breaks Lynx on SCO Unix / OpenServer
;;
solaris2.1[[0-9]]) #(vi
cf_xopen_source="-D__EXTENSIONS__ -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
;;
solaris2.[[1-9]]) #(vi
solaris2.*) #(vi
cf_xopen_source="-D__EXTENSIONS__"
;;
*)
AC_CACHE_CHECK(if we should define _XOPEN_SOURCE,cf_cv_xopen_source,[
AC_TRY_COMPILE([#include <sys/types.h>],[
#ifndef _XOPEN_SOURCE
make an error
#endif],
[cf_cv_xopen_source=no],
[cf_save="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=$cf_XOPEN_SOURCE"
AC_TRY_COMPILE([#include <sys/types.h>],[
#ifdef _XOPEN_SOURCE
make an error
#endif],
[cf_cv_xopen_source=no],
[cf_cv_xopen_source=$cf_XOPEN_SOURCE])
CPPFLAGS="$cf_save"
])
])
if test "$cf_cv_xopen_source" != no ; then
CF_REMOVE_DEFINE(CFLAGS,$CFLAGS,_XOPEN_SOURCE)
CF_REMOVE_DEFINE(CPPFLAGS,$CPPFLAGS,_XOPEN_SOURCE)
cf_temp_xopen_source="-D_XOPEN_SOURCE=$cf_cv_xopen_source"
CF_ADD_CFLAGS($cf_temp_xopen_source)
fi
CF_TRY_XOPEN_SOURCE
CF_POSIX_C_SOURCE($cf_POSIX_C_SOURCE)
;;
esac
@@ -1089,4 +1106,33 @@ esac
if test -n "$cf_xopen_source" ; then
CF_ADD_CFLAGS($cf_xopen_source)
fi
dnl In anything but the default case, we may have system-specific setting
dnl which is still not guaranteed to provide all of the entrypoints that
dnl _XOPEN_SOURCE would yield.
if test -n "$cf_XOPEN_SOURCE" && test -z "$cf_cv_xopen_source" ; then
AC_MSG_CHECKING(if _XOPEN_SOURCE really is set)
AC_TRY_COMPILE([#include <stdlib.h>],[
#ifndef _XOPEN_SOURCE
make an error
#endif],
[cf_XOPEN_SOURCE_set=yes],
[cf_XOPEN_SOURCE_set=no])
AC_MSG_RESULT($cf_XOPEN_SOURCE_set)
if test $cf_XOPEN_SOURCE_set = yes
then
AC_TRY_COMPILE([#include <stdlib.h>],[
#if (_XOPEN_SOURCE - 0) < $cf_XOPEN_SOURCE
make an error
#endif],
[cf_XOPEN_SOURCE_set_ok=yes],
[cf_XOPEN_SOURCE_set_ok=no])
if test $cf_XOPEN_SOURCE_set_ok = no
then
AC_MSG_WARN(_XOPEN_SOURCE is lower than requested)
fi
else
CF_TRY_XOPEN_SOURCE
fi
fi
])

View File

@@ -1,11 +1,11 @@
/* $NetBSD: closure.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* $NetBSD: closure.c,v 1.7 2013/04/06 14:52:24 christos Exp $ */
/* Id: closure.c,v 1.9 2010/06/09 08:21:47 tom Exp */
/* Id: closure.c,v 1.9 2010/06/09 08:21:47 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: closure.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: closure.c,v 1.7 2013/04/06 14:52:24 christos Exp $");
Value_t *itemset;
Value_t *itemsetend;

View File

@@ -1,14 +1,12 @@
#! /bin/sh
# Attempt to guess a canonical system name.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2911 Free Software Foundation, Inc.
# Copyright 1992-2013 Free Software Foundation, Inc.
timestamp='2011-01-01'
timestamp='2013-02-04'
# This file 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 2 of the License, or
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
@@ -17,26 +15,22 @@ timestamp='2011-01-01'
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Per Bothner. Please send patches (context
# diff format) to <config-patches@gnu.org> and include a ChangeLog
# entry.
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
# exits with 0. Otherwise, it exits with 1.
# Originally written by Per Bothner.
#
# You can get the latest version of this script from:
# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
#
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
me=`echo "$0" | sed -e 's,.*/,,'`
@@ -56,9 +50,7 @@ version="\
GNU config.guess ($timestamp)
Originally written by Per Bothner.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Copyright 1992-2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -145,7 +137,7 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:NetBSD:*:*)
# NetBSD (nbsd) targets should (where applicable) match one or
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
# *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
# switched to ELF, *-*-netbsd* would select the old
# object file format. This provides both forward
@@ -202,6 +194,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
echo "${machine}-${os}${release}"
exit ;;
*:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
exit ;;
*:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
@@ -220,10 +216,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
exit ;;
alpha:OSF1:*:*)
case $UNAME_RELEASE in
*4.0)
*4.0)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
;;
*5.*)
*5.*)
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
;;
esac
@@ -304,7 +300,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit ;;
arm:riscos:*:*|arm:RISCOS:*:*)
arm*:riscos:*:*|arm*:RISCOS:*:*)
echo arm-unknown-riscos
exit ;;
SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
@@ -600,50 +596,50 @@ EOF
sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
case "${sc_cpu_version}" in
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
532) # CPU_PA_RISC2_0
case "${sc_kernel_bits}" in
32) HP_ARCH="hppa2.0n" ;;
64) HP_ARCH="hppa2.0w" ;;
'') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
esac ;;
esac
esac ;;
esac
fi
if [ "${HP_ARCH}" = "" ]; then
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
sed 's/^ //' << EOF >$dummy.c
#define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
#define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
int main ()
{
#if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS);
#endif
long cpu = sysconf (_SC_CPU_VERSION);
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
switch (cpu)
{
case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
case CPU_PA_RISC2_0:
#if defined(_SC_KERNEL_BITS)
switch (bits)
{
case 64: puts ("hppa2.0w"); break;
case 32: puts ("hppa2.0n"); break;
default: puts ("hppa2.0"); break;
} break;
#else /* !defined(_SC_KERNEL_BITS) */
puts ("hppa2.0"); break;
#endif
default: puts ("hppa1.0"); break;
}
exit (0);
}
EOF
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
test -z "$HP_ARCH" && HP_ARCH=hppa
@@ -792,21 +788,26 @@ EOF
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit ;;
*:FreeBSD:*:*)
case ${UNAME_MACHINE} in
pc98)
echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
UNAME_PROCESSOR=`/usr/bin/uname -p`
case ${UNAME_PROCESSOR} in
amd64)
echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
*)
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
esac
exit ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
exit ;;
*:MINGW64*:*)
echo ${UNAME_MACHINE}-pc-mingw64
exit ;;
*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
exit ;;
i*:MSYS*:*)
echo ${UNAME_MACHINE}-pc-msys
exit ;;
i*:windows32*:*)
# uname -m includes "-pc" on this system.
echo ${UNAME_MACHINE}-mingw32
@@ -859,17 +860,24 @@ EOF
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
exit ;;
i*86:Minix:*:*)
echo ${UNAME_MACHINE}-pc-minix
echo ${UNAME_MACHINE}-elf32-minix # LSC, for Minix, should help
exit ;;
aarch64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
EV5) UNAME_MACHINE=alphaev5 ;;
EV56) UNAME_MACHINE=alphaev56 ;;
PCA56) UNAME_MACHINE=alphapca56 ;;
PCA57) UNAME_MACHINE=alphapca56 ;;
EV6) UNAME_MACHINE=alphaev6 ;;
EV67) UNAME_MACHINE=alphaev67 ;;
EV68*) UNAME_MACHINE=alphaev68 ;;
esac
objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
@@ -877,30 +885,39 @@ EOF
exit ;;
arm*:Linux:*:*)
eval $set_cc_for_build
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null | \
grep -q __ARM_EABI__
if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_EABI__
then
echo ${UNAME_MACHINE}-unknown-linux-gnu
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
| grep -q __ARM_PCS_VFP
then
echo ${UNAME_MACHINE}-unknown-linux-gnueabi
else
echo ${UNAME_MACHINE}-unknown-linux-gnueabihf
fi
fi
exit ;;
avr32*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
cris:Linux:*:*)
echo cris-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-gnu
exit ;;
crisv32:Linux:*:*)
echo crisv32-axis-linux-gnu
echo ${UNAME_MACHINE}-axis-linux-gnu
exit ;;
frv:Linux:*:*)
echo frv-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
hexagon:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
i*86:Linux:*:*)
LIBC=gnu
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
sed 's/^ //' << EOF >$dummy.c
#ifdef __dietlibc__
LIBC=dietlibc
#endif
@@ -937,7 +954,7 @@ EOF
test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
;;
or32:Linux:*:*)
echo or32-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
padre:Linux:*:*)
echo sparc-unknown-linux-gnu
@@ -972,13 +989,13 @@ EOF
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
tile*:Linux:*:*)
echo ${UNAME_MACHINE}-tilera-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
vax:Linux:*:*)
echo ${UNAME_MACHINE}-dec-linux-gnu
exit ;;
x86_64:Linux:*:*)
echo x86_64-unknown-linux-gnu
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
xtensa*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
@@ -1096,7 +1113,7 @@ EOF
&& { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
&& { echo i486-ncr-sysv4; exit; } ;;
&& { echo i486-ncr-sysv4; exit; } ;;
NCR*:*:4.2:* | MPRAS*:*:4.2:*)
OS_REL='.3'
test -r /etc/.relid \
@@ -1139,8 +1156,8 @@ EOF
echo ns32k-sni-sysv
fi
exit ;;
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
# says <Richard.M.Bartel@ccMail.Census.GOV>
echo i586-unisys-sysv4
exit ;;
*:UNIX_System_V:4*:FTX*)
@@ -1168,9 +1185,9 @@ EOF
exit ;;
R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
if [ -d /usr/nec ]; then
echo mips-nec-sysv${UNAME_RELEASE}
echo mips-nec-sysv${UNAME_RELEASE}
else
echo mips-unknown-sysv${UNAME_RELEASE}
echo mips-unknown-sysv${UNAME_RELEASE}
fi
exit ;;
BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
@@ -1185,6 +1202,9 @@ EOF
BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
echo i586-pc-haiku
exit ;;
x86_64:Haiku:*:*)
echo x86_64-unknown-haiku
exit ;;
SX-4:SUPER-UX:*:*)
echo sx4-nec-superux${UNAME_RELEASE}
exit ;;
@@ -1215,12 +1235,12 @@ EOF
i386)
eval $set_cc_for_build
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_64BIT_ARCH >/dev/null
then
UNAME_PROCESSOR="x86_64"
fi
fi ;;
unknown) UNAME_PROCESSOR=powerpc ;;
esac
@@ -1229,8 +1249,8 @@ EOF
*:procnto*:*:* | *:QNX:[0123456789]*:*)
UNAME_PROCESSOR=`uname -p`
if test "$UNAME_PROCESSOR" = "x86"; then
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
UNAME_PROCESSOR=i386
UNAME_MACHINE=pc
fi
echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
exit ;;
@@ -1240,7 +1260,7 @@ EOF
NEO-?:NONSTOP_KERNEL:*:*)
echo neo-tandem-nsk${UNAME_RELEASE}
exit ;;
NSE-?:NONSTOP_KERNEL:*:*)
NSE-*:NONSTOP_KERNEL:*:*)
echo nse-tandem-nsk${UNAME_RELEASE}
exit ;;
NSR-?:NONSTOP_KERNEL:*:*)
@@ -1309,11 +1329,11 @@ EOF
i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros
exit ;;
x86_64:VMkernel:*:*)
echo ${UNAME_MACHINE}-unknown-esx
exit ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
eval $set_cc_for_build
cat >$dummy.c <<EOF
#ifdef _SEQUENT_
@@ -1331,11 +1351,11 @@ main ()
#include <sys/param.h>
printf ("m68k-sony-newsos%s\n",
#ifdef NEWSOS4
"4"
"4"
#else
""
""
#endif
); exit (0);
); exit (0);
#endif
#endif

View File

@@ -1,38 +1,31 @@
#! /bin/sh
# Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
# 2011 Free Software Foundation, Inc.
# Copyright 1992-2013 Free Software Foundation, Inc.
timestamp='2011-04-01'
timestamp='2013-02-04'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
#
# This file 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 2 of the License, or
# This file 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 of the License, 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 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.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
# along with this program; if not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# the same distribution terms that you use for the rest of that
# program. This Exception is an additional permission under section 7
# of the GNU General Public License, version 3 ("GPLv3").
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted GNU ChangeLog entry.
# Please send patches with a ChangeLog entry to config-patches@gnu.org.
#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
@@ -75,9 +68,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
Copyright 1992-2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -125,13 +116,17 @@ esac
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
knetbsd*-gnu* | netbsd*-gnu* | \
kopensolaris*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
android-linux)
os=-linux-android
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
;;
*)
basic_machine=`echo $1 | sed 's/-[^-]*$//'`
if [ $basic_machine != $1 ]
@@ -154,7 +149,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis | -knuth | -cray | -microblaze)
-apple | -axis | -knuth | -cray | -microblaze*)
os=
basic_machine=$1
;;
@@ -223,6 +218,12 @@ case $os in
-isc*)
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-lynx*178)
os=-lynxos178
;;
-lynx*5)
os=-lynxos5
;;
-lynx*)
os=-lynxos
;;
@@ -247,20 +248,27 @@ case $basic_machine in
# Some are omitted here because they have special meanings below.
1750a | 580 \
| a29k \
| aarch64 | aarch64_be \
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
| arc \
| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
| avr | avr32 \
| be32 | be64 \
| bfin \
| c4x | clipper \
| d10v | d30v | dlx | dsp16xx \
| epiphany \
| fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| hexagon \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| le32 | le64 \
| lm32 \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep | metag \
| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@@ -278,20 +286,21 @@ case $basic_machine in
| mipsisa64r2 | mipsisa64r2el \
| mipsisa64sb1 | mipsisa64sb1el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipsr5900 | mipsr5900el \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| moxie \
| mt \
| msp430 \
| nds32 | nds32le | nds32be \
| nios | nios2 \
| nios | nios2 | nios2eb | nios2el \
| ns16k | ns32k \
| open8 \
| or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle \
| pyramid \
| rx \
| rl78 | rx \
| score \
| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \
@@ -300,7 +309,7 @@ case $basic_machine in
| spu \
| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
| ubicom32 \
| v850 | v850e \
| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
| we32k \
| x86 | xc16x | xstormy16 | xtensa \
| z8k | z80)
@@ -315,8 +324,7 @@ case $basic_machine in
c6x)
basic_machine=tic6x-unknown
;;
m6811 | m68hc11 | m6812 | m68hc12 | picochip)
# Motorola 68HC11/12.
m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
basic_machine=$basic_machine-unknown
os=-none
;;
@@ -325,21 +333,28 @@ case $basic_machine in
ms1)
basic_machine=mt-unknown
;;
strongarm | thumb | xscale)
basic_machine=arm-unknown
;;
xgate)
basic_machine=$basic_machine-unknown
os=-none
;;
xscaleeb)
basic_machine=armeb-unknown
;;
xscaleel)
basic_machine=armel-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
i*86 | x86_64)
basic_machine=$basic_machine-pc
;;
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
*-*-*)
echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
@@ -348,11 +363,13 @@ case $basic_machine in
# Recognize the basic CPU types with company name.
580-* \
| a29k-* \
| aarch64-* | aarch64_be-* \
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* | avr32-* \
| be32-* | be64-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* \
| clipper-* | craynv-* | cydra-* \
@@ -361,12 +378,15 @@ case $basic_machine in
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| hexagon-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| le32-* | le64-* \
| lm32-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \
| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
| microblaze-* | microblazeel-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
@@ -384,19 +404,20 @@ case $basic_machine in
| mipsisa64r2-* | mipsisa64r2el-* \
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipsr5900-* | mipsr5900el-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| nds32-* | nds32le-* | nds32be-* \
| nios-* | nios2-* \
| nios-* | nios2-* | nios2eb-* | nios2el-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| open8-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
| pyramid-* \
| romp-* | rs6000-* | rx-* \
| rl78-* | romp-* | rs6000-* | rx-* \
| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
@@ -404,10 +425,11 @@ case $basic_machine in
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
| tahoe-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tile-* | tilegx-* \
| tile*-* \
| tron-* \
| ubicom32-* \
| v850-* | v850e-* | vax-* \
| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
| vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* \
| xstormy16-* | xtensa*-* \
@@ -707,7 +729,6 @@ case $basic_machine in
i370-ibm* | ibm*)
basic_machine=i370-ibm
;;
# I'm not sure what "Sysv32" means. Should this be sysv3.2?
i*86v32)
basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
os=-sysv32
@@ -765,9 +786,13 @@ case $basic_machine in
basic_machine=ns32k-utek
os=-sysv
;;
microblaze)
microblaze*)
basic_machine=microblaze-xilinx
;;
mingw64)
basic_machine=x86_64-pc
os=-mingw64
;;
mingw32)
basic_machine=i386-pc
os=-mingw32
@@ -804,10 +829,18 @@ case $basic_machine in
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
msys)
basic_machine=i386-pc
os=-msys
;;
mvs)
basic_machine=i370-ibm
os=-mvs
;;
nacl)
basic_machine=le32-unknown
os=-nacl
;;
ncr3000)
basic_machine=i486-ncr
os=-sysv4
@@ -836,10 +869,10 @@ case $basic_machine in
basic_machine=v70-nec
os=-sysv
;;
next | m*-next)
next | m*-next )
basic_machine=m68k-next
case $os in
-nextstep*)
-nextstep* )
;;
-ns2*)
os=-nextstep2
@@ -958,11 +991,9 @@ case $basic_machine in
pn)
basic_machine=pn-gould
;;
power)
basic_machine=power-ibm
power) basic_machine=power-ibm
;;
ppc | ppcbe)
basic_machine=powerpc-unknown
ppc | ppcbe) basic_machine=powerpc-unknown
;;
ppc-* | ppcbe-*)
basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
@@ -973,11 +1004,9 @@ case $basic_machine in
ppcle-* | powerpclittle-*)
basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64)
basic_machine=powerpc64-unknown
ppc64) basic_machine=powerpc64-unknown
;;
ppc64-*)
basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
ppc64le | powerpc64little | ppc64-le | powerpc64-little)
basic_machine=powerpc64le-unknown
@@ -992,7 +1021,11 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
rdos)
rdos | rdos64)
basic_machine=x86_64-pc
os=-rdos
;;
rdos32)
basic_machine=i386-pc
os=-rdos
;;
@@ -1120,13 +1153,8 @@ case $basic_machine in
basic_machine=t90-cray
os=-unicos
;;
# This must be matched before tile*.
tilegx*)
basic_machine=tilegx-unknown
os=-linux-gnu
;;
tile*)
basic_machine=tile-unknown
basic_machine=$basic_machine-unknown
os=-linux-gnu
;;
tx39)
@@ -1324,21 +1352,21 @@ case $os in
-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
| -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
| -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
| -sym* | -kopensolaris* \
| -sym* | -kopensolaris* | -plan9* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
| -aos* | -aros* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \
| -bitrig* | -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* | -cegcc* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-uclibc* \
| -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
| -linux-newlib* | -linux-musl* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
@@ -1421,7 +1449,7 @@ case $os in
-nova*)
os=-rtmk-nova
;;
-ns2)
-ns2 )
os=-nextstep2
;;
-nsk*)
@@ -1470,9 +1498,6 @@ case $os in
-aros*)
os=-aros
;;
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
@@ -1521,6 +1546,9 @@ case $basic_machine in
c4x-* | tic4x-*)
os=-coff
;;
hexagon-*)
os=-elf
;;
tic54x-*)
os=-coff
;;
@@ -1548,9 +1576,6 @@ case $basic_machine in
;;
m68000-sun)
os=-sunos3
# This also exists in the configure program, but was not the
# default.
# os=-sunos4
;;
m68*-cisco)
os=-aout
@@ -1618,7 +1643,7 @@ case $basic_machine in
m88k-omron*)
os=-luna
;;
*-next)
*-next )
os=-nextstep
;;
*-sequent)

View File

@@ -1,3 +1,52 @@
/* @configure_input@ */
/* Id: config_h.in,v 1.1 1995/01/01 19:34:59 tom Exp */
@DEFS@
/* config_h.in. Generated automatically from configure.in by autoheader. */
/* Define to noreturn-attribute for gcc */
#undef GCC_NORETURN
/* Define to 1 if the compiler supports gcc-like printf attribute. */
#undef GCC_PRINTF
/* Define to printf-attribute for gcc */
#undef GCC_PRINTFLIKE
/* Define to 1 if the compiler supports gcc-like scanf attribute. */
#undef GCC_SCANF
/* Define to sscanf-attribute for gcc */
#undef GCC_SCANFLIKE
/* Define to unused-attribute for gcc */
#undef GCC_UNUSED
/* Define if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define if you have the `dbmalloc' library (-ldbmalloc). */
#undef HAVE_LIBDBMALLOC
/* Define if you have the `dmalloc' library (-ldmalloc). */
#undef HAVE_LIBDMALLOC
/* Define to 1 if mkstemp() is available and working. */
#undef HAVE_MKSTEMP
/* Define to 1 if filesystem supports mixed-case filenames. */
#undef MIXEDCASE_FILENAMES
/* Define to 1 if you want to perform memory-leak testing. */
#undef NO_LEAKS
/* Define to the system name. */
#undef SYSTEM_NAME
/* "Define to 1 if you want to use dbmalloc for testing." */
#undef USE_DBMALLOC
/* "Define to 1 if you want to use dmalloc for testing." */
#undef USE_DMALLOC
/* "Define to 1 if you want to use valgrind for testing." */
#undef USE_VALGRIND
/* Define to 1 if you want to perform memory-leak testing. */
#undef YY_NO_LEAKS

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +1,26 @@
dnl Process this file with 'autoconf' to produce a 'configure' script
dnl Id: configure.in,v 1.10 2010/12/26 19:10:21 tom Exp
AC_PREREQ(2.13.20020210)
AC_REVISION(Revision: 1.10)
dnl Id: configure.in,v 1.14 2012/10/03 23:41:36 tom Exp
AC_PREREQ(2.52.20011201)
AC_REVISION(Revision: 1.14 )
AC_INIT(main.c)
AC_CONFIG_HEADER(config.h:config_h.in)
CF_CHECK_CACHE([AC_CANONICAL_SYSTEM])
AC_ARG_PROGRAM
AC_PROG_CC
AC_CONST
CF_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_INSTALL
CF_MAKE_TAGS
CF_PROG_LINT
CF_ANSI_CC_REQD
CF_XOPEN_SOURCE
AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_FUNCS(atexit)
CF_MKSTEMP
CF_WITH_WARNINGS(Wwrite-strings)
CF_DISABLE_ECHO
CF_PROG_EXT
CF_DISABLE_LEAKS
### output makefile
AC_OUTPUT(makefile,,,cat)
AC_OUTPUT(makefile)

View File

@@ -1,9 +1,9 @@
/* $NetBSD: defs.h,v 1.5 2011/09/10 21:29:04 christos Exp $ */
/* $NetBSD: defs.h,v 1.6 2013/04/06 14:52:24 christos Exp $ */
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
/* Id: defs.h,v 1.35 2011/09/07 08:55:03 tom Exp */
/* Id: defs.h,v 1.37 2012/05/26 15:23:00 tom Exp */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -16,6 +16,10 @@
#include <ctype.h>
#include <stdio.h>
#if defined(__cplusplus) /* __cplusplus, etc. */
#define class myClass
#endif
#define YYMAJOR 1
#define YYMINOR 9
@@ -137,9 +141,11 @@
#define CALLOC(k,n) (calloc((size_t)(k),(size_t)(n)))
#define FREE(x) (free((char*)(x)))
#define MALLOC(n) (malloc((size_t)(n)))
#define TMALLOC(t,n) ((t*) malloc((size_t)(n) * sizeof(t)))
#define NEW(t) ((t*)allocate(sizeof(t)))
#define NEW2(n,t) ((t*)allocate(((size_t)(n)*sizeof(t))))
#define REALLOC(p,n) (realloc((char*)(p),(size_t)(n)))
#define TREALLOC(t,p,n) ((t*)realloc((char*)(p), (size_t)(n) * sizeof(t)))
#define DO_FREE(x) if (x) { FREE(x); x = 0; }
@@ -235,6 +241,7 @@ extern char gflag;
extern char iflag;
extern char lflag;
extern char rflag;
extern char sflag;
extern char tflag;
extern char vflag;
extern const char *symbol_prefix;
@@ -306,7 +313,6 @@ extern char *nullable;
extern bucket *first_symbol;
extern bucket *last_symbol;
extern int pure_parser;
extern int nstates;
extern core *first_state;
extern shifts *first_shift;
@@ -347,12 +353,22 @@ extern bucket *lookup(const char *);
extern bucket *make_bucket(const char *);
#ifndef GCC_NORETURN
#if defined(__dead2)
#define GCC_NORETURN __dead2
#elif defined(__dead)
#define GCC_NORETURN __dead
#else
#define GCC_NORETURN /* nothing */
#endif
#endif
#ifndef GCC_UNUSED
#if defined(__unused)
#define GCC_UNUSED __unused
#else
#define GCC_UNUSED /* nothing */
#endif
#endif
/* closure.c */
extern void closure(Value_t * nucleus, int n);
@@ -426,7 +442,7 @@ extern void output(void);
extern void reader(void);
/* skeleton.c */
extern void write_section(FILE *fp, const char *const section[]);
extern void write_section(FILE * fp, const char *const section[]);
/* verbose.c */
extern void verbose(void);

View File

@@ -1,10 +1,10 @@
/* $NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
/* Id: error.c,v 1.9 2011/09/05 23:27:43 tom Exp */
/* $NetBSD: error.c,v 1.8 2013/04/06 14:52:24 christos Exp $ */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: error.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: error.c,v 1.8 2013/04/06 14:52:24 christos Exp $");
/* Id: error.c,v 1.9 2011/09/05 23:27:43 tom Exp */
/* routines for printing error messages */

View File

@@ -1,10 +1,10 @@
/* $NetBSD: lr0.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: lr0.c,v 1.12 2010/06/09 08:53:17 tom Exp */
/* $NetBSD: lr0.c,v 1.7 2013/04/06 14:52:24 christos Exp $ */
/* Id: lr0.c,v 1.13 2012/05/26 00:40:47 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: lr0.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: lr0.c,v 1.7 2013/04/06 14:52:24 christos Exp $");
static core *new_state(int symbol);
static Value_t get_state(int symbol);
@@ -542,7 +542,7 @@ set_nullable(void)
int empty;
int done_flag;
nullable = MALLOC(nsyms);
nullable = TMALLOC(char, nsyms);
NO_SPACE(nullable);
for (i = 0; i < nsyms; ++i)

View File

@@ -1,24 +1,20 @@
/* $NetBSD: main.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
/* Id: main.c,v 1.36 2011/09/06 22:44:45 tom Exp */
/* $NetBSD: main.c,v 1.8 2013/04/06 14:52:24 christos Exp $ */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: main.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: main.c,v 1.8 2013/04/06 14:52:24 christos Exp $");
/* Id: main.c,v 1.40 2012/09/29 13:11:00 Adrian.Bunk Exp */
#include <signal.h>
#include <unistd.h> /* for _exit() */
#if defined(HAVE_ATEXIT)
# ifdef HAVE_MKSTEMP
# define USE_MKSTEMP 1
# elif defined(HAVE_FCNTL_H)
# define USE_MKSTEMP 1
# include <fcntl.h> /* for open(), O_EXCL, etc. */
# else
# define USE_MKSTEMP 0
# endif
#ifdef HAVE_MKSTEMP
# define USE_MKSTEMP 1
#elif defined(HAVE_FCNTL_H)
# define USE_MKSTEMP 1
# include <fcntl.h> /* for open(), O_EXCL, etc. */
#else
# define USE_MKSTEMP 0
#endif
@@ -43,6 +39,7 @@ char iflag;
char lflag;
static char oflag;
char rflag;
char sflag;
char tflag;
char vflag;
@@ -207,6 +204,7 @@ usage(void)
," -p symbol_prefix set symbol prefix (default \"yy\")"
," -P create a reentrant parser, e.g., \"%pure-parser\""
," -r produce separate code and table files (y.code.c)"
," -s suppress #define's for quoted names in %token lines"
," -t add debugging support"
," -v write description (y.output)"
," -V show version information and exit"
@@ -250,6 +248,10 @@ setflag(int ch)
rflag = 1;
break;
case 's':
sflag = 1;
break;
case 't':
tflag = 1;
break;
@@ -368,7 +370,7 @@ allocate(size_t n)
}
#define CREATE_FILE_NAME(dest, suffix) \
dest = MALLOC(len + strlen(suffix) + 1); \
dest = TMALLOC(char, len + strlen(suffix) + 1); \
NO_SPACE(dest); \
strcpy(dest, file_prefix); \
strcpy(dest + len, suffix)
@@ -399,7 +401,7 @@ create_file_names(void)
if (prefix != NULL)
{
len = (size_t) (prefix - output_file_name);
file_prefix = MALLOC(len + 1);
file_prefix = TMALLOC(char, len + 1);
NO_SPACE(file_prefix);
strncpy(file_prefix, output_file_name, len)[len] = 0;
}

View File

@@ -1,4 +1,4 @@
# Id: makefile.in,v 1.16 2010/06/09 09:46:37 tom Exp
# Id: makefile.in,v 1.18 2012/09/29 13:10:15 Adrian.Bunk Exp
#
# UNIX template-makefile for Berkeley Yacc
@@ -31,6 +31,7 @@ LINT = @LINT@
prefix = @prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
bindir = $(DESTDIR)@bindir@
mandir = $(DESTDIR)@mandir@/man1
manext = 1
@@ -156,7 +157,7 @@ $(THIS).txt : $(THIS).$(manext)
check: $(THIS)$x
$(SHELL) $(testdir)/run_test.sh $(testdir)
check_make:
check_make: $(THIS)$x
$(SHELL) $(testdir)/run_make.sh $(testdir)
check_lint:

View File

@@ -1,10 +1,11 @@
/* $NetBSD: mkpar.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: mkpar.c,v 1.11 2010/06/09 08:53:17 tom Exp */
/* $NetBSD: mkpar.c,v 1.7 2013/04/06 14:52:24 christos Exp $ */
/* Id: mkpar.c,v 1.12 2012/05/26 00:42:18 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: mkpar.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: mkpar.c,v 1.7 2013/04/06 14:52:24 christos Exp $");
static action *add_reduce(action *actions, int ruleno, int symbol);
static action *add_reductions(int stateno, action *actions);
@@ -184,7 +185,7 @@ unused_rules(void)
int i;
action *p;
rules_used = (Value_t *) MALLOC((unsigned)nrules * sizeof(Value_t));
rules_used = TMALLOC(Value_t, nrules);
NO_SPACE(rules_used);
for (i = 0; i < nrules; ++i)

View File

@@ -1,10 +1,11 @@
/* $NetBSD: output.c,v 1.8 2011/09/10 21:29:04 christos Exp $ */
/* Id: output.c,v 1.41 2011/09/08 09:25:40 tom Exp */
/* $NetBSD: output.c,v 1.9 2013/04/06 14:52:24 christos Exp $ */
/* Id: output.c,v 1.45 2013/03/05 00:29:17 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: output.c,v 1.8 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: output.c,v 1.9 2013/04/06 14:52:24 christos Exp $");
#define StaticOrR (rflag ? "" : "static ")
#define CountLine(fp) (!rflag || ((fp) == code_file))
@@ -561,10 +562,10 @@ pack_vector(int vector)
}
while (newmax <= loc);
table = (Value_t *) REALLOC(table, (unsigned)newmax * sizeof(Value_t));
table = TREALLOC(Value_t, table, newmax);
NO_SPACE(table);
check = (Value_t *) REALLOC(check, (unsigned)newmax * sizeof(Value_t));
check = TREALLOC(Value_t, check, newmax);
NO_SPACE(check);
for (l = maxtable; l < newmax; ++l)
@@ -831,7 +832,7 @@ output_defines(FILE * fp)
for (i = 2; i < ntokens; ++i)
{
s = symbol_name[i];
if (is_C_identifier(s))
if (is_C_identifier(s) && (!sflag || *s != '"'))
{
fprintf(fp, "#define ");
c = *s;
@@ -865,9 +866,12 @@ output_defines(FILE * fp)
{
if (unionized)
{
rewind(union_file);
while ((c = getc(union_file)) != EOF)
putc(c, fp);
if (union_file != 0)
{
rewind(union_file);
while ((c = getc(union_file)) != EOF)
putc(c, fp);
}
fprintf(fp, "extern YYSTYPE %slval;\n", symbol_prefix);
}
}
@@ -923,7 +927,7 @@ output_debug(void)
++outline;
fprintf(code_file, "#define YYMAXTOKEN %d\n", max);
symnam = (const char **)MALLOC((unsigned)(max + 1) * sizeof(char *));
symnam = TMALLOC(const char *, max + 1);
NO_SPACE(symnam);
/* Note that it is not necessary to initialize the element */
@@ -1244,8 +1248,13 @@ output_lex_decl(FILE * fp)
putl_code(fp, "#ifdef YYLEX_PARAM\n");
if (pure_parser)
{
putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval, "
"void *YYLEX_PARAM)\n");
putl_code(fp, "# ifdef YYLEX_PARAM_TYPE\n");
putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval,"
" YYLEX_PARAM_TYPE YYLEX_PARAM)\n");
putl_code(fp, "# else\n");
putl_code(fp, "# define YYLEX_DECL() yylex(YYSTYPE *yylval,"
" void * YYLEX_PARAM)\n");
putl_code(fp, "# endif\n");
putl_code(fp, "# define YYLEX yylex(&yylval, YYLEX_PARAM)\n");
}
else
@@ -1304,22 +1313,30 @@ output_error_decl(FILE * fp)
{
param *p;
putl_code(fp, "#ifndef YYERROR_DECL\n");
fprintf(fp, "#define YYERROR_DECL() yyerror(");
for (p = parse_param; p; p = p->next)
fprintf(fp, "%s %s%s, ", p->type, p->name, p->type2);
putl_code(fp, "const char *s)\n");
putl_code(fp, "#endif\n");
putl_code(fp, "#ifndef YYERROR_CALL\n");
puts_code(fp, "#define YYERROR_CALL(msg) yyerror(");
for (p = parse_param; p; p = p->next)
fprintf(fp, "%s, ", p->name);
putl_code(fp, "msg)\n");
putl_code(fp, "#endif\n");
}
else
{
putl_code(fp, "#ifndef YYERROR_DECL\n");
putl_code(fp, "#define YYERROR_DECL() yyerror(const char *s)\n");
putl_code(fp, "#endif\n");
putl_code(fp, "#ifndef YYERROR_CALL\n");
putl_code(fp, "#define YYERROR_CALL(msg) yyerror(msg)\n");
putl_code(fp, "#endif\n");
}
}
@@ -1437,9 +1454,12 @@ output(void)
if (iflag)
{
++outline;
fprintf(code_file, "#include \"%s\"\n", defines_file_name);
if (!dflag)
if (dflag)
{
++outline;
fprintf(code_file, "#include \"%s\"\n", defines_file_name);
}
else
output_defines(externs_file);
}
else

View File

@@ -1,8 +1,8 @@
Summary: byacc - public domain Berkeley LALR Yacc parser generator
%define AppProgram byacc
%define AppVersion 20110908
%define AppVersion 20130304
%define UseProgram yacc
# $XTermId: byacc.spec,v 1.10 2011/09/08 09:45:02 tom Exp $
# $XTermId: byacc.spec,v 1.16 2013/03/05 01:17:35 tom Exp $
Name: %{AppProgram}
Version: %{AppVersion}
Release: 1

View File

@@ -1,3 +1,33 @@
byacc (20130304) unstable; urgency=low
* changes prompted by Richard Mitton bug-report
-- Thomas E. Dickey <dickey@invisible-island.net> Mon, 04 Mar 2013 20:17:32 -0500
byacc (20121003) unstable; urgency=low
* changes from or prompted by Adrian Bunk.
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 29 Sep 2012 09:14:31 -0400
byacc (20120526) unstable; urgency=low
* minor code-cleanup.
-- Thomas E. Dickey <dickey@invisible-island.net> Sat, 26 May 2012 12:14:17 -0400
byacc (20120115) unstable; urgency=low
* add testcases, improve documentation for "-s" option.
-- Thomas E. Dickey <dickey@invisible-island.net> Fri, 13 Jan 2012 20:44:34 -0500
byacc (20111219) unstable; urgency=low
* add "-s" option.
-- Thomas E. Dickey <dickey@invisible-island.net> Mon, 19 Dec 2011 20:54:09 -0500
byacc (20110908) unstable; urgency=low
* add "-i" option.

View File

@@ -36,7 +36,7 @@ skeleton.c with the bug report. Do not expect rapid responses.
Files: aclocal.m4
Licence: other-BSD
Copyright: 2004-2009,2010 by Thomas E. Dickey
Copyright: 2004-2011,2012 by Thomas E. Dickey
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
@@ -97,7 +97,7 @@ Licence: other-BSD
shared with many OS's install programs.
Files: debian/*
Copyright: 2010 Thomas E. Dickey
Copyright: 2012 Thomas E. Dickey
Licence: other-BSD
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.1.1.1 2010/12/23 23:36:27 christos Exp $
# NetBSD: Makefile,v 1.9 2008/07/24 17:13:00 tonnerre Exp
#
DISTNAME= byacc-20050813

View File

@@ -1,3 +1,3 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2010/12/23 23:36:27 christos Exp $
@comment NetBSD: PLIST,v 1.2 2005/04/13 14:11:54 wiz Exp
bin/yacc
man/man1/yacc.1

View File

@@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.1.1.1 2010/12/23 23:36:27 christos Exp $
NetBSD: distinfo,v 1.4 2008/07/24 17:13:00 tonnerre Exp
SHA1 (byacc-20050813.tgz) = 3258494f3422eb3150944c1823af1c9c2c386062
RMD160 (byacc-20050813.tgz) = 3ee159857a79025a83e2b0807577925fe460f816

View File

@@ -1,10 +1,11 @@
/* $NetBSD: reader.c,v 1.7 2011/09/10 21:29:04 christos Exp $ */
/* Id: reader.c,v 1.33 2011/09/06 22:56:53 tom Exp */
/* $NetBSD: reader.c,v 1.8 2013/04/06 14:52:24 christos Exp $ */
/* Id: reader.c,v 1.36 2012/05/26 16:05:41 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: reader.c,v 1.7 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: reader.c,v 1.8 2013/04/06 14:52:24 christos Exp $");
/* The line size must be a positive integer. One hundred was chosen */
/* because few lines in Yacc input grammars exceed 100 characters. */
@@ -56,7 +57,7 @@ cachec(int c)
if (cinc >= cache_size)
{
cache_size += 256;
cache = REALLOC(cache, cache_size);
cache = TREALLOC(char, cache, cache_size);
NO_SPACE(cache);
}
cache[cinc] = (char)c;
@@ -87,7 +88,7 @@ get_line(void)
if (line)
FREE(line);
linesize = LINESIZE + 1;
line = MALLOC(linesize);
line = TMALLOC(char, linesize);
NO_SPACE(line);
}
@@ -104,7 +105,7 @@ get_line(void)
if (++i >= linesize)
{
linesize += LINESIZE;
line = REALLOC(line, linesize);
line = TREALLOC(char, line, linesize);
NO_SPACE(line);
}
c = getc(f);
@@ -128,7 +129,7 @@ dup_line(void)
s = line;
while (*s != '\n')
++s;
p = MALLOC(s - line + 1);
p = TMALLOC(char, s - line + 1);
NO_SPACE(p);
s = line;
@@ -689,7 +690,7 @@ copy_param(int k)
if (c == '}')
goto out;
buf = MALLOC(linesize);
buf = TMALLOC(char, linesize);
NO_SPACE(buf);
for (i = 0; (c = *cptr++) != '}'; i++)
@@ -737,7 +738,7 @@ copy_param(int k)
name = i + 1;
p = MALLOC(sizeof(*p));
p = TMALLOC(param, 1);
NO_SPACE(p);
p->type2 = strdup(buf + type2);
@@ -894,7 +895,7 @@ get_literal(void)
FREE(s_line);
n = cinc;
s = MALLOC(n);
s = TMALLOC(char, n);
NO_SPACE(s);
for (i = 0; i < n; ++i)
@@ -1062,14 +1063,14 @@ get_tag(void)
if (ntags >= tagmax)
{
tagmax += 16;
tag_table = (char **)
tag_table =
(tag_table
? REALLOC(tag_table, (unsigned)tagmax * sizeof(char *))
: MALLOC((unsigned)tagmax * sizeof(char *)));
? TREALLOC(char *, tag_table, tagmax)
: TMALLOC(char *, tagmax));
NO_SPACE(tag_table);
}
s = MALLOC(cinc);
s = TMALLOC(char, cinc);
NO_SPACE(s);
strcpy(s, cache);
@@ -1250,7 +1251,7 @@ read_declarations(void)
int c, k;
cache_size = 256;
cache = MALLOC(cache_size);
cache = TMALLOC(char, cache_size);
NO_SPACE(cache);
for (;;)
@@ -1320,7 +1321,7 @@ initialize_grammar(void)
nitems = 4;
maxitems = 300;
pitem = (bucket **)MALLOC((unsigned)maxitems * sizeof(bucket *));
pitem = TMALLOC(bucket *, maxitems);
NO_SPACE(pitem);
pitem[0] = 0;
@@ -1331,21 +1332,21 @@ initialize_grammar(void)
nrules = 3;
maxrules = 100;
plhs = (bucket **)MALLOC((unsigned)maxrules * sizeof(bucket *));
plhs = TMALLOC(bucket *, maxrules);
NO_SPACE(plhs);
plhs[0] = 0;
plhs[1] = 0;
plhs[2] = 0;
rprec = (short *)MALLOC((unsigned)maxrules * sizeof(short));
rprec = TMALLOC(Value_t, maxrules);
NO_SPACE(rprec);
rprec[0] = 0;
rprec[1] = 0;
rprec[2] = 0;
rassoc = (char *)MALLOC((unsigned)maxrules * sizeof(char));
rassoc = TMALLOC(Assoc_t, maxrules);
NO_SPACE(rassoc);
rassoc[0] = TOKEN;
@@ -1357,7 +1358,7 @@ static void
expand_items(void)
{
maxitems += 300;
pitem = (bucket **)REALLOC(pitem, (unsigned)maxitems * sizeof(bucket *));
pitem = TREALLOC(bucket *, pitem, maxitems);
NO_SPACE(pitem);
}
@@ -1366,13 +1367,13 @@ expand_rules(void)
{
maxrules += 100;
plhs = (bucket **)REALLOC(plhs, (unsigned)maxrules * sizeof(bucket *));
plhs = TREALLOC(bucket *, plhs, maxrules);
NO_SPACE(plhs);
rprec = (short *)REALLOC(rprec, (unsigned)maxrules * sizeof(short));
rprec = TREALLOC(Value_t, rprec, maxrules);
NO_SPACE(rprec);
rassoc = (char *)REALLOC(rassoc, (unsigned)maxrules * sizeof(char));
rassoc = TREALLOC(Assoc_t, rassoc, maxrules);
NO_SPACE(rassoc);
}
@@ -1784,7 +1785,7 @@ static int
mark_symbol(void)
{
int c;
bucket *bp;
bucket *bp = NULL;
c = cptr[1];
if (c == '%' || c == '\\')
@@ -1888,7 +1889,7 @@ pack_names(void)
for (bp = first_symbol; bp; bp = bp->next)
name_pool_size += strlen(bp->name) + 1;
name_pool = MALLOC(name_pool_size);
name_pool = TMALLOC(char, name_pool_size);
NO_SPACE(name_pool);
strlcpy(name_pool, "$accept", name_pool_size);
@@ -1943,7 +1944,7 @@ protect_string(char *src, char **des)
len++;
}
*des = d = (char *)MALLOC(len);
*des = d = TMALLOC(char, len);
NO_SPACE(d);
s = src;
@@ -1975,19 +1976,19 @@ pack_symbols(void)
start_symbol = (Value_t) ntokens;
nvars = nsyms - ntokens;
symbol_name = (char **)MALLOC((unsigned)nsyms * sizeof(char *));
symbol_name = TMALLOC(char *, nsyms);
NO_SPACE(symbol_name);
symbol_value = (short *)MALLOC((unsigned)nsyms * sizeof(short));
symbol_value = TMALLOC(Value_t, nsyms);
NO_SPACE(symbol_value);
symbol_prec = (short *)MALLOC((unsigned)nsyms * sizeof(short));
symbol_prec = TMALLOC(short, nsyms);
NO_SPACE(symbol_prec);
symbol_assoc = MALLOC(nsyms);
symbol_assoc = TMALLOC(char, nsyms);
NO_SPACE(symbol_assoc);
v = (bucket **)MALLOC((unsigned)nsyms * sizeof(bucket *));
v = TMALLOC(bucket *, nsyms);
NO_SPACE(v);
v[0] = 0;
@@ -2087,7 +2088,7 @@ pack_symbols(void)
if (gflag)
{
symbol_pname = (char **)MALLOC((unsigned)nsyms * sizeof(char *));
symbol_pname = TMALLOC(char *, nsyms);
NO_SPACE(symbol_pname);
for (i = 0; i < nsyms; ++i)
@@ -2105,19 +2106,19 @@ pack_grammar(void)
Assoc_t assoc;
Value_t prec2;
ritem = (short *)MALLOC((unsigned)nitems * sizeof(short));
ritem = TMALLOC(Value_t, nitems);
NO_SPACE(ritem);
rlhs = (short *)MALLOC((unsigned)nrules * sizeof(short));
rlhs = TMALLOC(Value_t, nrules);
NO_SPACE(rlhs);
rrhs = (short *)MALLOC((unsigned)(nrules + 1) * sizeof(short));
rrhs = TMALLOC(Value_t, nrules + 1);
NO_SPACE(rrhs);
rprec = (short *)REALLOC(rprec, (unsigned)nrules * sizeof(short));
rprec = TREALLOC(Value_t, rprec, nrules);
NO_SPACE(rprec);
rassoc = REALLOC(rassoc, nrules);
rassoc = TREALLOC(Assoc_t, rassoc, nrules);
NO_SPACE(rassoc);
ritem[0] = -1;

View File

@@ -1,10 +1,11 @@
/* $NetBSD: skeleton.c,v 1.10 2011/09/10 21:29:04 christos Exp $ */
/* Id: skeleton.c,v 1.31 2011/09/07 09:37:59 tom Exp */
/* $NetBSD: skeleton.c,v 1.13 2013/09/13 18:53:29 joerg Exp $ */
/* Id: skeleton.c,v 1.32 2013/03/04 23:19:39 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: skeleton.c,v 1.10 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: skeleton.c,v 1.13 2013/09/13 18:53:29 joerg Exp $");
/* The definition of yysccsid in the banner should be replaced with */
/* a #pragma ident directive if the target C compiler supports */
@@ -21,6 +22,9 @@ __RCSID("$NetBSD: skeleton.c,v 1.10 2011/09/10 21:29:04 christos Exp $");
const char *const banner[] =
{
"#ifndef lint",
"#if __GNUC__ - 0 >= 4 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ >= 1)",
"__attribute__((__used__))",
"#endif",
"static const char yysccsid[] = \"@(#)yaccpar 1.9 (Berkeley) 02/21/93\";",
"#endif",
"",
@@ -166,7 +170,7 @@ const char *const body_1[] =
" else if ((newsize *= 2) > YYMAXDEPTH)",
" newsize = YYMAXDEPTH;",
"",
" i = data->s_mark - data->s_base;",
" i = (int) (data->s_mark - data->s_base);",
" newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));",
" if (newss == 0)",
" return -1;",

View File

@@ -1,10 +1,11 @@
/* $NetBSD: symtab.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: symtab.c,v 1.9 2010/11/24 15:12:29 tom Exp */
/* $NetBSD: symtab.c,v 1.7 2013/04/06 14:52:24 christos Exp $ */
/* Id: symtab.c,v 1.10 2012/05/26 15:16:12 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: symtab.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: symtab.c,v 1.7 2013/04/06 14:52:24 christos Exp $");
/* TABLE_SIZE is the number of entries in the symbol table. */
/* TABLE_SIZE must be a power of two. */
@@ -37,13 +38,13 @@ make_bucket(const char *name)
assert(name != 0);
bp = (bucket *)MALLOC(sizeof(bucket));
bp = TMALLOC(bucket, 1);
NO_SPACE(bp);
bp->link = 0;
bp->next = 0;
bp->name = MALLOC(strlen(name) + 1);
bp->name = TMALLOC(char, strlen(name) + 1);
NO_SPACE(bp->name);
bp->tag = 0;
@@ -86,7 +87,7 @@ create_symbol_table(void)
int i;
bucket *bp;
symbol_table = (bucket **)MALLOC(TABLE_SIZE * sizeof(bucket *));
symbol_table = TMALLOC(bucket *, TABLE_SIZE);
NO_SPACE(symbol_table);
for (i = 0; i < TABLE_SIZE; i++)

View File

@@ -1,4 +1,4 @@
-- $Id: README,v 1.2 2009/10/29 00:56:20 christos Exp $
-- Id: README,v 1.1 2004/03/28 19:10:48 tom Exp
The files in this directory are input (.y) and output (.output, .tab.c, .tab.h)
examples.

View File

@@ -1,4 +1,4 @@
/* $NetBSD: calc.tab.c,v 1.1.1.4 2011/09/10 21:22:03 christos Exp $ */
/* $NetBSD: calc.tab.c,v 1.1.1.5 2013/04/06 14:45:27 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
@@ -104,7 +104,10 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
int regs[26];
int base;
#line 106 "calc.tab.c"
extern int yylex(void);
static void yyerror(const char *s);
#line 109 "calc.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -132,8 +135,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
@@ -296,14 +303,9 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 63 "calc.y"
#line 66 "calc.y"
/* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
main (void)
{
@@ -343,7 +345,7 @@ yylex(void)
}
return( c );
}
#line 345 "calc.tab.c"
#line 347 "calc.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -367,7 +369,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
@@ -550,66 +552,66 @@ yyreduce:
switch (yyn)
{
case 3:
#line 25 "calc.y"
#line 28 "calc.y"
{ yyerrok ; }
break;
case 4:
#line 29 "calc.y"
#line 32 "calc.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 31 "calc.y"
#line 34 "calc.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 35 "calc.y"
#line 38 "calc.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 37 "calc.y"
#line 40 "calc.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 39 "calc.y"
#line 42 "calc.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 41 "calc.y"
#line 44 "calc.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 43 "calc.y"
#line 46 "calc.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 45 "calc.y"
#line 48 "calc.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 47 "calc.y"
#line 50 "calc.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 49 "calc.y"
#line 52 "calc.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 51 "calc.y"
#line 54 "calc.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 53 "calc.y"
#line 56 "calc.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 58 "calc.y"
#line 61 "calc.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 60 "calc.y"
#line 63 "calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 611 "calc.tab.c"
#line 613 "calc.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: calc.y,v 1.1.1.4 2011/09/10 21:22:08 christos Exp $ */
/* $NetBSD: calc.y,v 1.1.1.5 2013/04/06 14:45:27 christos Exp $ */
%{
# include <stdio.h>
@@ -7,6 +7,9 @@
int regs[26];
int base;
extern int yylex(void);
static void yyerror(const char *s);
%}
%start list
@@ -64,11 +67,6 @@ number: DIGIT
%% /* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
main (void)
{

View File

@@ -1,4 +1,4 @@
/* $NetBSD: calc1.tab.c,v 1.1.1.3 2011/09/10 21:22:08 christos Exp $ */
/* $NetBSD: calc1.tab.c,v 1.1.1.4 2013/04/06 14:45:29 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
@@ -115,12 +115,15 @@ INTERVAL;
INTERVAL vmul(double, double, INTERVAL);
INTERVAL vdiv(double, double, INTERVAL);
extern int yylex(void);
static void yyerror(const char *s);
int dcheck(INTERVAL);
double dreg[26];
INTERVAL vreg[26];
#line 28 "calc1.y"
#line 31 "calc1.y"
#ifdef YYSTYPE
#undef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
@@ -134,7 +137,7 @@ typedef union
INTERVAL vval;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
#line 136 "calc1.tab.c"
#line 139 "calc1.tab.c"
/* compatibility with bison */
#ifdef YYPARSE_PARAM
@@ -158,8 +161,12 @@ typedef union
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
@@ -346,14 +353,9 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 173 "calc1.y"
#line 176 "calc1.y"
/* beginning of subroutines section */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
#define BSZ 50 /* buffer size for floating point numbers */
/* lexical analysis */
@@ -393,7 +395,7 @@ yylex(void)
for (; (cp - buf) < BSZ; ++cp, c = getchar())
{
*cp = c;
*cp = (char) c;
if (isdigit(c))
continue;
if (c == '.')
@@ -482,7 +484,7 @@ vdiv(double a, double b, INTERVAL v)
{
return (hilo(a / v.hi, a / v.lo, b / v.hi, b / v.lo));
}
#line 484 "calc1.tab.c"
#line 486 "calc1.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -506,7 +508,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
@@ -689,85 +691,85 @@ yyreduce:
switch (yyn)
{
case 3:
#line 54 "calc1.y"
#line 57 "calc1.y"
{
(void) printf("%15.8f\n", yystack.l_mark[-1].dval);
}
break;
case 4:
#line 58 "calc1.y"
#line 61 "calc1.y"
{
(void) printf("(%15.8f, %15.8f)\n", yystack.l_mark[-1].vval.lo, yystack.l_mark[-1].vval.hi);
}
break;
case 5:
#line 62 "calc1.y"
#line 65 "calc1.y"
{
dreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].dval;
}
break;
case 6:
#line 66 "calc1.y"
#line 69 "calc1.y"
{
vreg[yystack.l_mark[-3].ival] = yystack.l_mark[-1].vval;
}
break;
case 7:
#line 70 "calc1.y"
#line 73 "calc1.y"
{
yyerrok;
}
break;
case 9:
#line 77 "calc1.y"
#line 80 "calc1.y"
{
yyval.dval = dreg[yystack.l_mark[0].ival];
}
break;
case 10:
#line 81 "calc1.y"
#line 84 "calc1.y"
{
yyval.dval = yystack.l_mark[-2].dval + yystack.l_mark[0].dval;
}
break;
case 11:
#line 85 "calc1.y"
#line 88 "calc1.y"
{
yyval.dval = yystack.l_mark[-2].dval - yystack.l_mark[0].dval;
}
break;
case 12:
#line 89 "calc1.y"
#line 92 "calc1.y"
{
yyval.dval = yystack.l_mark[-2].dval * yystack.l_mark[0].dval;
}
break;
case 13:
#line 93 "calc1.y"
#line 96 "calc1.y"
{
yyval.dval = yystack.l_mark[-2].dval / yystack.l_mark[0].dval;
}
break;
case 14:
#line 97 "calc1.y"
#line 100 "calc1.y"
{
yyval.dval = -yystack.l_mark[0].dval;
}
break;
case 15:
#line 101 "calc1.y"
#line 104 "calc1.y"
{
yyval.dval = yystack.l_mark[-1].dval;
}
break;
case 16:
#line 107 "calc1.y"
#line 110 "calc1.y"
{
yyval.vval.hi = yyval.vval.lo = yystack.l_mark[0].dval;
}
break;
case 17:
#line 111 "calc1.y"
#line 114 "calc1.y"
{
yyval.vval.lo = yystack.l_mark[-3].dval;
yyval.vval.hi = yystack.l_mark[-1].dval;
@@ -779,79 +781,79 @@ case 17:
}
break;
case 18:
#line 121 "calc1.y"
#line 124 "calc1.y"
{
yyval.vval = vreg[yystack.l_mark[0].ival];
}
break;
case 19:
#line 125 "calc1.y"
#line 128 "calc1.y"
{
yyval.vval.hi = yystack.l_mark[-2].vval.hi + yystack.l_mark[0].vval.hi;
yyval.vval.lo = yystack.l_mark[-2].vval.lo + yystack.l_mark[0].vval.lo;
}
break;
case 20:
#line 130 "calc1.y"
#line 133 "calc1.y"
{
yyval.vval.hi = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.hi;
yyval.vval.lo = yystack.l_mark[-2].dval + yystack.l_mark[0].vval.lo;
}
break;
case 21:
#line 135 "calc1.y"
#line 138 "calc1.y"
{
yyval.vval.hi = yystack.l_mark[-2].vval.hi - yystack.l_mark[0].vval.lo;
yyval.vval.lo = yystack.l_mark[-2].vval.lo - yystack.l_mark[0].vval.hi;
}
break;
case 22:
#line 140 "calc1.y"
#line 143 "calc1.y"
{
yyval.vval.hi = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.lo;
yyval.vval.lo = yystack.l_mark[-2].dval - yystack.l_mark[0].vval.hi;
}
break;
case 23:
#line 145 "calc1.y"
#line 148 "calc1.y"
{
yyval.vval = vmul( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
}
break;
case 24:
#line 149 "calc1.y"
#line 152 "calc1.y"
{
yyval.vval = vmul (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
}
break;
case 25:
#line 153 "calc1.y"
#line 156 "calc1.y"
{
if (dcheck(yystack.l_mark[0].vval)) YYERROR;
yyval.vval = vdiv ( yystack.l_mark[-2].vval.lo, yystack.l_mark[-2].vval.hi, yystack.l_mark[0].vval );
}
break;
case 26:
#line 158 "calc1.y"
#line 161 "calc1.y"
{
if (dcheck ( yystack.l_mark[0].vval )) YYERROR;
yyval.vval = vdiv (yystack.l_mark[-2].dval, yystack.l_mark[-2].dval, yystack.l_mark[0].vval );
}
break;
case 27:
#line 163 "calc1.y"
#line 166 "calc1.y"
{
yyval.vval.hi = -yystack.l_mark[0].vval.lo;
yyval.vval.lo = -yystack.l_mark[0].vval.hi;
}
break;
case 28:
#line 168 "calc1.y"
#line 171 "calc1.y"
{
yyval.vval = yystack.l_mark[-1].vval;
}
break;
#line 853 "calc1.tab.c"
#line 855 "calc1.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: calc1.y,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
/* $NetBSD: calc1.y,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */
%{
@@ -18,6 +18,9 @@ INTERVAL;
INTERVAL vmul(double, double, INTERVAL);
INTERVAL vdiv(double, double, INTERVAL);
extern int yylex(void);
static void yyerror(const char *s);
int dcheck(INTERVAL);
double dreg[26];
@@ -174,11 +177,6 @@ vexp : dexp
%% /* beginning of subroutines section */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
#define BSZ 50 /* buffer size for floating point numbers */
/* lexical analysis */
@@ -218,7 +216,7 @@ yylex(void)
for (; (cp - buf) < BSZ; ++cp, c = getchar())
{
*cp = c;
*cp = (char) c;
if (isdigit(c))
continue;
if (c == '.')

View File

@@ -1,4 +1,4 @@
/* $NetBSD: calc2.tab.c,v 1.1.1.3 2011/09/10 21:22:08 christos Exp $ */
/* $NetBSD: calc2.tab.c,v 1.1.1.4 2013/04/06 14:45:28 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
@@ -101,7 +101,15 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
# include <stdio.h>
# include <ctype.h>
#line 103 "calc2.tab.c"
#ifdef YYBISON
#define YYLEX_PARAM base
#define YYLEX_DECL() yylex(int *YYLEX_PARAM)
#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
int YYLEX_DECL();
static void YYERROR_DECL();
#endif
#line 111 "calc2.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -129,8 +137,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(regs, base, msg)
#endif
extern int YYPARSE_DECL();
@@ -293,12 +305,11 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 65 "calc2.y"
#line 73 "calc2.y"
/* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
@@ -320,7 +331,7 @@ YYERROR_DECL()
}
int
yylex(int *base)
YYLEX_DECL()
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
@@ -343,7 +354,7 @@ yylex(int *base)
}
return( c );
}
#line 345 "calc2.tab.c"
#line 356 "calc2.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -367,7 +378,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
@@ -550,66 +561,66 @@ yyreduce:
switch (yyn)
{
case 3:
#line 27 "calc2.y"
#line 35 "calc2.y"
{ yyerrok ; }
break;
case 4:
#line 31 "calc2.y"
#line 39 "calc2.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 33 "calc2.y"
#line 41 "calc2.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 37 "calc2.y"
#line 45 "calc2.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 39 "calc2.y"
#line 47 "calc2.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 41 "calc2.y"
#line 49 "calc2.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 43 "calc2.y"
#line 51 "calc2.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 45 "calc2.y"
#line 53 "calc2.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 47 "calc2.y"
#line 55 "calc2.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 49 "calc2.y"
#line 57 "calc2.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 51 "calc2.y"
#line 59 "calc2.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 53 "calc2.y"
#line 61 "calc2.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 55 "calc2.y"
#line 63 "calc2.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 60 "calc2.y"
#line 68 "calc2.y"
{ yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 62 "calc2.y"
#line 70 "calc2.y"
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 611 "calc2.tab.c"
#line 622 "calc2.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: calc2.y,v 1.1.1.3 2011/09/10 21:22:06 christos Exp $ */
/* $NetBSD: calc2.y,v 1.1.1.4 2013/04/06 14:45:29 christos Exp $ */
%parse-param { int regs[26] }
%parse-param { int *base }
@@ -9,6 +9,14 @@
# include <stdio.h>
# include <ctype.h>
#ifdef YYBISON
#define YYLEX_PARAM base
#define YYLEX_DECL() yylex(int *YYLEX_PARAM)
#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
int YYLEX_DECL();
static void YYERROR_DECL();
#endif
%}
%start list
@@ -68,7 +76,6 @@ number: DIGIT
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
@@ -90,7 +97,7 @@ YYERROR_DECL()
}
int
yylex(int *base)
YYLEX_DECL()
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: calc3.tab.c,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
/* $NetBSD: calc3.tab.c,v 1.1.1.4 2013/04/06 14:45:29 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
@@ -101,7 +101,16 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
# include <stdio.h>
# include <ctype.h>
#line 103 "calc3.tab.c"
#ifdef YYBISON
#define YYSTYPE int
#define YYLEX_PARAM base
#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM)
#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
int YYLEX_DECL();
static void YYERROR_DECL();
#endif
#line 112 "calc3.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -121,7 +130,11 @@ typedef int YYSTYPE;
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
# ifdef YYLEX_PARAM_TYPE
# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
# else
# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
# endif
# define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(YYSTYPE *yylval, int * base)
@@ -129,8 +142,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(int regs[26], int * base, const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(regs, base, msg)
#endif
extern int YYPARSE_DECL();
@@ -286,12 +303,11 @@ typedef struct {
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
#line 67 "calc3.y"
#line 76 "calc3.y"
/* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
@@ -336,7 +352,7 @@ YYLEX_DECL()
}
return( c );
}
#line 338 "calc3.tab.c"
#line 354 "calc3.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -360,7 +376,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
@@ -550,66 +566,66 @@ yyreduce:
switch (yyn)
{
case 3:
#line 29 "calc3.y"
#line 38 "calc3.y"
{ yyerrok ; }
break;
case 4:
#line 33 "calc3.y"
#line 42 "calc3.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 35 "calc3.y"
#line 44 "calc3.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 39 "calc3.y"
#line 48 "calc3.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 41 "calc3.y"
#line 50 "calc3.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 43 "calc3.y"
#line 52 "calc3.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 45 "calc3.y"
#line 54 "calc3.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 47 "calc3.y"
#line 56 "calc3.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 49 "calc3.y"
#line 58 "calc3.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 51 "calc3.y"
#line 60 "calc3.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 53 "calc3.y"
#line 62 "calc3.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 55 "calc3.y"
#line 64 "calc3.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 57 "calc3.y"
#line 66 "calc3.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 62 "calc3.y"
#line 71 "calc3.y"
{ yyval = yystack.l_mark[0]; (*base) = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 64 "calc3.y"
#line 73 "calc3.y"
{ yyval = (*base) * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 611 "calc3.tab.c"
#line 627 "calc3.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: calc3.y,v 1.1.1.3 2011/09/10 21:22:07 christos Exp $ */
/* $NetBSD: calc3.y,v 1.1.1.4 2013/04/06 14:45:28 christos Exp $ */
%pure-parser
@@ -11,6 +11,15 @@
# include <stdio.h>
# include <ctype.h>
#ifdef YYBISON
#define YYSTYPE int
#define YYLEX_PARAM base
#define YYLEX_DECL() yylex(YYSTYPE *yylval, int *YYLEX_PARAM)
#define YYERROR_DECL() yyerror(int regs[26], int *base, const char *s)
int YYLEX_DECL();
static void YYERROR_DECL();
#endif
%}
%start list
@@ -70,7 +79,6 @@ number: DIGIT
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int

View File

@@ -1,4 +1,4 @@
/* $NetBSD: code_calc.code.c,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
/* $NetBSD: code_calc.code.c,v 1.1.1.4 2013/04/06 14:45:29 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
@@ -23,7 +23,12 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
int regs[26];
int base;
#line 25 "code_calc.code.c"
#ifdef YYBISON
int yylex(void);
static void yyerror(const char *s);
#endif
#line 30 "code_calc.code.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -51,8 +56,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
@@ -197,12 +206,11 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 63 "code_calc.y"
#line 68 "code_calc.y"
/* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
@@ -221,7 +229,8 @@ yyerror(const char *s)
}
int
yylex(void) {
yylex(void)
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
@@ -243,7 +252,7 @@ yylex(void) {
}
return( c );
}
#line 245 "code_calc.code.c"
#line 254 "code_calc.code.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -267,7 +276,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
@@ -450,66 +459,66 @@ yyreduce:
switch (yyn)
{
case 3:
#line 25 "code_calc.y"
#line 30 "code_calc.y"
{ yyerrok ; }
break;
case 4:
#line 29 "code_calc.y"
#line 34 "code_calc.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 31 "code_calc.y"
#line 36 "code_calc.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 35 "code_calc.y"
#line 40 "code_calc.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 37 "code_calc.y"
#line 42 "code_calc.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 39 "code_calc.y"
#line 44 "code_calc.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 41 "code_calc.y"
#line 46 "code_calc.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 43 "code_calc.y"
#line 48 "code_calc.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 45 "code_calc.y"
#line 50 "code_calc.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 47 "code_calc.y"
#line 52 "code_calc.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 49 "code_calc.y"
#line 54 "code_calc.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 51 "code_calc.y"
#line 56 "code_calc.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 53 "code_calc.y"
#line 58 "code_calc.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 58 "code_calc.y"
#line 63 "code_calc.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 60 "code_calc.y"
#line 65 "code_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 511 "code_calc.code.c"
#line 520 "code_calc.code.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: code_calc.y,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
/* $NetBSD: code_calc.y,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */
%{
# include <stdio.h>
@@ -7,6 +7,11 @@
int regs[26];
int base;
#ifdef YYBISON
int yylex(void);
static void yyerror(const char *s);
#endif
%}
%start list
@@ -66,7 +71,6 @@ number: DIGIT
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
@@ -85,7 +89,8 @@ yyerror(const char *s)
}
int
yylex(void) {
yylex(void)
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: code_error.code.c,v 1.1.1.3 2011/09/10 21:22:06 christos Exp $ */
/* $NetBSD: code_error.code.c,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
@@ -16,6 +16,14 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#define YYPURE 0
#line 2 "code_error.y"
#ifdef YYBISON
int yylex(void);
static void yyerror(const char *);
#endif
#line 25 "code_error.code.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -43,8 +51,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
@@ -186,13 +198,12 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 4 "code_error.y"
#line 12 "code_error.y"
#include <stdio.h>
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
@@ -213,7 +224,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
#line 215 "code_error.code.c"
#line 226 "code_error.code.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -237,7 +248,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;

View File

@@ -1,5 +1,13 @@
/* $NetBSD: code_error.y,v 1.1.1.3 2011/09/10 21:22:09 christos Exp $ */
/* $NetBSD: code_error.y,v 1.1.1.4 2013/04/06 14:45:29 christos Exp $ */
%{
#ifdef YYBISON
int yylex(void);
static void yyerror(const char *);
#endif
%}
%%
S: error
%%
@@ -8,7 +16,6 @@ S: error
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int

View File

@@ -1,8 +1,8 @@
/* $NetBSD: error.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $ */
/* $NetBSD: error.tab.c,v 1.5 2013/04/06 14:52:24 christos Exp $ */
#ifndef lint
/* static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; */
static char rcsid[] = "$NetBSD: error.tab.c,v 1.4 2011/09/10 21:29:04 christos Exp $";
static char rcsid[] = "$NetBSD: error.tab.c,v 1.5 2013/04/06 14:52:24 christos Exp $";
#endif
#define YYBYACC 1
@@ -98,6 +98,10 @@ static char rcsid[] = "$NetBSD: error.tab.c,v 1.4 2011/09/10 21:29:04 christos E
#define YYPURE 0
#line 2 "error.y"
int yylex(void);
static void yyerror(const char *);
#line 102 "error.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -125,8 +129,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
@@ -205,15 +213,10 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 4 "error.y"
#line 8 "error.y"
#include <stdio.h>
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
main(void)
{
@@ -232,7 +235,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
#line 233 "error.tab.c"
#line 236 "error.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -256,7 +259,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;

View File

@@ -1,16 +1,15 @@
/* $NetBSD: error.y,v 1.1.1.4 2011/09/10 21:22:03 christos Exp $ */
/* $NetBSD: error.y,v 1.1.1.5 2013/04/06 14:45:27 christos Exp $ */
%{
int yylex(void);
static void yyerror(const char *);
%}
%%
S: error
%%
#include <stdio.h>
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
main(void)
{

View File

@@ -759,8 +759,8 @@ state 79
type_code : L . SP byte_size (62)
type_code : L . byte_size (63)
SP shift 123
NUMBER shift 124
NUMBER shift 123
SP shift 124
CRLF reduce 61
byte_size goto 125
@@ -1110,20 +1110,20 @@ state 122
state 123
type_code : L SP . byte_size (62)
NUMBER shift 124
. error
byte_size goto 159
state 124
byte_size : NUMBER . (51)
. reduce 51
state 124
type_code : L SP . byte_size (62)
NUMBER shift 123
. error
byte_size goto 159
state 125
type_code : L byte_size . (63)

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +1,22 @@
/* $NetBSD: ftp.tab.h,v 1.3 2011/09/10 21:29:04 christos Exp $ */
/* $NetBSD: ftp.tab.h,v 1.4 2013/04/06 14:52:24 christos Exp $ */
#define A 257
#define B 258
#define C 259
#define E 260
#define F 261
#define I 262
#define L 263
#define N 264
#define P 265
#define R 266
#define S 267
#define T 268
#define SP 269
#define CRLF 270
#define COMMA 271
#define STRING 272
#define NUMBER 273
#define NUMBER 257
#define STRING 258
#define A 259
#define B 260
#define C 261
#define E 262
#define F 263
#define I 264
#define L 265
#define N 266
#define P 267
#define R 268
#define S 269
#define T 270
#define SP 271
#define CRLF 272
#define COMMA 273
#define USER 274
#define PASS 275
#define ACCT 276
@@ -63,3 +63,16 @@
#define IDLE 317
#define CHMOD 318
#define LEXERR 319
#ifdef YYSTYPE
#undef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
#endif
#ifndef YYSTYPE_IS_DECLARED
#define YYSTYPE_IS_DECLARED 1
typedef union
{
int ival;
char *sval;
} YYSTYPE;
#endif /* !YYSTYPE_IS_DECLARED */
extern YYSTYPE ftp_lval;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $ */
/* $NetBSD: ftp.y,v 1.5 2013/04/06 14:52:24 christos Exp $ */
/*
* Copyright (c) 1985, 1988 Regents of the University of California.
@@ -17,7 +17,7 @@
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* from: @(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89
* $NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $
* $NetBSD: ftp.y,v 1.5 2013/04/06 14:52:24 christos Exp $
*/
/*
@@ -29,7 +29,7 @@
#ifndef lint
static char sccsid[] = "@(#)ftpcmd.y 5.20.1.1 (Berkeley) 3/2/89";
static char rcsid[] = "$NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $";
static char rcsid[] = "$NetBSD: ftp.y,v 1.5 2013/04/06 14:52:24 christos Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -52,6 +52,11 @@ static char rcsid[] = "$NetBSD: ftp.y,v 1.4 2011/09/10 21:29:04 christos Exp $";
#include <time.h>
#include <assert.h>
#ifdef YYBISON
int yylex(void);
static void yyerror(const char *);
#endif
extern struct sockaddr_in data_dest;
extern int logged_in;
extern struct passwd *pw;
@@ -100,10 +105,23 @@ static int cmd_bytesz;
char cbuf[512];
char *fromname;
struct tab {
const char *name;
short token;
short state;
short implemented; /* 1 if command is implemented */
const char *help;
};
static char * copy(const char *);
#ifdef YYBISON
static void sizecmd(char *filename);
static void help(struct tab *ctab, char *s);
struct tab cmdtab[];
struct tab sitetab[];
#endif
static void
yyerror(const char *msg)
{
@@ -111,6 +129,28 @@ yyerror(const char *msg)
}
%}
%union
{
int ival;
char *sval;
}
%token <ival> NUMBER
%token <sval> STRING
%type <ival>
byte_size
check_login
form_code
mode_code
octal_number
struct_code
%type <sval>
password
pathname
pathstring
username
%token
A B C E F I
L N P R S T
@@ -135,24 +175,24 @@ yyerror(const char *msg)
cmd_list: /* empty */
| cmd_list cmd
= {
{
fromname = (char *) 0;
}
| cmd_list rcmd
;
cmd: USER SP username CRLF
= {
user((char *) $3);
free((char *) $3);
{
user($3);
free($3);
}
| PASS SP password CRLF
= {
pass((char *) $3);
free((char *) $3);
{
pass($3);
free($3);
}
| PORT SP host_port CRLF
= {
{
usedefault = 0;
if (pdata >= 0) {
(void) close(pdata);
@@ -161,11 +201,11 @@ cmd: USER SP username CRLF
reply(200, "PORT command successful.");
}
| PASV CRLF
= {
{
passive();
}
| TYPE SP type_code CRLF
= {
{
switch (cmd_type) {
case TYPE_A:
@@ -200,7 +240,7 @@ cmd: USER SP username CRLF
}
}
| STRU SP struct_code CRLF
= {
{
switch ($3) {
case STRU_F:
@@ -212,7 +252,7 @@ cmd: USER SP username CRLF
}
}
| MODE SP mode_code CRLF
= {
{
switch ($3) {
case MODE_S:
@@ -224,78 +264,78 @@ cmd: USER SP username CRLF
}
}
| ALLO SP NUMBER CRLF
= {
{
reply(202, "ALLO command ignored.");
}
| ALLO SP NUMBER SP R SP NUMBER CRLF
= {
{
reply(202, "ALLO command ignored.");
}
| RETR check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
retrieve((char *) 0, (char *) $4);
retrieve((char *) 0, $4);
if ($4 != 0)
free((char *) $4);
free($4);
}
| STOR check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
store((char *) $4, "w", 0);
store($4, "w", 0);
if ($4 != 0)
free((char *) $4);
free($4);
}
| APPE check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
store((char *) $4, "a", 0);
store($4, "a", 0);
if ($4 != 0)
free((char *) $4);
free($4);
}
| NLST check_login CRLF
= {
{
if ($2)
send_file_list(".");
}
| NLST check_login SP STRING CRLF
= {
{
if ($2 && $4 != 0)
send_file_list((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| LIST check_login CRLF
= {
{
if ($2)
retrieve("/bin/ls -lgA", "");
}
| LIST check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
retrieve("/bin/ls -lgA %s", (char *) $4);
retrieve("/bin/ls -lgA %s", $4);
if ($4 != 0)
free((char *) $4);
free($4);
}
| STAT check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
statfilecmd((char *) $4);
statfilecmd($4);
if ($4 != 0)
free((char *) $4);
free($4);
}
| STAT CRLF
= {
{
statcmd();
}
| DELE check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
remove((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| RNTO SP pathname CRLF
= {
{
if (fromname) {
renamecmd(fromname, (char *) $3);
free(fromname);
@@ -306,27 +346,27 @@ cmd: USER SP username CRLF
free((char *) $3);
}
| ABOR CRLF
= {
{
reply(225, "ABOR command successful.");
}
| CWD check_login CRLF
= {
{
if ($2)
cwd(pw->pw_dir);
}
| CWD check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
cwd((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| HELP CRLF
= {
{
help(cmdtab, (char *) 0);
}
| HELP SP STRING CRLF
= {
{
register char *cp = (char *)$3;
if (strncasecmp(cp, "SITE", 4) == 0) {
@@ -341,43 +381,43 @@ cmd: USER SP username CRLF
help(cmdtab, (char *) $3);
}
| NOOP CRLF
= {
{
reply(200, "NOOP command successful.");
}
| MKD check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
makedir((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| RMD check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
removedir((char *) $4);
if ($4 != 0)
free((char *) $4);
}
| PWD check_login CRLF
= {
{
if ($2)
pwd();
}
| CDUP check_login CRLF
= {
{
if ($2)
cwd("..");
}
| SITE SP HELP CRLF
= {
{
help(sitetab, (char *) 0);
}
| SITE SP HELP SP STRING CRLF
= {
{
help(sitetab, (char *) $5);
}
| SITE SP UMASK check_login CRLF
= {
{
int oldmask;
if ($4) {
@@ -387,7 +427,7 @@ cmd: USER SP username CRLF
}
}
| SITE SP UMASK check_login SP octal_number CRLF
= {
{
int oldmask;
if ($4) {
@@ -402,7 +442,7 @@ cmd: USER SP username CRLF
}
}
| SITE SP CHMOD check_login SP octal_number SP pathname CRLF
= {
{
if ($4 && ($8 != 0)) {
if ($6 > 0777)
reply(501,
@@ -416,13 +456,13 @@ cmd: USER SP username CRLF
free((char *) $8);
}
| SITE SP IDLE CRLF
= {
{
reply(200,
"Current IDLE time limit is %d seconds; max %d",
timeout, maxtimeout);
}
| SITE SP IDLE SP NUMBER CRLF
= {
{
if ($5 < 30 || $5 > maxtimeout) {
reply(501,
"Maximum IDLE time must be between 30 and %d seconds",
@@ -436,14 +476,14 @@ cmd: USER SP username CRLF
}
}
| STOU check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
store((char *) $4, "w", 1);
if ($4 != 0)
free((char *) $4);
}
| SYST CRLF
= {
{
#ifdef unix
#ifdef BSD
reply(215, "UNIX Type: L%d Version: BSD-%d",
@@ -464,7 +504,7 @@ cmd: USER SP username CRLF
* using with RESTART (we just count bytes).
*/
| SIZE check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0)
sizecmd((char *) $4);
if ($4 != 0)
@@ -481,7 +521,7 @@ cmd: USER SP username CRLF
* not necessarily 3 digits)
*/
| MDTM check_login SP pathname CRLF
= {
{
if ($2 && $4 != 0) {
struct stat stbuf;
if (stat((char *) $4, &stbuf) < 0)
@@ -503,17 +543,17 @@ cmd: USER SP username CRLF
free((char *) $4);
}
| QUIT CRLF
= {
{
reply(221, "Goodbye.");
dologout(0);
}
| error CRLF
= {
{
yyerrok;
}
;
rcmd: RNFR check_login SP pathname CRLF
= {
{
if ($2 && $4) {
fromname = renamefrom((char *) $4);
if (fromname == (char *) 0 && $4) {
@@ -527,7 +567,7 @@ username: STRING
;
password: /* empty */
= {
{
*(const char **)(&($$)) = "";
}
| STRING
@@ -538,103 +578,107 @@ byte_size: NUMBER
host_port: NUMBER COMMA NUMBER COMMA NUMBER COMMA NUMBER COMMA
NUMBER COMMA NUMBER
= {
{
register char *a, *p;
a = (char *)&data_dest.sin_addr;
a[0] = $1; a[1] = $3; a[2] = $5; a[3] = $7;
a[0] = (char) $1;
a[1] = (char) $3;
a[2] = (char) $5;
a[3] = (char) $7;
p = (char *)&data_dest.sin_port;
p[0] = $9; p[1] = $11;
p[0] = (char) $9;
p[1] = (char) $11;
data_dest.sin_family = AF_INET;
}
;
form_code: N
= {
{
$$ = FORM_N;
}
| T
= {
{
$$ = FORM_T;
}
| C
= {
{
$$ = FORM_C;
}
;
type_code: A
= {
{
cmd_type = TYPE_A;
cmd_form = FORM_N;
}
| A SP form_code
= {
{
cmd_type = TYPE_A;
cmd_form = $3;
}
| E
= {
{
cmd_type = TYPE_E;
cmd_form = FORM_N;
}
| E SP form_code
= {
{
cmd_type = TYPE_E;
cmd_form = $3;
}
| I
= {
{
cmd_type = TYPE_I;
}
| L
= {
{
cmd_type = TYPE_L;
cmd_bytesz = NBBY;
}
| L SP byte_size
= {
{
cmd_type = TYPE_L;
cmd_bytesz = $3;
}
/* this is for a bug in the BBN ftp */
| L byte_size
= {
{
cmd_type = TYPE_L;
cmd_bytesz = $2;
}
;
struct_code: F
= {
{
$$ = STRU_F;
}
| R
= {
{
$$ = STRU_R;
}
| P
= {
{
$$ = STRU_P;
}
;
mode_code: S
= {
{
$$ = MODE_S;
}
| B
= {
{
$$ = MODE_B;
}
| C
= {
{
$$ = MODE_C;
}
;
pathname: pathstring
= {
{
/*
* Problem: this production is used for all pathname
* processing, but only gives a 550 error reply.
@@ -656,7 +700,7 @@ pathstring: STRING
;
octal_number: NUMBER
= {
{
register int ret, dec, multby, digit;
/*
@@ -681,7 +725,7 @@ octal_number: NUMBER
;
check_login: /* empty */
= {
{
if (logged_in)
$$ = 1;
else {
@@ -695,7 +739,6 @@ check_login: /* empty */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
extern jmp_buf errcatch;
@@ -712,14 +755,6 @@ static void upper(char *);
#define SITECMD 7 /* SITE command */
#define NSTR 8 /* Number followed by a string */
struct tab {
const char *name;
short token;
short state;
short implemented; /* 1 if command is implemented */
const char *help;
};
struct tab cmdtab[] = { /* In order defined in RFC 765 */
{ "USER", USER, STR1, 1, "<sp> username" },
{ "PASS", PASS, ZSTR1, 1, "<sp> password" },
@@ -839,7 +874,7 @@ get_line(char *s, int n, FILE *iop)
}
}
}
*cs++ = c;
*cs++ = (char) c;
if (--n <= 0 || c == '\n')
break;
}
@@ -897,7 +932,7 @@ yylex(void)
*cp = '\0';
}
if ((cp = strpbrk(cbuf, " \n")))
cpos = cp - cbuf;
cpos = (int) (cp - cbuf);
if (cpos == 0)
cpos = 4;
c = cbuf[cpos];
@@ -924,7 +959,7 @@ yylex(void)
}
cp = &cbuf[cpos];
if ((cp2 = strpbrk(cp, " \n")))
cpos = cp2 - cbuf;
cpos = (int) (cp2 - cbuf);
c = cbuf[cpos];
cbuf[cpos] = '\0';
upper(cp);
@@ -973,7 +1008,7 @@ yylex(void)
case STR2:
cp = &cbuf[cpos];
n = strlen(cp);
n = (int) strlen(cp);
cpos += n - 1;
/*
* Make sure the string is nonempty and \n terminated.
@@ -998,7 +1033,7 @@ yylex(void)
;
c = cbuf[cpos];
cbuf[cpos] = '\0';
yylval = atoi(cp);
yylval.ival = atoi(cp);
cbuf[cpos] = c;
state = STR1;
return (NUMBER);
@@ -1013,7 +1048,7 @@ yylex(void)
;
c = cbuf[cpos];
cbuf[cpos] = '\0';
yylval = atoi(cp);
yylval.ival = atoi(cp);
cbuf[cpos] = c;
return (NUMBER);
}
@@ -1125,7 +1160,7 @@ help(struct tab *ctab, char *s)
help_type = "";
width = 0, NCMDS = 0;
for (c = ctab; c->name != 0; c++) {
int len = strlen(c->name);
int len = (int) strlen(c->name);
if (len > width)
width = len;
@@ -1151,7 +1186,7 @@ help(struct tab *ctab, char *s)
c->implemented ? ' ' : '*');
if (c + lines >= &ctab[NCMDS])
break;
w = strlen(c->name) + 1;
w = (int) strlen(c->name) + 1;
while (w < width) {
putchar(' ');
w++;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: grammar.tab.c,v 1.1.1.4 2011/09/10 21:22:10 christos Exp $ */
/* $NetBSD: grammar.tab.c,v 1.1.1.5 2013/04/06 14:45:29 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
@@ -97,7 +97,17 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#define YYPURE 0
#line 69 "grammar.y"
#line 9 "grammar.y"
#ifdef YYBISON
#include <stdlib.h>
#define YYSTYPE_IS_DECLARED
#define yyerror yaccError
#endif
#if defined(YYBISON) || !defined(YYBYACC)
static void yyerror(const char *s);
#endif
#line 81 "grammar.y"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
@@ -300,8 +310,6 @@ extern boolean file_comments;
extern FuncDefStyle func_style;
extern char base_file[];
#define YYMAXDEPTH 150
extern int yylex (void);
/* declaration specifier attributes for the typedef statement currently being
@@ -376,7 +384,7 @@ haveAnsiParam (void)
}
return FALSE;
}
#line 378 "grammar.tab.c"
#line 386 "grammar.tab.c"
/* compatibility with bison */
#ifdef YYPARSE_PARAM
@@ -400,8 +408,12 @@ haveAnsiParam (void)
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
@@ -900,7 +912,7 @@ typedef struct {
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 1004 "grammar.y"
#line 1014 "grammar.y"
/* lex.yy.c */
#define BEGIN yy_start = 1 + 2 *
@@ -1071,7 +1083,7 @@ free_parser(void)
#endif
}
#endif
#line 1073 "grammar.tab.c"
#line 1085 "grammar.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -1095,7 +1107,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
@@ -1278,19 +1290,19 @@ yyreduce:
switch (yyn)
{
case 10:
#line 367 "grammar.y"
#line 377 "grammar.y"
{
yyerrok;
}
break;
case 11:
#line 371 "grammar.y"
#line 381 "grammar.y"
{
yyerrok;
}
break;
case 13:
#line 382 "grammar.y"
#line 392 "grammar.y"
{
/* Provide an empty action here so bison will not complain about
* incompatible types in the default action it normally would
@@ -1299,13 +1311,13 @@ case 13:
}
break;
case 14:
#line 389 "grammar.y"
#line 399 "grammar.y"
{
/* empty */
}
break;
case 15:
#line 396 "grammar.y"
#line 406 "grammar.y"
{
#if OPT_LINTLIBRARY
if (types_out && want_typedef()) {
@@ -1318,7 +1330,7 @@ case 15:
}
break;
case 16:
#line 407 "grammar.y"
#line 417 "grammar.y"
{
if (func_params != NULL) {
set_param_types(func_params, &yystack.l_mark[-2].decl_spec, &yystack.l_mark[-1].decl_list);
@@ -1334,32 +1346,32 @@ case 16:
}
break;
case 17:
#line 421 "grammar.y"
#line 431 "grammar.y"
{
cur_decl_spec_flags = yystack.l_mark[0].decl_spec.flags;
free_decl_spec(&yystack.l_mark[0].decl_spec);
}
break;
case 18:
#line 426 "grammar.y"
#line 436 "grammar.y"
{
end_typedef();
}
break;
case 19:
#line 433 "grammar.y"
#line 443 "grammar.y"
{
begin_typedef();
}
break;
case 20:
#line 437 "grammar.y"
#line 447 "grammar.y"
{
begin_typedef();
}
break;
case 23:
#line 449 "grammar.y"
#line 459 "grammar.y"
{
int flags = cur_decl_spec_flags;
@@ -1373,7 +1385,7 @@ case 23:
}
break;
case 24:
#line 461 "grammar.y"
#line 471 "grammar.y"
{
int flags = cur_decl_spec_flags;
@@ -1384,7 +1396,7 @@ case 24:
}
break;
case 25:
#line 473 "grammar.y"
#line 483 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
@@ -1397,7 +1409,7 @@ case 25:
}
break;
case 26:
#line 484 "grammar.y"
#line 494 "grammar.y"
{
/* If we're converting to K&R and we've got a nominally K&R
* function which has a parameter which is ANSI (i.e., a prototyped
@@ -1423,7 +1435,7 @@ case 26:
}
break;
case 28:
#line 509 "grammar.y"
#line 519 "grammar.y"
{
if (yystack.l_mark[0].declarator->func_def == FUNC_NONE) {
yyerror("syntax error");
@@ -1435,7 +1447,7 @@ case 28:
}
break;
case 29:
#line 519 "grammar.y"
#line 529 "grammar.y"
{
DeclSpec decl_spec;
@@ -1453,7 +1465,7 @@ case 29:
}
break;
case 36:
#line 550 "grammar.y"
#line 560 "grammar.y"
{
join_decl_specs(&yyval.decl_spec, &yystack.l_mark[-1].decl_spec, &yystack.l_mark[0].decl_spec);
free(yystack.l_mark[-1].decl_spec.text);
@@ -1461,115 +1473,115 @@ case 36:
}
break;
case 40:
#line 565 "grammar.y"
#line 575 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 41:
#line 569 "grammar.y"
#line 579 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_EXTERN);
}
break;
case 42:
#line 573 "grammar.y"
#line 583 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 43:
#line 577 "grammar.y"
#line 587 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_STATIC);
}
break;
case 44:
#line 581 "grammar.y"
#line 591 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_INLINE);
}
break;
case 45:
#line 585 "grammar.y"
#line 595 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_JUNK);
}
break;
case 46:
#line 592 "grammar.y"
#line 602 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
}
break;
case 47:
#line 596 "grammar.y"
#line 606 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 48:
#line 600 "grammar.y"
#line 610 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_FLOAT);
}
break;
case 49:
#line 604 "grammar.y"
#line 614 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 50:
#line 608 "grammar.y"
#line 618 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 51:
#line 612 "grammar.y"
#line 622 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_SHORT);
}
break;
case 52:
#line 616 "grammar.y"
#line 626 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 53:
#line 620 "grammar.y"
#line 630 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 54:
#line 624 "grammar.y"
#line 634 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 55:
#line 628 "grammar.y"
#line 638 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_CHAR);
}
break;
case 56:
#line 632 "grammar.y"
#line 642 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 57:
#line 636 "grammar.y"
#line 646 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 58:
#line 640 "grammar.y"
#line 650 "grammar.y"
{
Symbol *s;
s = find_symbol(typedef_names, yystack.l_mark[0].text.text);
@@ -1578,13 +1590,13 @@ case 58:
}
break;
case 61:
#line 652 "grammar.y"
#line 662 "grammar.y"
{
new_decl_spec(&yyval.decl_spec, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin, DS_NONE);
}
break;
case 62:
#line 656 "grammar.y"
#line 666 "grammar.y"
{
/* This rule allows the <pointer> nonterminal to scan #define
* names as if they were type modifiers.
@@ -1596,7 +1608,7 @@ case 62:
}
break;
case 63:
#line 669 "grammar.y"
#line 679 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
@@ -1605,7 +1617,7 @@ case 63:
}
break;
case 64:
#line 676 "grammar.y"
#line 686 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
@@ -1614,38 +1626,38 @@ case 64:
}
break;
case 65:
#line 683 "grammar.y"
#line 693 "grammar.y"
{
(void)sprintf(buf, "%s %s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 66:
#line 691 "grammar.y"
#line 701 "grammar.y"
{
imply_typedef(yyval.text.text);
}
break;
case 67:
#line 695 "grammar.y"
#line 705 "grammar.y"
{
imply_typedef(yyval.text.text);
}
break;
case 68:
#line 702 "grammar.y"
#line 712 "grammar.y"
{
new_decl_list(&yyval.decl_list, yystack.l_mark[0].declarator);
}
break;
case 69:
#line 706 "grammar.y"
#line 716 "grammar.y"
{
add_decl_list(&yyval.decl_list, &yystack.l_mark[-2].decl_list, yystack.l_mark[0].declarator);
}
break;
case 70:
#line 713 "grammar.y"
#line 723 "grammar.y"
{
if (yystack.l_mark[0].declarator->func_def != FUNC_NONE && func_params == NULL &&
func_style == FUNC_TRADITIONAL && cur_file->convert) {
@@ -1656,7 +1668,7 @@ case 70:
}
break;
case 71:
#line 722 "grammar.y"
#line 732 "grammar.y"
{
if (yystack.l_mark[-1].declarator->func_def != FUNC_NONE && func_params == NULL &&
func_style == FUNC_TRADITIONAL && cur_file->convert) {
@@ -1666,7 +1678,7 @@ case 71:
}
break;
case 73:
#line 734 "grammar.y"
#line 744 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
@@ -1675,7 +1687,7 @@ case 73:
}
break;
case 74:
#line 741 "grammar.y"
#line 751 "grammar.y"
{
char *s;
if ((s = implied_typedef()) == 0)
@@ -1684,21 +1696,21 @@ case 74:
}
break;
case 75:
#line 748 "grammar.y"
#line 758 "grammar.y"
{
(void)sprintf(buf, "enum %s", yystack.l_mark[0].text.text);
new_decl_spec(&yyval.decl_spec, buf, yystack.l_mark[-1].text.begin, DS_NONE);
}
break;
case 76:
#line 756 "grammar.y"
#line 766 "grammar.y"
{
imply_typedef("enum");
yyval.text = yystack.l_mark[0].text;
}
break;
case 79:
#line 769 "grammar.y"
#line 779 "grammar.y"
{
yyval.declarator = yystack.l_mark[0].declarator;
(void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
@@ -1709,13 +1721,13 @@ case 79:
}
break;
case 81:
#line 782 "grammar.y"
#line 792 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, yystack.l_mark[0].text.text, yystack.l_mark[0].text.begin);
}
break;
case 82:
#line 786 "grammar.y"
#line 796 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
(void)sprintf(buf, "(%s)", yyval.declarator->text);
@@ -1725,7 +1737,7 @@ case 82:
}
break;
case 83:
#line 794 "grammar.y"
#line 804 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
(void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
@@ -1734,7 +1746,7 @@ case 83:
}
break;
case 84:
#line 801 "grammar.y"
#line 811 "grammar.y"
{
yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -1744,7 +1756,7 @@ case 84:
}
break;
case 85:
#line 809 "grammar.y"
#line 819 "grammar.y"
{
yyval.declarator = new_declarator("%s()", yystack.l_mark[-3].declarator->name, yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -1754,28 +1766,28 @@ case 85:
}
break;
case 86:
#line 820 "grammar.y"
#line 830 "grammar.y"
{
(void)sprintf(yyval.text.text, "*%s", yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
}
break;
case 87:
#line 825 "grammar.y"
#line 835 "grammar.y"
{
(void)sprintf(yyval.text.text, "*%s%s", yystack.l_mark[-1].text.text, yystack.l_mark[0].text.text);
yyval.text.begin = yystack.l_mark[-2].text.begin;
}
break;
case 88:
#line 833 "grammar.y"
#line 843 "grammar.y"
{
strcpy(yyval.text.text, "");
yyval.text.begin = 0L;
}
break;
case 90:
#line 842 "grammar.y"
#line 852 "grammar.y"
{
(void)sprintf(yyval.text.text, "%s ", yystack.l_mark[0].decl_spec.text);
yyval.text.begin = yystack.l_mark[0].decl_spec.begin;
@@ -1783,7 +1795,7 @@ case 90:
}
break;
case 91:
#line 848 "grammar.y"
#line 858 "grammar.y"
{
(void)sprintf(yyval.text.text, "%s%s ", yystack.l_mark[-1].text.text, yystack.l_mark[0].decl_spec.text);
yyval.text.begin = yystack.l_mark[-1].text.begin;
@@ -1791,71 +1803,71 @@ case 91:
}
break;
case 93:
#line 858 "grammar.y"
#line 868 "grammar.y"
{
add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, "...");
}
break;
case 94:
#line 865 "grammar.y"
#line 875 "grammar.y"
{
new_param_list(&yyval.param_list, yystack.l_mark[0].parameter);
}
break;
case 95:
#line 869 "grammar.y"
#line 879 "grammar.y"
{
add_param_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].parameter);
}
break;
case 96:
#line 876 "grammar.y"
#line 886 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
}
break;
case 97:
#line 881 "grammar.y"
#line 891 "grammar.y"
{
check_untagged(&yystack.l_mark[-1].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[-1].decl_spec, yystack.l_mark[0].declarator);
}
break;
case 98:
#line 886 "grammar.y"
#line 896 "grammar.y"
{
check_untagged(&yystack.l_mark[0].decl_spec);
yyval.parameter = new_parameter(&yystack.l_mark[0].decl_spec, (Declarator *)0);
}
break;
case 99:
#line 894 "grammar.y"
#line 904 "grammar.y"
{
new_ident_list(&yyval.param_list);
}
break;
case 101:
#line 902 "grammar.y"
#line 912 "grammar.y"
{
new_ident_list(&yyval.param_list);
add_ident_list(&yyval.param_list, &yyval.param_list, yystack.l_mark[0].text.text);
}
break;
case 102:
#line 907 "grammar.y"
#line 917 "grammar.y"
{
add_ident_list(&yyval.param_list, &yystack.l_mark[-2].param_list, yystack.l_mark[0].text.text);
}
break;
case 103:
#line 914 "grammar.y"
#line 924 "grammar.y"
{
yyval.text = yystack.l_mark[0].text;
}
break;
case 104:
#line 918 "grammar.y"
#line 928 "grammar.y"
{
#if OPT_LINTLIBRARY
if (lintLibrary()) { /* Lint doesn't grok C++ ref variables */
@@ -1867,13 +1879,13 @@ case 104:
}
break;
case 105:
#line 931 "grammar.y"
#line 941 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
}
break;
case 106:
#line 935 "grammar.y"
#line 945 "grammar.y"
{
yyval.declarator = yystack.l_mark[0].declarator;
(void)sprintf(buf, "%s%s", yystack.l_mark[-1].text.text, yyval.declarator->text);
@@ -1883,7 +1895,7 @@ case 106:
}
break;
case 108:
#line 947 "grammar.y"
#line 957 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
(void)sprintf(buf, "(%s)", yyval.declarator->text);
@@ -1893,7 +1905,7 @@ case 108:
}
break;
case 109:
#line 955 "grammar.y"
#line 965 "grammar.y"
{
yyval.declarator = yystack.l_mark[-1].declarator;
(void)sprintf(buf, "%s%s", yyval.declarator->text, yystack.l_mark[0].text.text);
@@ -1902,13 +1914,13 @@ case 109:
}
break;
case 110:
#line 962 "grammar.y"
#line 972 "grammar.y"
{
yyval.declarator = new_declarator(yystack.l_mark[0].text.text, "", yystack.l_mark[0].text.begin);
}
break;
case 111:
#line 966 "grammar.y"
#line 976 "grammar.y"
{
yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-3].declarator->begin);
yyval.declarator->params = yystack.l_mark[-1].param_list;
@@ -1918,7 +1930,7 @@ case 111:
}
break;
case 112:
#line 974 "grammar.y"
#line 984 "grammar.y"
{
yyval.declarator = new_declarator("%s()", "", yystack.l_mark[-2].declarator->begin);
yyval.declarator->func_stack = yystack.l_mark[-2].declarator;
@@ -1927,7 +1939,7 @@ case 112:
}
break;
case 113:
#line 981 "grammar.y"
#line 991 "grammar.y"
{
Declarator *d;
@@ -1940,7 +1952,7 @@ case 113:
}
break;
case 114:
#line 992 "grammar.y"
#line 1002 "grammar.y"
{
Declarator *d;
@@ -1951,7 +1963,7 @@ case 114:
yyval.declarator->func_def = FUNC_ANSI;
}
break;
#line 1953 "grammar.tab.c"
#line 1965 "grammar.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;

View File

@@ -1,12 +1,24 @@
/* $NetBSD: grammar.y,v 1.1.1.4 2011/09/10 21:22:07 christos Exp $ */
/* $NetBSD: grammar.y,v 1.1.1.5 2013/04/06 14:45:27 christos Exp $ */
/* Id: grammar.y,v 1.3 2010/11/23 01:28:47 tom Exp
/* Id: grammar.y,v 1.5 2012/01/15 20:00:59 tom Exp
*
* yacc grammar for C function prototype generator
* This was derived from the grammar in Appendix A of
* "The C Programming Language" by Kernighan and Ritchie.
*/
%expect 1
%{
#ifdef YYBISON
#include <stdlib.h>
#define YYSTYPE_IS_DECLARED
#define yyerror yaccError
#endif
#if defined(YYBISON) || !defined(YYBYACC)
static void yyerror(const char *s);
#endif
%}
%token <text> '(' '*' '&'
/* identifiers that are not reserved words */
T_IDENTIFIER T_TYPEDEF_NAME T_DEFINE_NAME
@@ -270,8 +282,6 @@ extern boolean file_comments;
extern FuncDefStyle func_style;
extern char base_file[];
#define YYMAXDEPTH 150
extern int yylex (void);
/* declaration specifier attributes for the typedef statement currently being

View File

@@ -1,4 +1,4 @@
/* $NetBSD: pure_calc.tab.c,v 1.1.1.3 2011/09/10 21:22:03 christos Exp $ */
/* $NetBSD: pure_calc.tab.c,v 1.1.1.4 2013/04/06 14:45:28 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
@@ -104,7 +104,16 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
int regs[26];
int base;
#line 106 "pure_calc.tab.c"
#ifdef YYBISON
#define YYSTYPE int
#define YYLEX_PARAM &yylval
#define YYLEX_DECL() yylex(YYSTYPE *yylval)
#define YYERROR_DECL() yyerror(const char *s)
int YYLEX_DECL();
static void YYERROR_DECL();
#endif
#line 115 "pure_calc.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -124,7 +133,11 @@ typedef int YYSTYPE;
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
# ifdef YYLEX_PARAM_TYPE
# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
# else
# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
# endif
# define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(YYSTYPE *yylval)
@@ -132,8 +145,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
@@ -289,12 +306,11 @@ typedef struct {
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
#line 63 "pure_calc.y"
#line 72 "pure_calc.y"
/* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
static int YYLEX_DECL();
#endif
int
@@ -307,13 +323,13 @@ main (void)
}
static void
yyerror(const char *s)
YYERROR_DECL()
{
fprintf(stderr, "%s\n", s);
}
int
yylex(YYSTYPE *value)
YYLEX_DECL()
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
@@ -327,16 +343,16 @@ yylex(YYSTYPE *value)
/* c is now nonblank */
if( islower( c )) {
*value = c - 'a';
*yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
*value = c - '0';
*yylval = c - '0';
return ( DIGIT );
}
return( c );
}
#line 338 "pure_calc.tab.c"
#line 354 "pure_calc.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -360,7 +376,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
@@ -550,66 +566,66 @@ yyreduce:
switch (yyn)
{
case 3:
#line 25 "pure_calc.y"
#line 34 "pure_calc.y"
{ yyerrok ; }
break;
case 4:
#line 29 "pure_calc.y"
#line 38 "pure_calc.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 31 "pure_calc.y"
#line 40 "pure_calc.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 35 "pure_calc.y"
#line 44 "pure_calc.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 37 "pure_calc.y"
#line 46 "pure_calc.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 39 "pure_calc.y"
#line 48 "pure_calc.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 41 "pure_calc.y"
#line 50 "pure_calc.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 43 "pure_calc.y"
#line 52 "pure_calc.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 45 "pure_calc.y"
#line 54 "pure_calc.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 47 "pure_calc.y"
#line 56 "pure_calc.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 49 "pure_calc.y"
#line 58 "pure_calc.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 51 "pure_calc.y"
#line 60 "pure_calc.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 53 "pure_calc.y"
#line 62 "pure_calc.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 58 "pure_calc.y"
#line 67 "pure_calc.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 60 "pure_calc.y"
#line 69 "pure_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 611 "pure_calc.tab.c"
#line 627 "pure_calc.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;

View File

@@ -1,4 +1,4 @@
/* $NetBSD: pure_calc.y,v 1.1.1.3 2011/09/10 21:22:10 christos Exp $ */
/* $NetBSD: pure_calc.y,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */
%{
# include <stdio.h>
@@ -7,6 +7,15 @@
int regs[26];
int base;
#ifdef YYBISON
#define YYSTYPE int
#define YYLEX_PARAM &yylval
#define YYLEX_DECL() yylex(YYSTYPE *yylval)
#define YYERROR_DECL() yyerror(const char *s)
int YYLEX_DECL();
static void YYERROR_DECL();
#endif
%}
%start list
@@ -65,8 +74,7 @@ number: DIGIT
%% /* start of programs */
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
static int YYLEX_DECL();
#endif
int
@@ -79,13 +87,13 @@ main (void)
}
static void
yyerror(const char *s)
YYERROR_DECL()
{
fprintf(stderr, "%s\n", s);
}
int
yylex(YYSTYPE *value)
YYLEX_DECL()
{
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
@@ -99,11 +107,11 @@ yylex(YYSTYPE *value)
/* c is now nonblank */
if( islower( c )) {
*value = c - 'a';
*yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
*value = c - '0';
*yylval = c - '0';
return ( DIGIT );
}
return( c );

View File

@@ -1,4 +1,4 @@
/* $NetBSD: pure_error.tab.c,v 1.1.1.3 2011/09/10 21:22:04 christos Exp $ */
/* $NetBSD: pure_error.tab.c,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
@@ -97,6 +97,18 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#define YYPURE 1
#line 2 "pure_error.y"
#ifdef YYBISON
#define YYSTYPE int
#define YYLEX_PARAM &yylval
#define YYLEX_DECL() yylex(YYSTYPE *yylval)
#define YYERROR_DECL() yyerror(const char *s)
int YYLEX_DECL();
static void YYERROR_DECL();
#endif
#line 110 "pure_error.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
@@ -116,7 +128,11 @@ typedef int YYSTYPE;
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(YYSTYPE *yylval, void *YYLEX_PARAM)
# ifdef YYLEX_PARAM_TYPE
# define YYLEX_DECL() yylex(YYSTYPE *yylval, YYLEX_PARAM_TYPE YYLEX_PARAM)
# else
# define YYLEX_DECL() yylex(YYSTYPE *yylval, void * YYLEX_PARAM)
# endif
# define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(YYSTYPE *yylval)
@@ -124,8 +140,12 @@ typedef int YYSTYPE;
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
@@ -197,13 +217,12 @@ typedef struct {
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
#line 4 "pure_error.y"
#line 17 "pure_error.y"
#include <stdio.h>
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int
@@ -224,7 +243,7 @@ yyerror(const char* s)
{
printf("%s\n", s);
}
#line 226 "pure_error.tab.c"
#line 245 "pure_error.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
@@ -248,7 +267,7 @@ static int yygrowstack(YYSTACKDATA *data)
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = data->s_mark - data->s_base;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;

View File

@@ -1,4 +1,17 @@
/* $NetBSD: pure_error.y,v 1.1.1.3 2011/09/10 21:22:05 christos Exp $ */
/* $NetBSD: pure_error.y,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */
%{
#ifdef YYBISON
#define YYSTYPE int
#define YYLEX_PARAM &yylval
#define YYLEX_DECL() yylex(YYSTYPE *yylval)
#define YYERROR_DECL() yyerror(const char *s)
int YYLEX_DECL();
static void YYERROR_DECL();
#endif
%}
%%
S: error
@@ -8,7 +21,6 @@ S: error
#ifdef YYBYACC
extern int YYLEX_DECL();
static void YYERROR_DECL();
#endif
int

View File

@@ -0,0 +1,557 @@
0 $accept : list $end
1 list :
2 | list stat '\n'
3 | list error '\n'
4 stat : expr
5 | LETTER '=' expr
6 expr : '(' expr ')'
7 | expr OP_ADD expr
8 | expr OP_SUB expr
9 | expr OP_MUL expr
10 | expr OP_DIV expr
11 | expr OP_MOD expr
12 | expr OP_AND expr
13 | expr '|' expr
14 | OP_SUB expr
15 | LETTER
16 | number
17 number : DIGIT
18 | number DIGIT
state 0
$accept : . list $end (0)
list : . (1)
. reduce 1
list goto 1
state 1
$accept : list . $end (0)
list : list . stat '\n' (2)
list : list . error '\n' (3)
$end accept
error shift 2
OP_SUB shift 3
DIGIT shift 4
LETTER shift 5
'(' shift 6
. error
stat goto 7
expr goto 8
number goto 9
state 2
list : list error . '\n' (3)
'\n' shift 10
. error
state 3
expr : OP_SUB . expr (14)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 12
number goto 9
state 4
number : DIGIT . (17)
. reduce 17
state 5
stat : LETTER . '=' expr (5)
expr : LETTER . (15)
'=' shift 13
OP_ADD reduce 15
OP_SUB reduce 15
OP_MUL reduce 15
OP_DIV reduce 15
OP_MOD reduce 15
OP_AND reduce 15
'|' reduce 15
'\n' reduce 15
state 6
expr : '(' . expr ')' (6)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 14
number goto 9
state 7
list : list stat . '\n' (2)
'\n' shift 15
. error
state 8
stat : expr . (4)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 4
state 9
expr : number . (16)
number : number . DIGIT (18)
DIGIT shift 23
OP_ADD reduce 16
OP_SUB reduce 16
OP_MUL reduce 16
OP_DIV reduce 16
OP_MOD reduce 16
OP_AND reduce 16
'|' reduce 16
'\n' reduce 16
')' reduce 16
state 10
list : list error '\n' . (3)
. reduce 3
state 11
expr : LETTER . (15)
. reduce 15
12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD
12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB
12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL
12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV
12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD
12: shift/reduce conflict (shift 21, reduce 14) on OP_AND
state 12
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
expr : OP_SUB expr . (14)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' reduce 14
'\n' reduce 14
')' reduce 14
state 13
stat : LETTER '=' . expr (5)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 24
number goto 9
state 14
expr : '(' expr . ')' (6)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
')' shift 25
. error
state 15
list : list stat '\n' . (2)
. reduce 2
state 16
expr : expr OP_ADD . expr (7)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 26
number goto 9
state 17
expr : expr OP_SUB . expr (8)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 27
number goto 9
state 18
expr : expr OP_MUL . expr (9)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 28
number goto 9
state 19
expr : expr OP_DIV . expr (10)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 29
number goto 9
state 20
expr : expr OP_MOD . expr (11)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 30
number goto 9
state 21
expr : expr OP_AND . expr (12)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 31
number goto 9
state 22
expr : expr '|' . expr (13)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 32
number goto 9
state 23
number : number DIGIT . (18)
. reduce 18
state 24
stat : LETTER '=' expr . (5)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 5
state 25
expr : '(' expr ')' . (6)
. reduce 6
26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD
26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB
26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL
26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV
26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD
26: shift/reduce conflict (shift 21, reduce 7) on OP_AND
26: shift/reduce conflict (shift 22, reduce 7) on '|'
state 26
expr : expr . OP_ADD expr (7)
expr : expr OP_ADD expr . (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 7
')' reduce 7
27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD
27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB
27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL
27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV
27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD
27: shift/reduce conflict (shift 21, reduce 8) on OP_AND
27: shift/reduce conflict (shift 22, reduce 8) on '|'
state 27
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr OP_SUB expr . (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 8
')' reduce 8
28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD
28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB
28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL
28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV
28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD
28: shift/reduce conflict (shift 21, reduce 9) on OP_AND
28: shift/reduce conflict (shift 22, reduce 9) on '|'
state 28
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr OP_MUL expr . (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 9
')' reduce 9
29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD
29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB
29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL
29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV
29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD
29: shift/reduce conflict (shift 21, reduce 10) on OP_AND
29: shift/reduce conflict (shift 22, reduce 10) on '|'
state 29
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr OP_DIV expr . (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 10
')' reduce 10
30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD
30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB
30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL
30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV
30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD
30: shift/reduce conflict (shift 21, reduce 11) on OP_AND
30: shift/reduce conflict (shift 22, reduce 11) on '|'
state 30
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr OP_MOD expr . (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 11
')' reduce 11
31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD
31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB
31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL
31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV
31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD
31: shift/reduce conflict (shift 21, reduce 12) on OP_AND
31: shift/reduce conflict (shift 22, reduce 12) on '|'
state 31
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr OP_AND expr . (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 12
')' reduce 12
32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD
32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB
32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL
32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV
32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD
32: shift/reduce conflict (shift 21, reduce 13) on OP_AND
state 32
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
expr : expr '|' expr . (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' reduce 13
'\n' reduce 13
')' reduce 13
State 12 contains 6 shift/reduce conflicts.
State 26 contains 7 shift/reduce conflicts.
State 27 contains 7 shift/reduce conflicts.
State 28 contains 7 shift/reduce conflicts.
State 29 contains 7 shift/reduce conflicts.
State 30 contains 7 shift/reduce conflicts.
State 31 contains 7 shift/reduce conflicts.
State 32 contains 6 shift/reduce conflicts.
28 terminals, 5 nonterminals
19 grammar rules, 33 states

View File

@@ -0,0 +1,689 @@
/* $NetBSD: quote_calc-s.tab.c,v 1.1.1.1 2013/04/06 14:45:27 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#ifndef yyparse
#define yyparse quote_calc_parse
#endif /* yyparse */
#ifndef yylex
#define yylex quote_calc_lex
#endif /* yylex */
#ifndef yyerror
#define yyerror quote_calc_error
#endif /* yyerror */
#ifndef yychar
#define yychar quote_calc_char
#endif /* yychar */
#ifndef yyval
#define yyval quote_calc_val
#endif /* yyval */
#ifndef yylval
#define yylval quote_calc_lval
#endif /* yylval */
#ifndef yydebug
#define yydebug quote_calc_debug
#endif /* yydebug */
#ifndef yynerrs
#define yynerrs quote_calc_nerrs
#endif /* yynerrs */
#ifndef yyerrflag
#define yyerrflag quote_calc_errflag
#endif /* yyerrflag */
#ifndef yylhs
#define yylhs quote_calc_lhs
#endif /* yylhs */
#ifndef yylen
#define yylen quote_calc_len
#endif /* yylen */
#ifndef yydefred
#define yydefred quote_calc_defred
#endif /* yydefred */
#ifndef yydgoto
#define yydgoto quote_calc_dgoto
#endif /* yydgoto */
#ifndef yysindex
#define yysindex quote_calc_sindex
#endif /* yysindex */
#ifndef yyrindex
#define yyrindex quote_calc_rindex
#endif /* yyrindex */
#ifndef yygindex
#define yygindex quote_calc_gindex
#endif /* yygindex */
#ifndef yytable
#define yytable quote_calc_table
#endif /* yytable */
#ifndef yycheck
#define yycheck quote_calc_check
#endif /* yycheck */
#ifndef yyname
#define yyname quote_calc_name
#endif /* yyname */
#ifndef yyrule
#define yyrule quote_calc_rule
#endif /* yyrule */
#define YYPREFIX "quote_calc_"
#define YYPURE 0
#line 2 "quote_calc.y"
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
#line 109 "quote_calc-s.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271
#define YYERRCODE 256
static const short quote_calc_lhs[] = { -1,
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3,
};
static const short quote_calc_len[] = { 2,
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 2, 1, 1, 1, 2,
};
static const short quote_calc_defred[] = { 1,
0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
0, 0,
};
static const short quote_calc_dgoto[] = { 1,
7, 8, 9,
};
static const short quote_calc_sindex[] = { 0,
-38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
-36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
-121, -243,
};
static const short quote_calc_rindex[] = { 0,
0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
3, -4,
};
static const short quote_calc_gindex[] = { 0,
0, 42, 0,
};
#define YYTABLESIZE 258
static const short quote_calc_table[] = { 16,
15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
0, 19, 0, 20, 0, 21, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
16, 15, 16, 15, 16, 15, 16, 15,
};
static const short quote_calc_check[] = { 10,
10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
-1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
-1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 124, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
-1, 263, -1, 265, -1, 267, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
261, 261, 263, 263, 265, 265, 267, 267,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 271
#if YYDEBUG
static const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
};
static const char *yyrule[] = {
"$accept : list",
"list :",
"list : list stat '\\n'",
"list : list error '\\n'",
"stat : expr",
"stat : LETTER '=' expr",
"expr : '(' expr ')'",
"expr : expr OP_ADD expr",
"expr : expr OP_SUB expr",
"expr : expr OP_MUL expr",
"expr : expr OP_DIV expr",
"expr : expr OP_MOD expr",
"expr : expr OP_AND expr",
"expr : expr '|' expr",
"expr : OP_SUB expr",
"expr : LETTER",
"expr : number",
"number : DIGIT",
"number : number DIGIT",
};
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
typedef struct {
unsigned stacksize;
short *s_base;
short *s_mark;
short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 73 "quote_calc.y"
/* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}
#line 361 "quote_calc-s.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
data->l_base = newvs;
data->l_mark = newvs + i;
data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0;
}
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
YYPARSE_DECL()
{
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
yystate = 0;
#if YYPURE
memset(&yystack, 0, sizeof(yystack));
#endif
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0;
*yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
goto yyerrlab;
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yystack.s_mark);
#endif
if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yystack.s_mark;
--yystack.l_mark;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
if (yym)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 3:
#line 35 "quote_calc.y"
{ yyerrok ; }
break;
case 4:
#line 39 "quote_calc.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 41 "quote_calc.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 45 "quote_calc.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 47 "quote_calc.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 49 "quote_calc.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 51 "quote_calc.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 53 "quote_calc.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 55 "quote_calc.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 57 "quote_calc.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 59 "quote_calc.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 61 "quote_calc.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 63 "quote_calc.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 68 "quote_calc.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 70 "quote_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 627 "quote_calc-s.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yystack.s_mark = YYFINAL;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
*++yystack.s_mark = (short) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
yyfreestack(&yystack);
return (1);
yyaccept:
yyfreestack(&yystack);
return (0);
}

View File

@@ -0,0 +1,11 @@
/* $NetBSD: quote_calc-s.tab.h,v 1.1.1.1 2013/04/06 14:45:27 christos Exp $ */
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271

View File

@@ -0,0 +1,557 @@
0 $accept : list $end
1 list :
2 | list stat '\n'
3 | list error '\n'
4 stat : expr
5 | LETTER '=' expr
6 expr : '(' expr ')'
7 | expr OP_ADD expr
8 | expr OP_SUB expr
9 | expr OP_MUL expr
10 | expr OP_DIV expr
11 | expr OP_MOD expr
12 | expr OP_AND expr
13 | expr '|' expr
14 | OP_SUB expr
15 | LETTER
16 | number
17 number : DIGIT
18 | number DIGIT
state 0
$accept : . list $end (0)
list : . (1)
. reduce 1
list goto 1
state 1
$accept : list . $end (0)
list : list . stat '\n' (2)
list : list . error '\n' (3)
$end accept
error shift 2
OP_SUB shift 3
DIGIT shift 4
LETTER shift 5
'(' shift 6
. error
stat goto 7
expr goto 8
number goto 9
state 2
list : list error . '\n' (3)
'\n' shift 10
. error
state 3
expr : OP_SUB . expr (14)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 12
number goto 9
state 4
number : DIGIT . (17)
. reduce 17
state 5
stat : LETTER . '=' expr (5)
expr : LETTER . (15)
'=' shift 13
OP_ADD reduce 15
OP_SUB reduce 15
OP_MUL reduce 15
OP_DIV reduce 15
OP_MOD reduce 15
OP_AND reduce 15
'|' reduce 15
'\n' reduce 15
state 6
expr : '(' . expr ')' (6)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 14
number goto 9
state 7
list : list stat . '\n' (2)
'\n' shift 15
. error
state 8
stat : expr . (4)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 4
state 9
expr : number . (16)
number : number . DIGIT (18)
DIGIT shift 23
OP_ADD reduce 16
OP_SUB reduce 16
OP_MUL reduce 16
OP_DIV reduce 16
OP_MOD reduce 16
OP_AND reduce 16
'|' reduce 16
'\n' reduce 16
')' reduce 16
state 10
list : list error '\n' . (3)
. reduce 3
state 11
expr : LETTER . (15)
. reduce 15
12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD
12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB
12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL
12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV
12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD
12: shift/reduce conflict (shift 21, reduce 14) on OP_AND
state 12
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
expr : OP_SUB expr . (14)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' reduce 14
'\n' reduce 14
')' reduce 14
state 13
stat : LETTER '=' . expr (5)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 24
number goto 9
state 14
expr : '(' expr . ')' (6)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
')' shift 25
. error
state 15
list : list stat '\n' . (2)
. reduce 2
state 16
expr : expr OP_ADD . expr (7)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 26
number goto 9
state 17
expr : expr OP_SUB . expr (8)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 27
number goto 9
state 18
expr : expr OP_MUL . expr (9)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 28
number goto 9
state 19
expr : expr OP_DIV . expr (10)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 29
number goto 9
state 20
expr : expr OP_MOD . expr (11)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 30
number goto 9
state 21
expr : expr OP_AND . expr (12)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 31
number goto 9
state 22
expr : expr '|' . expr (13)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 32
number goto 9
state 23
number : number DIGIT . (18)
. reduce 18
state 24
stat : LETTER '=' expr . (5)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 5
state 25
expr : '(' expr ')' . (6)
. reduce 6
26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD
26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB
26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL
26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV
26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD
26: shift/reduce conflict (shift 21, reduce 7) on OP_AND
26: shift/reduce conflict (shift 22, reduce 7) on '|'
state 26
expr : expr . OP_ADD expr (7)
expr : expr OP_ADD expr . (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 7
')' reduce 7
27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD
27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB
27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL
27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV
27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD
27: shift/reduce conflict (shift 21, reduce 8) on OP_AND
27: shift/reduce conflict (shift 22, reduce 8) on '|'
state 27
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr OP_SUB expr . (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 8
')' reduce 8
28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD
28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB
28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL
28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV
28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD
28: shift/reduce conflict (shift 21, reduce 9) on OP_AND
28: shift/reduce conflict (shift 22, reduce 9) on '|'
state 28
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr OP_MUL expr . (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 9
')' reduce 9
29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD
29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB
29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL
29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV
29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD
29: shift/reduce conflict (shift 21, reduce 10) on OP_AND
29: shift/reduce conflict (shift 22, reduce 10) on '|'
state 29
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr OP_DIV expr . (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 10
')' reduce 10
30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD
30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB
30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL
30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV
30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD
30: shift/reduce conflict (shift 21, reduce 11) on OP_AND
30: shift/reduce conflict (shift 22, reduce 11) on '|'
state 30
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr OP_MOD expr . (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 11
')' reduce 11
31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD
31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB
31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL
31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV
31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD
31: shift/reduce conflict (shift 21, reduce 12) on OP_AND
31: shift/reduce conflict (shift 22, reduce 12) on '|'
state 31
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr OP_AND expr . (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 12
')' reduce 12
32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD
32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB
32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL
32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV
32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD
32: shift/reduce conflict (shift 21, reduce 13) on OP_AND
state 32
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
expr : expr '|' expr . (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' reduce 13
'\n' reduce 13
')' reduce 13
State 12 contains 6 shift/reduce conflicts.
State 26 contains 7 shift/reduce conflicts.
State 27 contains 7 shift/reduce conflicts.
State 28 contains 7 shift/reduce conflicts.
State 29 contains 7 shift/reduce conflicts.
State 30 contains 7 shift/reduce conflicts.
State 31 contains 7 shift/reduce conflicts.
State 32 contains 6 shift/reduce conflicts.
28 terminals, 5 nonterminals
19 grammar rules, 33 states

View File

@@ -0,0 +1,695 @@
/* $NetBSD: quote_calc.tab.c,v 1.1.1.1 2013/04/06 14:45:27 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#ifndef yyparse
#define yyparse quote_calc_parse
#endif /* yyparse */
#ifndef yylex
#define yylex quote_calc_lex
#endif /* yylex */
#ifndef yyerror
#define yyerror quote_calc_error
#endif /* yyerror */
#ifndef yychar
#define yychar quote_calc_char
#endif /* yychar */
#ifndef yyval
#define yyval quote_calc_val
#endif /* yyval */
#ifndef yylval
#define yylval quote_calc_lval
#endif /* yylval */
#ifndef yydebug
#define yydebug quote_calc_debug
#endif /* yydebug */
#ifndef yynerrs
#define yynerrs quote_calc_nerrs
#endif /* yynerrs */
#ifndef yyerrflag
#define yyerrflag quote_calc_errflag
#endif /* yyerrflag */
#ifndef yylhs
#define yylhs quote_calc_lhs
#endif /* yylhs */
#ifndef yylen
#define yylen quote_calc_len
#endif /* yylen */
#ifndef yydefred
#define yydefred quote_calc_defred
#endif /* yydefred */
#ifndef yydgoto
#define yydgoto quote_calc_dgoto
#endif /* yydgoto */
#ifndef yysindex
#define yysindex quote_calc_sindex
#endif /* yysindex */
#ifndef yyrindex
#define yyrindex quote_calc_rindex
#endif /* yyrindex */
#ifndef yygindex
#define yygindex quote_calc_gindex
#endif /* yygindex */
#ifndef yytable
#define yytable quote_calc_table
#endif /* yytable */
#ifndef yycheck
#define yycheck quote_calc_check
#endif /* yycheck */
#ifndef yyname
#define yyname quote_calc_name
#endif /* yyname */
#ifndef yyrule
#define yyrule quote_calc_rule
#endif /* yyrule */
#define YYPREFIX "quote_calc_"
#define YYPURE 0
#line 2 "quote_calc.y"
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
#line 109 "quote_calc.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define OP_ADD 257
#define ADD 258
#define OP_SUB 259
#define SUB 260
#define OP_MUL 261
#define MUL 262
#define OP_DIV 263
#define DIV 264
#define OP_MOD 265
#define MOD 266
#define OP_AND 267
#define AND 268
#define DIGIT 269
#define LETTER 270
#define UMINUS 271
#define YYERRCODE 256
static const short quote_calc_lhs[] = { -1,
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3,
};
static const short quote_calc_len[] = { 2,
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 2, 1, 1, 1, 2,
};
static const short quote_calc_defred[] = { 1,
0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
0, 0,
};
static const short quote_calc_dgoto[] = { 1,
7, 8, 9,
};
static const short quote_calc_sindex[] = { 0,
-38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
-36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
-121, -243,
};
static const short quote_calc_rindex[] = { 0,
0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
3, -4,
};
static const short quote_calc_gindex[] = { 0,
0, 42, 0,
};
#define YYTABLESIZE 258
static const short quote_calc_table[] = { 16,
15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
0, 19, 0, 20, 0, 21, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
16, 15, 16, 15, 16, 15, 16, 15,
};
static const short quote_calc_check[] = { 10,
10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
-1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
-1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 124, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
-1, 263, -1, 265, -1, 267, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
261, 261, 263, 263, 265, 265, 267, 267,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 271
#if YYDEBUG
static const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
};
static const char *yyrule[] = {
"$accept : list",
"list :",
"list : list stat '\\n'",
"list : list error '\\n'",
"stat : expr",
"stat : LETTER '=' expr",
"expr : '(' expr ')'",
"expr : expr OP_ADD expr",
"expr : expr OP_SUB expr",
"expr : expr OP_MUL expr",
"expr : expr OP_DIV expr",
"expr : expr OP_MOD expr",
"expr : expr OP_AND expr",
"expr : expr '|' expr",
"expr : OP_SUB expr",
"expr : LETTER",
"expr : number",
"number : DIGIT",
"number : number DIGIT",
};
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
typedef struct {
unsigned stacksize;
short *s_base;
short *s_mark;
short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 73 "quote_calc.y"
/* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}
#line 367 "quote_calc.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
data->l_base = newvs;
data->l_mark = newvs + i;
data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0;
}
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
YYPARSE_DECL()
{
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
yystate = 0;
#if YYPURE
memset(&yystack, 0, sizeof(yystack));
#endif
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0;
*yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
goto yyerrlab;
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yystack.s_mark);
#endif
if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yystack.s_mark;
--yystack.l_mark;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
if (yym)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 3:
#line 35 "quote_calc.y"
{ yyerrok ; }
break;
case 4:
#line 39 "quote_calc.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 41 "quote_calc.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 45 "quote_calc.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 47 "quote_calc.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 49 "quote_calc.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 51 "quote_calc.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 53 "quote_calc.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 55 "quote_calc.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 57 "quote_calc.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 59 "quote_calc.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 61 "quote_calc.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 63 "quote_calc.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 68 "quote_calc.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 70 "quote_calc.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 633 "quote_calc.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yystack.s_mark = YYFINAL;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
*++yystack.s_mark = (short) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
yyfreestack(&yystack);
return (1);
yyaccept:
yyfreestack(&yystack);
return (0);
}

View File

@@ -0,0 +1,17 @@
/* $NetBSD: quote_calc.tab.h,v 1.1.1.1 2013/04/06 14:45:28 christos Exp $ */
#define OP_ADD 257
#define ADD 258
#define OP_SUB 259
#define SUB 260
#define OP_MUL 261
#define MUL 262
#define OP_DIV 263
#define DIV 264
#define OP_MOD 265
#define MOD 266
#define OP_AND 267
#define AND 268
#define DIGIT 269
#define LETTER 270
#define UMINUS 271

View File

@@ -0,0 +1,114 @@
/* $NetBSD: quote_calc.y,v 1.1.1.1 2013/04/06 14:45:30 christos Exp $ */
%{
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
%}
%start list
%token OP_ADD "ADD"
%token OP_SUB "SUB"
%token OP_MUL "MUL"
%token OP_DIV "DIV"
%token OP_MOD "MOD"
%token OP_AND "AND"
%token DIGIT LETTER
%left '|'
%left '&'
%left '+' '-'
%left '*' '/' '%'
%left UMINUS /* supplies precedence for unary minus */
%% /* beginning of rules section */
list : /* empty */
| list stat '\n'
| list error '\n'
{ yyerrok ; }
;
stat : expr
{ printf("%d\n",$1);}
| LETTER '=' expr
{ regs[$1] = $3; }
;
expr : '(' expr ')'
{ $$ = $2; }
| expr OP_ADD expr
{ $$ = $1 + $3; }
| expr OP_SUB expr
{ $$ = $1 - $3; }
| expr OP_MUL expr
{ $$ = $1 * $3; }
| expr OP_DIV expr
{ $$ = $1 / $3; }
| expr OP_MOD expr
{ $$ = $1 % $3; }
| expr OP_AND expr
{ $$ = $1 & $3; }
| expr '|' expr
{ $$ = $1 | $3; }
| OP_SUB expr %prec UMINUS
{ $$ = - $2; }
| LETTER
{ $$ = regs[$1]; }
| number
;
number: DIGIT
{ $$ = $1; base = ($1==0) ? 8 : 10; }
| number DIGIT
{ $$ = base * $1 + $2; }
;
%% /* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}

View File

@@ -0,0 +1,557 @@
0 $accept : list $end
1 list :
2 | list stat '\n'
3 | list error '\n'
4 stat : expr
5 | LETTER '=' expr
6 expr : '(' expr ')'
7 | expr "ADD" expr
8 | expr "SUB" expr
9 | expr "MUL" expr
10 | expr "DIV" expr
11 | expr "MOD" expr
12 | expr "AND" expr
13 | expr '|' expr
14 | "SUB" expr
15 | LETTER
16 | number
17 number : DIGIT
18 | number DIGIT
state 0
$accept : . list $end (0)
list : . (1)
. reduce 1
list goto 1
state 1
$accept : list . $end (0)
list : list . stat '\n' (2)
list : list . error '\n' (3)
$end accept
error shift 2
"SUB" shift 3
DIGIT shift 4
LETTER shift 5
'(' shift 6
. error
stat goto 7
expr goto 8
number goto 9
state 2
list : list error . '\n' (3)
'\n' shift 10
. error
state 3
expr : "SUB" . expr (14)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 12
number goto 9
state 4
number : DIGIT . (17)
. reduce 17
state 5
stat : LETTER . '=' expr (5)
expr : LETTER . (15)
'=' shift 13
"ADD" reduce 15
"SUB" reduce 15
"MUL" reduce 15
"DIV" reduce 15
"MOD" reduce 15
"AND" reduce 15
'|' reduce 15
'\n' reduce 15
state 6
expr : '(' . expr ')' (6)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 14
number goto 9
state 7
list : list stat . '\n' (2)
'\n' shift 15
. error
state 8
stat : expr . (4)
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 4
state 9
expr : number . (16)
number : number . DIGIT (18)
DIGIT shift 23
"ADD" reduce 16
"SUB" reduce 16
"MUL" reduce 16
"DIV" reduce 16
"MOD" reduce 16
"AND" reduce 16
'|' reduce 16
'\n' reduce 16
')' reduce 16
state 10
list : list error '\n' . (3)
. reduce 3
state 11
expr : LETTER . (15)
. reduce 15
12: shift/reduce conflict (shift 16, reduce 14) on "ADD"
12: shift/reduce conflict (shift 17, reduce 14) on "SUB"
12: shift/reduce conflict (shift 18, reduce 14) on "MUL"
12: shift/reduce conflict (shift 19, reduce 14) on "DIV"
12: shift/reduce conflict (shift 20, reduce 14) on "MOD"
12: shift/reduce conflict (shift 21, reduce 14) on "AND"
state 12
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
expr : "SUB" expr . (14)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' reduce 14
'\n' reduce 14
')' reduce 14
state 13
stat : LETTER '=' . expr (5)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 24
number goto 9
state 14
expr : '(' expr . ')' (6)
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
')' shift 25
. error
state 15
list : list stat '\n' . (2)
. reduce 2
state 16
expr : expr "ADD" . expr (7)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 26
number goto 9
state 17
expr : expr "SUB" . expr (8)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 27
number goto 9
state 18
expr : expr "MUL" . expr (9)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 28
number goto 9
state 19
expr : expr "DIV" . expr (10)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 29
number goto 9
state 20
expr : expr "MOD" . expr (11)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 30
number goto 9
state 21
expr : expr "AND" . expr (12)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 31
number goto 9
state 22
expr : expr '|' . expr (13)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 32
number goto 9
state 23
number : number DIGIT . (18)
. reduce 18
state 24
stat : LETTER '=' expr . (5)
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 5
state 25
expr : '(' expr ')' . (6)
. reduce 6
26: shift/reduce conflict (shift 16, reduce 7) on "ADD"
26: shift/reduce conflict (shift 17, reduce 7) on "SUB"
26: shift/reduce conflict (shift 18, reduce 7) on "MUL"
26: shift/reduce conflict (shift 19, reduce 7) on "DIV"
26: shift/reduce conflict (shift 20, reduce 7) on "MOD"
26: shift/reduce conflict (shift 21, reduce 7) on "AND"
26: shift/reduce conflict (shift 22, reduce 7) on '|'
state 26
expr : expr . "ADD" expr (7)
expr : expr "ADD" expr . (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 7
')' reduce 7
27: shift/reduce conflict (shift 16, reduce 8) on "ADD"
27: shift/reduce conflict (shift 17, reduce 8) on "SUB"
27: shift/reduce conflict (shift 18, reduce 8) on "MUL"
27: shift/reduce conflict (shift 19, reduce 8) on "DIV"
27: shift/reduce conflict (shift 20, reduce 8) on "MOD"
27: shift/reduce conflict (shift 21, reduce 8) on "AND"
27: shift/reduce conflict (shift 22, reduce 8) on '|'
state 27
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr "SUB" expr . (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 8
')' reduce 8
28: shift/reduce conflict (shift 16, reduce 9) on "ADD"
28: shift/reduce conflict (shift 17, reduce 9) on "SUB"
28: shift/reduce conflict (shift 18, reduce 9) on "MUL"
28: shift/reduce conflict (shift 19, reduce 9) on "DIV"
28: shift/reduce conflict (shift 20, reduce 9) on "MOD"
28: shift/reduce conflict (shift 21, reduce 9) on "AND"
28: shift/reduce conflict (shift 22, reduce 9) on '|'
state 28
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr "MUL" expr . (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 9
')' reduce 9
29: shift/reduce conflict (shift 16, reduce 10) on "ADD"
29: shift/reduce conflict (shift 17, reduce 10) on "SUB"
29: shift/reduce conflict (shift 18, reduce 10) on "MUL"
29: shift/reduce conflict (shift 19, reduce 10) on "DIV"
29: shift/reduce conflict (shift 20, reduce 10) on "MOD"
29: shift/reduce conflict (shift 21, reduce 10) on "AND"
29: shift/reduce conflict (shift 22, reduce 10) on '|'
state 29
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr "DIV" expr . (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 10
')' reduce 10
30: shift/reduce conflict (shift 16, reduce 11) on "ADD"
30: shift/reduce conflict (shift 17, reduce 11) on "SUB"
30: shift/reduce conflict (shift 18, reduce 11) on "MUL"
30: shift/reduce conflict (shift 19, reduce 11) on "DIV"
30: shift/reduce conflict (shift 20, reduce 11) on "MOD"
30: shift/reduce conflict (shift 21, reduce 11) on "AND"
30: shift/reduce conflict (shift 22, reduce 11) on '|'
state 30
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr "MOD" expr . (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 11
')' reduce 11
31: shift/reduce conflict (shift 16, reduce 12) on "ADD"
31: shift/reduce conflict (shift 17, reduce 12) on "SUB"
31: shift/reduce conflict (shift 18, reduce 12) on "MUL"
31: shift/reduce conflict (shift 19, reduce 12) on "DIV"
31: shift/reduce conflict (shift 20, reduce 12) on "MOD"
31: shift/reduce conflict (shift 21, reduce 12) on "AND"
31: shift/reduce conflict (shift 22, reduce 12) on '|'
state 31
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr "AND" expr . (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 12
')' reduce 12
32: shift/reduce conflict (shift 16, reduce 13) on "ADD"
32: shift/reduce conflict (shift 17, reduce 13) on "SUB"
32: shift/reduce conflict (shift 18, reduce 13) on "MUL"
32: shift/reduce conflict (shift 19, reduce 13) on "DIV"
32: shift/reduce conflict (shift 20, reduce 13) on "MOD"
32: shift/reduce conflict (shift 21, reduce 13) on "AND"
state 32
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
expr : expr '|' expr . (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' reduce 13
'\n' reduce 13
')' reduce 13
State 12 contains 6 shift/reduce conflicts.
State 26 contains 7 shift/reduce conflicts.
State 27 contains 7 shift/reduce conflicts.
State 28 contains 7 shift/reduce conflicts.
State 29 contains 7 shift/reduce conflicts.
State 30 contains 7 shift/reduce conflicts.
State 31 contains 7 shift/reduce conflicts.
State 32 contains 6 shift/reduce conflicts.
28 terminals, 5 nonterminals
19 grammar rules, 33 states

View File

@@ -0,0 +1,689 @@
/* $NetBSD: quote_calc2-s.tab.c,v 1.1.1.1 2013/04/06 14:45:30 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#ifndef yyparse
#define yyparse quote_calc2_parse
#endif /* yyparse */
#ifndef yylex
#define yylex quote_calc2_lex
#endif /* yylex */
#ifndef yyerror
#define yyerror quote_calc2_error
#endif /* yyerror */
#ifndef yychar
#define yychar quote_calc2_char
#endif /* yychar */
#ifndef yyval
#define yyval quote_calc2_val
#endif /* yyval */
#ifndef yylval
#define yylval quote_calc2_lval
#endif /* yylval */
#ifndef yydebug
#define yydebug quote_calc2_debug
#endif /* yydebug */
#ifndef yynerrs
#define yynerrs quote_calc2_nerrs
#endif /* yynerrs */
#ifndef yyerrflag
#define yyerrflag quote_calc2_errflag
#endif /* yyerrflag */
#ifndef yylhs
#define yylhs quote_calc2_lhs
#endif /* yylhs */
#ifndef yylen
#define yylen quote_calc2_len
#endif /* yylen */
#ifndef yydefred
#define yydefred quote_calc2_defred
#endif /* yydefred */
#ifndef yydgoto
#define yydgoto quote_calc2_dgoto
#endif /* yydgoto */
#ifndef yysindex
#define yysindex quote_calc2_sindex
#endif /* yysindex */
#ifndef yyrindex
#define yyrindex quote_calc2_rindex
#endif /* yyrindex */
#ifndef yygindex
#define yygindex quote_calc2_gindex
#endif /* yygindex */
#ifndef yytable
#define yytable quote_calc2_table
#endif /* yytable */
#ifndef yycheck
#define yycheck quote_calc2_check
#endif /* yycheck */
#ifndef yyname
#define yyname quote_calc2_name
#endif /* yyname */
#ifndef yyrule
#define yyrule quote_calc2_rule
#endif /* yyrule */
#define YYPREFIX "quote_calc2_"
#define YYPURE 0
#line 2 "quote_calc2.y"
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
#line 109 "quote_calc2-s.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271
#define YYERRCODE 256
static const short quote_calc2_lhs[] = { -1,
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3,
};
static const short quote_calc2_len[] = { 2,
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 2, 1, 1, 1, 2,
};
static const short quote_calc2_defred[] = { 1,
0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
0, 0,
};
static const short quote_calc2_dgoto[] = { 1,
7, 8, 9,
};
static const short quote_calc2_sindex[] = { 0,
-38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
-36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
-121, -243,
};
static const short quote_calc2_rindex[] = { 0,
0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
3, -4,
};
static const short quote_calc2_gindex[] = { 0,
0, 42, 0,
};
#define YYTABLESIZE 259
static const short quote_calc2_table[] = { 16,
15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
18, 0, 19, 0, 20, 0, 21, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
15, 16, 15, 16, 15, 16, 15, 16, 15,
};
static const short quote_calc2_check[] = { 10,
10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
-1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
-1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
262, -1, 264, -1, 266, -1, 268, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
-1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
260, 262, 262, 264, 264, 266, 266, 268, 268,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 271
#if YYDEBUG
static const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
};
static const char *yyrule[] = {
"$accept : list",
"list :",
"list : list stat '\\n'",
"list : list error '\\n'",
"stat : expr",
"stat : LETTER '=' expr",
"expr : '(' expr ')'",
"expr : expr \"ADD\" expr",
"expr : expr \"SUB\" expr",
"expr : expr \"MUL\" expr",
"expr : expr \"DIV\" expr",
"expr : expr \"MOD\" expr",
"expr : expr \"AND\" expr",
"expr : expr '|' expr",
"expr : \"SUB\" expr",
"expr : LETTER",
"expr : number",
"number : DIGIT",
"number : number DIGIT",
};
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
typedef struct {
unsigned stacksize;
short *s_base;
short *s_mark;
short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 73 "quote_calc2.y"
/* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}
#line 361 "quote_calc2-s.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
data->l_base = newvs;
data->l_mark = newvs + i;
data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0;
}
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
YYPARSE_DECL()
{
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
yystate = 0;
#if YYPURE
memset(&yystack, 0, sizeof(yystack));
#endif
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0;
*yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
goto yyerrlab;
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yystack.s_mark);
#endif
if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yystack.s_mark;
--yystack.l_mark;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
if (yym)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 3:
#line 35 "quote_calc2.y"
{ yyerrok ; }
break;
case 4:
#line 39 "quote_calc2.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 41 "quote_calc2.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 45 "quote_calc2.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 47 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 49 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 51 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 53 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 55 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 57 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 59 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 61 "quote_calc2.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 63 "quote_calc2.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 68 "quote_calc2.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 70 "quote_calc2.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 627 "quote_calc2-s.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yystack.s_mark = YYFINAL;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
*++yystack.s_mark = (short) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
yyfreestack(&yystack);
return (1);
yyaccept:
yyfreestack(&yystack);
return (0);
}

View File

@@ -0,0 +1,11 @@
/* $NetBSD: quote_calc2-s.tab.h,v 1.1.1.1 2013/04/06 14:45:27 christos Exp $ */
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271

View File

@@ -0,0 +1,557 @@
0 $accept : list $end
1 list :
2 | list stat '\n'
3 | list error '\n'
4 stat : expr
5 | LETTER '=' expr
6 expr : '(' expr ')'
7 | expr "ADD" expr
8 | expr "SUB" expr
9 | expr "MUL" expr
10 | expr "DIV" expr
11 | expr "MOD" expr
12 | expr "AND" expr
13 | expr '|' expr
14 | "SUB" expr
15 | LETTER
16 | number
17 number : DIGIT
18 | number DIGIT
state 0
$accept : . list $end (0)
list : . (1)
. reduce 1
list goto 1
state 1
$accept : list . $end (0)
list : list . stat '\n' (2)
list : list . error '\n' (3)
$end accept
error shift 2
"SUB" shift 3
DIGIT shift 4
LETTER shift 5
'(' shift 6
. error
stat goto 7
expr goto 8
number goto 9
state 2
list : list error . '\n' (3)
'\n' shift 10
. error
state 3
expr : "SUB" . expr (14)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 12
number goto 9
state 4
number : DIGIT . (17)
. reduce 17
state 5
stat : LETTER . '=' expr (5)
expr : LETTER . (15)
'=' shift 13
"ADD" reduce 15
"SUB" reduce 15
"MUL" reduce 15
"DIV" reduce 15
"MOD" reduce 15
"AND" reduce 15
'|' reduce 15
'\n' reduce 15
state 6
expr : '(' . expr ')' (6)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 14
number goto 9
state 7
list : list stat . '\n' (2)
'\n' shift 15
. error
state 8
stat : expr . (4)
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 4
state 9
expr : number . (16)
number : number . DIGIT (18)
DIGIT shift 23
"ADD" reduce 16
"SUB" reduce 16
"MUL" reduce 16
"DIV" reduce 16
"MOD" reduce 16
"AND" reduce 16
'|' reduce 16
'\n' reduce 16
')' reduce 16
state 10
list : list error '\n' . (3)
. reduce 3
state 11
expr : LETTER . (15)
. reduce 15
12: shift/reduce conflict (shift 16, reduce 14) on "ADD"
12: shift/reduce conflict (shift 17, reduce 14) on "SUB"
12: shift/reduce conflict (shift 18, reduce 14) on "MUL"
12: shift/reduce conflict (shift 19, reduce 14) on "DIV"
12: shift/reduce conflict (shift 20, reduce 14) on "MOD"
12: shift/reduce conflict (shift 21, reduce 14) on "AND"
state 12
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
expr : "SUB" expr . (14)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' reduce 14
'\n' reduce 14
')' reduce 14
state 13
stat : LETTER '=' . expr (5)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 24
number goto 9
state 14
expr : '(' expr . ')' (6)
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
')' shift 25
. error
state 15
list : list stat '\n' . (2)
. reduce 2
state 16
expr : expr "ADD" . expr (7)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 26
number goto 9
state 17
expr : expr "SUB" . expr (8)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 27
number goto 9
state 18
expr : expr "MUL" . expr (9)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 28
number goto 9
state 19
expr : expr "DIV" . expr (10)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 29
number goto 9
state 20
expr : expr "MOD" . expr (11)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 30
number goto 9
state 21
expr : expr "AND" . expr (12)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 31
number goto 9
state 22
expr : expr '|' . expr (13)
"SUB" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 32
number goto 9
state 23
number : number DIGIT . (18)
. reduce 18
state 24
stat : LETTER '=' expr . (5)
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 5
state 25
expr : '(' expr ')' . (6)
. reduce 6
26: shift/reduce conflict (shift 16, reduce 7) on "ADD"
26: shift/reduce conflict (shift 17, reduce 7) on "SUB"
26: shift/reduce conflict (shift 18, reduce 7) on "MUL"
26: shift/reduce conflict (shift 19, reduce 7) on "DIV"
26: shift/reduce conflict (shift 20, reduce 7) on "MOD"
26: shift/reduce conflict (shift 21, reduce 7) on "AND"
26: shift/reduce conflict (shift 22, reduce 7) on '|'
state 26
expr : expr . "ADD" expr (7)
expr : expr "ADD" expr . (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 7
')' reduce 7
27: shift/reduce conflict (shift 16, reduce 8) on "ADD"
27: shift/reduce conflict (shift 17, reduce 8) on "SUB"
27: shift/reduce conflict (shift 18, reduce 8) on "MUL"
27: shift/reduce conflict (shift 19, reduce 8) on "DIV"
27: shift/reduce conflict (shift 20, reduce 8) on "MOD"
27: shift/reduce conflict (shift 21, reduce 8) on "AND"
27: shift/reduce conflict (shift 22, reduce 8) on '|'
state 27
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr "SUB" expr . (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 8
')' reduce 8
28: shift/reduce conflict (shift 16, reduce 9) on "ADD"
28: shift/reduce conflict (shift 17, reduce 9) on "SUB"
28: shift/reduce conflict (shift 18, reduce 9) on "MUL"
28: shift/reduce conflict (shift 19, reduce 9) on "DIV"
28: shift/reduce conflict (shift 20, reduce 9) on "MOD"
28: shift/reduce conflict (shift 21, reduce 9) on "AND"
28: shift/reduce conflict (shift 22, reduce 9) on '|'
state 28
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr "MUL" expr . (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 9
')' reduce 9
29: shift/reduce conflict (shift 16, reduce 10) on "ADD"
29: shift/reduce conflict (shift 17, reduce 10) on "SUB"
29: shift/reduce conflict (shift 18, reduce 10) on "MUL"
29: shift/reduce conflict (shift 19, reduce 10) on "DIV"
29: shift/reduce conflict (shift 20, reduce 10) on "MOD"
29: shift/reduce conflict (shift 21, reduce 10) on "AND"
29: shift/reduce conflict (shift 22, reduce 10) on '|'
state 29
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr "DIV" expr . (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 10
')' reduce 10
30: shift/reduce conflict (shift 16, reduce 11) on "ADD"
30: shift/reduce conflict (shift 17, reduce 11) on "SUB"
30: shift/reduce conflict (shift 18, reduce 11) on "MUL"
30: shift/reduce conflict (shift 19, reduce 11) on "DIV"
30: shift/reduce conflict (shift 20, reduce 11) on "MOD"
30: shift/reduce conflict (shift 21, reduce 11) on "AND"
30: shift/reduce conflict (shift 22, reduce 11) on '|'
state 30
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr "MOD" expr . (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 11
')' reduce 11
31: shift/reduce conflict (shift 16, reduce 12) on "ADD"
31: shift/reduce conflict (shift 17, reduce 12) on "SUB"
31: shift/reduce conflict (shift 18, reduce 12) on "MUL"
31: shift/reduce conflict (shift 19, reduce 12) on "DIV"
31: shift/reduce conflict (shift 20, reduce 12) on "MOD"
31: shift/reduce conflict (shift 21, reduce 12) on "AND"
31: shift/reduce conflict (shift 22, reduce 12) on '|'
state 31
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr "AND" expr . (12)
expr : expr . '|' expr (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' shift 22
'\n' reduce 12
')' reduce 12
32: shift/reduce conflict (shift 16, reduce 13) on "ADD"
32: shift/reduce conflict (shift 17, reduce 13) on "SUB"
32: shift/reduce conflict (shift 18, reduce 13) on "MUL"
32: shift/reduce conflict (shift 19, reduce 13) on "DIV"
32: shift/reduce conflict (shift 20, reduce 13) on "MOD"
32: shift/reduce conflict (shift 21, reduce 13) on "AND"
state 32
expr : expr . "ADD" expr (7)
expr : expr . "SUB" expr (8)
expr : expr . "MUL" expr (9)
expr : expr . "DIV" expr (10)
expr : expr . "MOD" expr (11)
expr : expr . "AND" expr (12)
expr : expr . '|' expr (13)
expr : expr '|' expr . (13)
"ADD" shift 16
"SUB" shift 17
"MUL" shift 18
"DIV" shift 19
"MOD" shift 20
"AND" shift 21
'|' reduce 13
'\n' reduce 13
')' reduce 13
State 12 contains 6 shift/reduce conflicts.
State 26 contains 7 shift/reduce conflicts.
State 27 contains 7 shift/reduce conflicts.
State 28 contains 7 shift/reduce conflicts.
State 29 contains 7 shift/reduce conflicts.
State 30 contains 7 shift/reduce conflicts.
State 31 contains 7 shift/reduce conflicts.
State 32 contains 6 shift/reduce conflicts.
28 terminals, 5 nonterminals
19 grammar rules, 33 states

View File

@@ -0,0 +1,695 @@
/* $NetBSD: quote_calc2.tab.c,v 1.1.1.1 2013/04/06 14:45:29 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#ifndef yyparse
#define yyparse quote_calc2_parse
#endif /* yyparse */
#ifndef yylex
#define yylex quote_calc2_lex
#endif /* yylex */
#ifndef yyerror
#define yyerror quote_calc2_error
#endif /* yyerror */
#ifndef yychar
#define yychar quote_calc2_char
#endif /* yychar */
#ifndef yyval
#define yyval quote_calc2_val
#endif /* yyval */
#ifndef yylval
#define yylval quote_calc2_lval
#endif /* yylval */
#ifndef yydebug
#define yydebug quote_calc2_debug
#endif /* yydebug */
#ifndef yynerrs
#define yynerrs quote_calc2_nerrs
#endif /* yynerrs */
#ifndef yyerrflag
#define yyerrflag quote_calc2_errflag
#endif /* yyerrflag */
#ifndef yylhs
#define yylhs quote_calc2_lhs
#endif /* yylhs */
#ifndef yylen
#define yylen quote_calc2_len
#endif /* yylen */
#ifndef yydefred
#define yydefred quote_calc2_defred
#endif /* yydefred */
#ifndef yydgoto
#define yydgoto quote_calc2_dgoto
#endif /* yydgoto */
#ifndef yysindex
#define yysindex quote_calc2_sindex
#endif /* yysindex */
#ifndef yyrindex
#define yyrindex quote_calc2_rindex
#endif /* yyrindex */
#ifndef yygindex
#define yygindex quote_calc2_gindex
#endif /* yygindex */
#ifndef yytable
#define yytable quote_calc2_table
#endif /* yytable */
#ifndef yycheck
#define yycheck quote_calc2_check
#endif /* yycheck */
#ifndef yyname
#define yyname quote_calc2_name
#endif /* yyname */
#ifndef yyrule
#define yyrule quote_calc2_rule
#endif /* yyrule */
#define YYPREFIX "quote_calc2_"
#define YYPURE 0
#line 2 "quote_calc2.y"
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
#line 109 "quote_calc2.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define OP_ADD 257
#define ADD 258
#define OP_SUB 259
#define SUB 260
#define OP_MUL 261
#define MUL 262
#define OP_DIV 263
#define DIV 264
#define OP_MOD 265
#define MOD 266
#define OP_AND 267
#define AND 268
#define DIGIT 269
#define LETTER 270
#define UMINUS 271
#define YYERRCODE 256
static const short quote_calc2_lhs[] = { -1,
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3,
};
static const short quote_calc2_len[] = { 2,
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 2, 1, 1, 1, 2,
};
static const short quote_calc2_defred[] = { 1,
0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
0, 0,
};
static const short quote_calc2_dgoto[] = { 1,
7, 8, 9,
};
static const short quote_calc2_sindex[] = { 0,
-38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
-36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
-121, -243,
};
static const short quote_calc2_rindex[] = { 0,
0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
3, -4,
};
static const short quote_calc2_gindex[] = { 0,
0, 42, 0,
};
#define YYTABLESIZE 259
static const short quote_calc2_table[] = { 16,
15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
18, 0, 19, 0, 20, 0, 21, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
15, 16, 15, 16, 15, 16, 15, 16, 15,
};
static const short quote_calc2_check[] = { 10,
10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
-1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
-1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
262, -1, 264, -1, 266, -1, 268, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
-1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
260, 262, 262, 264, 264, 266, 266, 268, 268,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 271
#if YYDEBUG
static const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"OP_ADD","\"ADD\"","OP_SUB","\"SUB\"","OP_MUL","\"MUL\"","OP_DIV",
"\"DIV\"","OP_MOD","\"MOD\"","OP_AND","\"AND\"","DIGIT","LETTER","UMINUS",
};
static const char *yyrule[] = {
"$accept : list",
"list :",
"list : list stat '\\n'",
"list : list error '\\n'",
"stat : expr",
"stat : LETTER '=' expr",
"expr : '(' expr ')'",
"expr : expr \"ADD\" expr",
"expr : expr \"SUB\" expr",
"expr : expr \"MUL\" expr",
"expr : expr \"DIV\" expr",
"expr : expr \"MOD\" expr",
"expr : expr \"AND\" expr",
"expr : expr '|' expr",
"expr : \"SUB\" expr",
"expr : LETTER",
"expr : number",
"number : DIGIT",
"number : number DIGIT",
};
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
typedef struct {
unsigned stacksize;
short *s_base;
short *s_mark;
short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 73 "quote_calc2.y"
/* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}
#line 367 "quote_calc2.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
data->l_base = newvs;
data->l_mark = newvs + i;
data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0;
}
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
YYPARSE_DECL()
{
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
yystate = 0;
#if YYPURE
memset(&yystack, 0, sizeof(yystack));
#endif
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0;
*yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
goto yyerrlab;
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yystack.s_mark);
#endif
if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yystack.s_mark;
--yystack.l_mark;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
if (yym)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 3:
#line 35 "quote_calc2.y"
{ yyerrok ; }
break;
case 4:
#line 39 "quote_calc2.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 41 "quote_calc2.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 45 "quote_calc2.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 47 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 49 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 51 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 53 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 55 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 57 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 59 "quote_calc2.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 61 "quote_calc2.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 63 "quote_calc2.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 68 "quote_calc2.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 70 "quote_calc2.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 633 "quote_calc2.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yystack.s_mark = YYFINAL;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
*++yystack.s_mark = (short) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
yyfreestack(&yystack);
return (1);
yyaccept:
yyfreestack(&yystack);
return (0);
}

View File

@@ -0,0 +1,17 @@
/* $NetBSD: quote_calc2.tab.h,v 1.1.1.1 2013/04/06 14:45:28 christos Exp $ */
#define OP_ADD 257
#define ADD 258
#define OP_SUB 259
#define SUB 260
#define OP_MUL 261
#define MUL 262
#define OP_DIV 263
#define DIV 264
#define OP_MOD 265
#define MOD 266
#define OP_AND 267
#define AND 268
#define DIGIT 269
#define LETTER 270
#define UMINUS 271

View File

@@ -0,0 +1,114 @@
/* $NetBSD: quote_calc2.y,v 1.1.1.1 2013/04/06 14:45:28 christos Exp $ */
%{
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
%}
%start list
%token OP_ADD "ADD"
%token OP_SUB "SUB"
%token OP_MUL "MUL"
%token OP_DIV "DIV"
%token OP_MOD "MOD"
%token OP_AND "AND"
%token DIGIT LETTER
%left '|'
%left '&'
%left '+' '-'
%left '*' '/' '%'
%left UMINUS /* supplies precedence for unary minus */
%% /* beginning of rules section */
list : /* empty */
| list stat '\n'
| list error '\n'
{ yyerrok ; }
;
stat : expr
{ printf("%d\n",$1);}
| LETTER '=' expr
{ regs[$1] = $3; }
;
expr : '(' expr ')'
{ $$ = $2; }
| expr "ADD" expr
{ $$ = $1 + $3; }
| expr "SUB" expr
{ $$ = $1 - $3; }
| expr "MUL" expr
{ $$ = $1 * $3; }
| expr "DIV" expr
{ $$ = $1 / $3; }
| expr "MOD" expr
{ $$ = $1 % $3; }
| expr "AND" expr
{ $$ = $1 & $3; }
| expr '|' expr
{ $$ = $1 | $3; }
| "SUB" expr %prec UMINUS
{ $$ = - $2; }
| LETTER
{ $$ = regs[$1]; }
| number
;
number: DIGIT
{ $$ = $1; base = ($1==0) ? 8 : 10; }
| number DIGIT
{ $$ = base * $1 + $2; }
;
%% /* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}

View File

@@ -0,0 +1,557 @@
0 $accept : list $end
1 list :
2 | list stat '\n'
3 | list error '\n'
4 stat : expr
5 | LETTER '=' expr
6 expr : '(' expr ')'
7 | expr OP_ADD expr
8 | expr OP_SUB expr
9 | expr OP_MUL expr
10 | expr OP_DIV expr
11 | expr OP_MOD expr
12 | expr OP_AND expr
13 | expr '|' expr
14 | OP_SUB expr
15 | LETTER
16 | number
17 number : DIGIT
18 | number DIGIT
state 0
$accept : . list $end (0)
list : . (1)
. reduce 1
list goto 1
state 1
$accept : list . $end (0)
list : list . stat '\n' (2)
list : list . error '\n' (3)
$end accept
error shift 2
OP_SUB shift 3
DIGIT shift 4
LETTER shift 5
'(' shift 6
. error
stat goto 7
expr goto 8
number goto 9
state 2
list : list error . '\n' (3)
'\n' shift 10
. error
state 3
expr : OP_SUB . expr (14)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 12
number goto 9
state 4
number : DIGIT . (17)
. reduce 17
state 5
stat : LETTER . '=' expr (5)
expr : LETTER . (15)
'=' shift 13
OP_ADD reduce 15
OP_SUB reduce 15
OP_MUL reduce 15
OP_DIV reduce 15
OP_MOD reduce 15
OP_AND reduce 15
'|' reduce 15
'\n' reduce 15
state 6
expr : '(' . expr ')' (6)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 14
number goto 9
state 7
list : list stat . '\n' (2)
'\n' shift 15
. error
state 8
stat : expr . (4)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 4
state 9
expr : number . (16)
number : number . DIGIT (18)
DIGIT shift 23
OP_ADD reduce 16
OP_SUB reduce 16
OP_MUL reduce 16
OP_DIV reduce 16
OP_MOD reduce 16
OP_AND reduce 16
'|' reduce 16
'\n' reduce 16
')' reduce 16
state 10
list : list error '\n' . (3)
. reduce 3
state 11
expr : LETTER . (15)
. reduce 15
12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD
12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB
12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL
12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV
12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD
12: shift/reduce conflict (shift 21, reduce 14) on OP_AND
state 12
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
expr : OP_SUB expr . (14)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' reduce 14
'\n' reduce 14
')' reduce 14
state 13
stat : LETTER '=' . expr (5)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 24
number goto 9
state 14
expr : '(' expr . ')' (6)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
')' shift 25
. error
state 15
list : list stat '\n' . (2)
. reduce 2
state 16
expr : expr OP_ADD . expr (7)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 26
number goto 9
state 17
expr : expr OP_SUB . expr (8)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 27
number goto 9
state 18
expr : expr OP_MUL . expr (9)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 28
number goto 9
state 19
expr : expr OP_DIV . expr (10)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 29
number goto 9
state 20
expr : expr OP_MOD . expr (11)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 30
number goto 9
state 21
expr : expr OP_AND . expr (12)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 31
number goto 9
state 22
expr : expr '|' . expr (13)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 32
number goto 9
state 23
number : number DIGIT . (18)
. reduce 18
state 24
stat : LETTER '=' expr . (5)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 5
state 25
expr : '(' expr ')' . (6)
. reduce 6
26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD
26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB
26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL
26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV
26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD
26: shift/reduce conflict (shift 21, reduce 7) on OP_AND
26: shift/reduce conflict (shift 22, reduce 7) on '|'
state 26
expr : expr . OP_ADD expr (7)
expr : expr OP_ADD expr . (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 7
')' reduce 7
27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD
27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB
27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL
27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV
27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD
27: shift/reduce conflict (shift 21, reduce 8) on OP_AND
27: shift/reduce conflict (shift 22, reduce 8) on '|'
state 27
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr OP_SUB expr . (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 8
')' reduce 8
28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD
28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB
28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL
28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV
28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD
28: shift/reduce conflict (shift 21, reduce 9) on OP_AND
28: shift/reduce conflict (shift 22, reduce 9) on '|'
state 28
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr OP_MUL expr . (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 9
')' reduce 9
29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD
29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB
29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL
29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV
29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD
29: shift/reduce conflict (shift 21, reduce 10) on OP_AND
29: shift/reduce conflict (shift 22, reduce 10) on '|'
state 29
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr OP_DIV expr . (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 10
')' reduce 10
30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD
30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB
30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL
30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV
30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD
30: shift/reduce conflict (shift 21, reduce 11) on OP_AND
30: shift/reduce conflict (shift 22, reduce 11) on '|'
state 30
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr OP_MOD expr . (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 11
')' reduce 11
31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD
31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB
31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL
31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV
31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD
31: shift/reduce conflict (shift 21, reduce 12) on OP_AND
31: shift/reduce conflict (shift 22, reduce 12) on '|'
state 31
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr OP_AND expr . (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 12
')' reduce 12
32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD
32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB
32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL
32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV
32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD
32: shift/reduce conflict (shift 21, reduce 13) on OP_AND
state 32
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
expr : expr '|' expr . (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' reduce 13
'\n' reduce 13
')' reduce 13
State 12 contains 6 shift/reduce conflicts.
State 26 contains 7 shift/reduce conflicts.
State 27 contains 7 shift/reduce conflicts.
State 28 contains 7 shift/reduce conflicts.
State 29 contains 7 shift/reduce conflicts.
State 30 contains 7 shift/reduce conflicts.
State 31 contains 7 shift/reduce conflicts.
State 32 contains 6 shift/reduce conflicts.
28 terminals, 5 nonterminals
19 grammar rules, 33 states

View File

@@ -0,0 +1,690 @@
/* $NetBSD: quote_calc3-s.tab.c,v 1.1.1.1 2013/04/06 14:45:28 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#ifndef yyparse
#define yyparse quote_calc3_parse
#endif /* yyparse */
#ifndef yylex
#define yylex quote_calc3_lex
#endif /* yylex */
#ifndef yyerror
#define yyerror quote_calc3_error
#endif /* yyerror */
#ifndef yychar
#define yychar quote_calc3_char
#endif /* yychar */
#ifndef yyval
#define yyval quote_calc3_val
#endif /* yyval */
#ifndef yylval
#define yylval quote_calc3_lval
#endif /* yylval */
#ifndef yydebug
#define yydebug quote_calc3_debug
#endif /* yydebug */
#ifndef yynerrs
#define yynerrs quote_calc3_nerrs
#endif /* yynerrs */
#ifndef yyerrflag
#define yyerrflag quote_calc3_errflag
#endif /* yyerrflag */
#ifndef yylhs
#define yylhs quote_calc3_lhs
#endif /* yylhs */
#ifndef yylen
#define yylen quote_calc3_len
#endif /* yylen */
#ifndef yydefred
#define yydefred quote_calc3_defred
#endif /* yydefred */
#ifndef yydgoto
#define yydgoto quote_calc3_dgoto
#endif /* yydgoto */
#ifndef yysindex
#define yysindex quote_calc3_sindex
#endif /* yysindex */
#ifndef yyrindex
#define yyrindex quote_calc3_rindex
#endif /* yyrindex */
#ifndef yygindex
#define yygindex quote_calc3_gindex
#endif /* yygindex */
#ifndef yytable
#define yytable quote_calc3_table
#endif /* yytable */
#ifndef yycheck
#define yycheck quote_calc3_check
#endif /* yycheck */
#ifndef yyname
#define yyname quote_calc3_name
#endif /* yyname */
#ifndef yyrule
#define yyrule quote_calc3_rule
#endif /* yyrule */
#define YYPREFIX "quote_calc3_"
#define YYPURE 0
#line 2 "quote_calc3.y"
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
#line 109 "quote_calc3-s.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271
#define YYERRCODE 256
static const short quote_calc3_lhs[] = { -1,
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3,
};
static const short quote_calc3_len[] = { 2,
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 2, 1, 1, 1, 2,
};
static const short quote_calc3_defred[] = { 1,
0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
0, 0,
};
static const short quote_calc3_dgoto[] = { 1,
7, 8, 9,
};
static const short quote_calc3_sindex[] = { 0,
-38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
-36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
-121, -243,
};
static const short quote_calc3_rindex[] = { 0,
0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
3, -4,
};
static const short quote_calc3_gindex[] = { 0,
0, 42, 0,
};
#define YYTABLESIZE 258
static const short quote_calc3_table[] = { 16,
15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
0, 19, 0, 20, 0, 21, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
16, 15, 16, 15, 16, 15, 16, 15,
};
static const short quote_calc3_check[] = { 10,
10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
-1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
-1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 124, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
-1, 263, -1, 265, -1, 267, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
261, 261, 263, 263, 265, 265, 267, 267,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 271
#if YYDEBUG
static const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",
};
static const char *yyrule[] = {
"$accept : list",
"list :",
"list : list stat '\\n'",
"list : list error '\\n'",
"stat : expr",
"stat : LETTER '=' expr",
"expr : '(' expr ')'",
"expr : expr OP_ADD expr",
"expr : expr OP_SUB expr",
"expr : expr OP_MUL expr",
"expr : expr OP_DIV expr",
"expr : expr OP_MOD expr",
"expr : expr OP_AND expr",
"expr : expr '|' expr",
"expr : OP_SUB expr",
"expr : LETTER",
"expr : number",
"number : DIGIT",
"number : number DIGIT",
};
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
typedef struct {
unsigned stacksize;
short *s_base;
short *s_mark;
short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 73 "quote_calc3.y"
/* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}
#line 362 "quote_calc3-s.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
data->l_base = newvs;
data->l_mark = newvs + i;
data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0;
}
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
YYPARSE_DECL()
{
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
yystate = 0;
#if YYPURE
memset(&yystack, 0, sizeof(yystack));
#endif
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0;
*yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
goto yyerrlab;
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yystack.s_mark);
#endif
if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yystack.s_mark;
--yystack.l_mark;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
if (yym)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 3:
#line 35 "quote_calc3.y"
{ yyerrok ; }
break;
case 4:
#line 39 "quote_calc3.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 41 "quote_calc3.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 45 "quote_calc3.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 47 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 49 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 51 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 53 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 55 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 57 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 59 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 61 "quote_calc3.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 63 "quote_calc3.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 68 "quote_calc3.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 70 "quote_calc3.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 628 "quote_calc3-s.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yystack.s_mark = YYFINAL;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
*++yystack.s_mark = (short) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
yyfreestack(&yystack);
return (1);
yyaccept:
yyfreestack(&yystack);
return (0);
}

View File

@@ -0,0 +1,11 @@
/* $NetBSD: quote_calc3-s.tab.h,v 1.1.1.1 2013/04/06 14:45:27 christos Exp $ */
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271

View File

@@ -0,0 +1,557 @@
0 $accept : list $end
1 list :
2 | list stat '\n'
3 | list error '\n'
4 stat : expr
5 | LETTER '=' expr
6 expr : '(' expr ')'
7 | expr OP_ADD expr
8 | expr OP_SUB expr
9 | expr OP_MUL expr
10 | expr OP_DIV expr
11 | expr OP_MOD expr
12 | expr OP_AND expr
13 | expr '|' expr
14 | OP_SUB expr
15 | LETTER
16 | number
17 number : DIGIT
18 | number DIGIT
state 0
$accept : . list $end (0)
list : . (1)
. reduce 1
list goto 1
state 1
$accept : list . $end (0)
list : list . stat '\n' (2)
list : list . error '\n' (3)
$end accept
error shift 2
OP_SUB shift 3
DIGIT shift 4
LETTER shift 5
'(' shift 6
. error
stat goto 7
expr goto 8
number goto 9
state 2
list : list error . '\n' (3)
'\n' shift 10
. error
state 3
expr : OP_SUB . expr (14)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 12
number goto 9
state 4
number : DIGIT . (17)
. reduce 17
state 5
stat : LETTER . '=' expr (5)
expr : LETTER . (15)
'=' shift 13
OP_ADD reduce 15
OP_SUB reduce 15
OP_MUL reduce 15
OP_DIV reduce 15
OP_MOD reduce 15
OP_AND reduce 15
'|' reduce 15
'\n' reduce 15
state 6
expr : '(' . expr ')' (6)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 14
number goto 9
state 7
list : list stat . '\n' (2)
'\n' shift 15
. error
state 8
stat : expr . (4)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 4
state 9
expr : number . (16)
number : number . DIGIT (18)
DIGIT shift 23
OP_ADD reduce 16
OP_SUB reduce 16
OP_MUL reduce 16
OP_DIV reduce 16
OP_MOD reduce 16
OP_AND reduce 16
'|' reduce 16
'\n' reduce 16
')' reduce 16
state 10
list : list error '\n' . (3)
. reduce 3
state 11
expr : LETTER . (15)
. reduce 15
12: shift/reduce conflict (shift 16, reduce 14) on OP_ADD
12: shift/reduce conflict (shift 17, reduce 14) on OP_SUB
12: shift/reduce conflict (shift 18, reduce 14) on OP_MUL
12: shift/reduce conflict (shift 19, reduce 14) on OP_DIV
12: shift/reduce conflict (shift 20, reduce 14) on OP_MOD
12: shift/reduce conflict (shift 21, reduce 14) on OP_AND
state 12
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
expr : OP_SUB expr . (14)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' reduce 14
'\n' reduce 14
')' reduce 14
state 13
stat : LETTER '=' . expr (5)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 24
number goto 9
state 14
expr : '(' expr . ')' (6)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
')' shift 25
. error
state 15
list : list stat '\n' . (2)
. reduce 2
state 16
expr : expr OP_ADD . expr (7)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 26
number goto 9
state 17
expr : expr OP_SUB . expr (8)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 27
number goto 9
state 18
expr : expr OP_MUL . expr (9)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 28
number goto 9
state 19
expr : expr OP_DIV . expr (10)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 29
number goto 9
state 20
expr : expr OP_MOD . expr (11)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 30
number goto 9
state 21
expr : expr OP_AND . expr (12)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 31
number goto 9
state 22
expr : expr '|' . expr (13)
OP_SUB shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 32
number goto 9
state 23
number : number DIGIT . (18)
. reduce 18
state 24
stat : LETTER '=' expr . (5)
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 5
state 25
expr : '(' expr ')' . (6)
. reduce 6
26: shift/reduce conflict (shift 16, reduce 7) on OP_ADD
26: shift/reduce conflict (shift 17, reduce 7) on OP_SUB
26: shift/reduce conflict (shift 18, reduce 7) on OP_MUL
26: shift/reduce conflict (shift 19, reduce 7) on OP_DIV
26: shift/reduce conflict (shift 20, reduce 7) on OP_MOD
26: shift/reduce conflict (shift 21, reduce 7) on OP_AND
26: shift/reduce conflict (shift 22, reduce 7) on '|'
state 26
expr : expr . OP_ADD expr (7)
expr : expr OP_ADD expr . (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 7
')' reduce 7
27: shift/reduce conflict (shift 16, reduce 8) on OP_ADD
27: shift/reduce conflict (shift 17, reduce 8) on OP_SUB
27: shift/reduce conflict (shift 18, reduce 8) on OP_MUL
27: shift/reduce conflict (shift 19, reduce 8) on OP_DIV
27: shift/reduce conflict (shift 20, reduce 8) on OP_MOD
27: shift/reduce conflict (shift 21, reduce 8) on OP_AND
27: shift/reduce conflict (shift 22, reduce 8) on '|'
state 27
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr OP_SUB expr . (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 8
')' reduce 8
28: shift/reduce conflict (shift 16, reduce 9) on OP_ADD
28: shift/reduce conflict (shift 17, reduce 9) on OP_SUB
28: shift/reduce conflict (shift 18, reduce 9) on OP_MUL
28: shift/reduce conflict (shift 19, reduce 9) on OP_DIV
28: shift/reduce conflict (shift 20, reduce 9) on OP_MOD
28: shift/reduce conflict (shift 21, reduce 9) on OP_AND
28: shift/reduce conflict (shift 22, reduce 9) on '|'
state 28
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr OP_MUL expr . (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 9
')' reduce 9
29: shift/reduce conflict (shift 16, reduce 10) on OP_ADD
29: shift/reduce conflict (shift 17, reduce 10) on OP_SUB
29: shift/reduce conflict (shift 18, reduce 10) on OP_MUL
29: shift/reduce conflict (shift 19, reduce 10) on OP_DIV
29: shift/reduce conflict (shift 20, reduce 10) on OP_MOD
29: shift/reduce conflict (shift 21, reduce 10) on OP_AND
29: shift/reduce conflict (shift 22, reduce 10) on '|'
state 29
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr OP_DIV expr . (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 10
')' reduce 10
30: shift/reduce conflict (shift 16, reduce 11) on OP_ADD
30: shift/reduce conflict (shift 17, reduce 11) on OP_SUB
30: shift/reduce conflict (shift 18, reduce 11) on OP_MUL
30: shift/reduce conflict (shift 19, reduce 11) on OP_DIV
30: shift/reduce conflict (shift 20, reduce 11) on OP_MOD
30: shift/reduce conflict (shift 21, reduce 11) on OP_AND
30: shift/reduce conflict (shift 22, reduce 11) on '|'
state 30
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr OP_MOD expr . (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 11
')' reduce 11
31: shift/reduce conflict (shift 16, reduce 12) on OP_ADD
31: shift/reduce conflict (shift 17, reduce 12) on OP_SUB
31: shift/reduce conflict (shift 18, reduce 12) on OP_MUL
31: shift/reduce conflict (shift 19, reduce 12) on OP_DIV
31: shift/reduce conflict (shift 20, reduce 12) on OP_MOD
31: shift/reduce conflict (shift 21, reduce 12) on OP_AND
31: shift/reduce conflict (shift 22, reduce 12) on '|'
state 31
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr OP_AND expr . (12)
expr : expr . '|' expr (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' shift 22
'\n' reduce 12
')' reduce 12
32: shift/reduce conflict (shift 16, reduce 13) on OP_ADD
32: shift/reduce conflict (shift 17, reduce 13) on OP_SUB
32: shift/reduce conflict (shift 18, reduce 13) on OP_MUL
32: shift/reduce conflict (shift 19, reduce 13) on OP_DIV
32: shift/reduce conflict (shift 20, reduce 13) on OP_MOD
32: shift/reduce conflict (shift 21, reduce 13) on OP_AND
state 32
expr : expr . OP_ADD expr (7)
expr : expr . OP_SUB expr (8)
expr : expr . OP_MUL expr (9)
expr : expr . OP_DIV expr (10)
expr : expr . OP_MOD expr (11)
expr : expr . OP_AND expr (12)
expr : expr . '|' expr (13)
expr : expr '|' expr . (13)
OP_ADD shift 16
OP_SUB shift 17
OP_MUL shift 18
OP_DIV shift 19
OP_MOD shift 20
OP_AND shift 21
'|' reduce 13
'\n' reduce 13
')' reduce 13
State 12 contains 6 shift/reduce conflicts.
State 26 contains 7 shift/reduce conflicts.
State 27 contains 7 shift/reduce conflicts.
State 28 contains 7 shift/reduce conflicts.
State 29 contains 7 shift/reduce conflicts.
State 30 contains 7 shift/reduce conflicts.
State 31 contains 7 shift/reduce conflicts.
State 32 contains 6 shift/reduce conflicts.
28 terminals, 5 nonterminals
19 grammar rules, 33 states

View File

@@ -0,0 +1,690 @@
/* $NetBSD: quote_calc3.tab.c,v 1.1.1.1 2013/04/06 14:45:28 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#ifndef yyparse
#define yyparse quote_calc3_parse
#endif /* yyparse */
#ifndef yylex
#define yylex quote_calc3_lex
#endif /* yylex */
#ifndef yyerror
#define yyerror quote_calc3_error
#endif /* yyerror */
#ifndef yychar
#define yychar quote_calc3_char
#endif /* yychar */
#ifndef yyval
#define yyval quote_calc3_val
#endif /* yyval */
#ifndef yylval
#define yylval quote_calc3_lval
#endif /* yylval */
#ifndef yydebug
#define yydebug quote_calc3_debug
#endif /* yydebug */
#ifndef yynerrs
#define yynerrs quote_calc3_nerrs
#endif /* yynerrs */
#ifndef yyerrflag
#define yyerrflag quote_calc3_errflag
#endif /* yyerrflag */
#ifndef yylhs
#define yylhs quote_calc3_lhs
#endif /* yylhs */
#ifndef yylen
#define yylen quote_calc3_len
#endif /* yylen */
#ifndef yydefred
#define yydefred quote_calc3_defred
#endif /* yydefred */
#ifndef yydgoto
#define yydgoto quote_calc3_dgoto
#endif /* yydgoto */
#ifndef yysindex
#define yysindex quote_calc3_sindex
#endif /* yysindex */
#ifndef yyrindex
#define yyrindex quote_calc3_rindex
#endif /* yyrindex */
#ifndef yygindex
#define yygindex quote_calc3_gindex
#endif /* yygindex */
#ifndef yytable
#define yytable quote_calc3_table
#endif /* yytable */
#ifndef yycheck
#define yycheck quote_calc3_check
#endif /* yycheck */
#ifndef yyname
#define yyname quote_calc3_name
#endif /* yyname */
#ifndef yyrule
#define yyrule quote_calc3_rule
#endif /* yyrule */
#define YYPREFIX "quote_calc3_"
#define YYPURE 0
#line 2 "quote_calc3.y"
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
#line 109 "quote_calc3.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271
#define YYERRCODE 256
static const short quote_calc3_lhs[] = { -1,
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3,
};
static const short quote_calc3_len[] = { 2,
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 2, 1, 1, 1, 2,
};
static const short quote_calc3_defred[] = { 1,
0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
0, 0,
};
static const short quote_calc3_dgoto[] = { 1,
7, 8, 9,
};
static const short quote_calc3_sindex[] = { 0,
-38, 5, -36, 0, -51, -36, 7, -121, -248, 0,
0, -243, -36, -22, 0, -36, -36, -36, -36, -36,
-36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
-121, -243,
};
static const short quote_calc3_rindex[] = { 0,
0, 0, 0, 0, -9, 0, 0, 13, -10, 0,
0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 15, 0, -3, -2, -1, 1, 2,
3, -4,
};
static const short quote_calc3_gindex[] = { 0,
0, 42, 0,
};
#define YYTABLESIZE 258
static const short quote_calc3_table[] = { 16,
15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
10, 11, 12, 16, 10, 17, 15, 18, 25, 19,
23, 20, 4, 21, 5, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 22, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 16, 0, 17, 0, 18,
0, 19, 0, 20, 0, 21, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
3, 0, 3, 0, 0, 0, 0, 0, 0, 0,
4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
19, 0, 20, 0, 21, 0, 16, 15, 16, 15,
16, 15, 16, 15, 16, 15, 16, 15,
};
static const short quote_calc3_check[] = { 10,
10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
10, 10, 10, 257, 10, 259, 10, 261, 41, 263,
269, 265, 10, 267, 10, -1, -1, -1, -1, -1,
41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
-1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
-1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, 124, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 257, -1, 259, -1, 261,
-1, 263, -1, 265, -1, 267, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
259, -1, 259, -1, -1, -1, -1, -1, -1, -1,
269, 270, 269, 270, 257, -1, 259, -1, 261, -1,
263, -1, 265, -1, 267, -1, 257, 257, 259, 259,
261, 261, 263, 263, 265, 265, 267, 267,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 271
#if YYDEBUG
static const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",
};
static const char *yyrule[] = {
"$accept : list",
"list :",
"list : list stat '\\n'",
"list : list error '\\n'",
"stat : expr",
"stat : LETTER '=' expr",
"expr : '(' expr ')'",
"expr : expr OP_ADD expr",
"expr : expr OP_SUB expr",
"expr : expr OP_MUL expr",
"expr : expr OP_DIV expr",
"expr : expr OP_MOD expr",
"expr : expr OP_AND expr",
"expr : expr '|' expr",
"expr : OP_SUB expr",
"expr : LETTER",
"expr : number",
"number : DIGIT",
"number : number DIGIT",
};
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
typedef struct {
unsigned stacksize;
short *s_base;
short *s_mark;
short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 73 "quote_calc3.y"
/* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}
#line 362 "quote_calc3.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
data->l_base = newvs;
data->l_mark = newvs + i;
data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0;
}
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
YYPARSE_DECL()
{
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
yystate = 0;
#if YYPURE
memset(&yystack, 0, sizeof(yystack));
#endif
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0;
*yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
goto yyerrlab;
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yystack.s_mark);
#endif
if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yystack.s_mark;
--yystack.l_mark;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
if (yym)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 3:
#line 35 "quote_calc3.y"
{ yyerrok ; }
break;
case 4:
#line 39 "quote_calc3.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 41 "quote_calc3.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 45 "quote_calc3.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 47 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 49 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 51 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 53 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 55 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 57 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 59 "quote_calc3.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 61 "quote_calc3.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 63 "quote_calc3.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 68 "quote_calc3.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 70 "quote_calc3.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 628 "quote_calc3.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yystack.s_mark = YYFINAL;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
*++yystack.s_mark = (short) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
yyfreestack(&yystack);
return (1);
yyaccept:
yyfreestack(&yystack);
return (0);
}

View File

@@ -0,0 +1,11 @@
/* $NetBSD: quote_calc3.tab.h,v 1.1.1.1 2013/04/06 14:45:30 christos Exp $ */
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271

View File

@@ -0,0 +1,114 @@
/* $NetBSD: quote_calc3.y,v 1.1.1.1 2013/04/06 14:45:27 christos Exp $ */
%{
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
%}
%start list
%token OP_ADD "ADD-operator"
%token OP_SUB "SUB-operator"
%token OP_MUL "MUL-operator"
%token OP_DIV "DIV-operator"
%token OP_MOD "MOD-operator"
%token OP_AND "AND-operator"
%token DIGIT LETTER
%left '|'
%left '&'
%left '+' '-'
%left '*' '/' '%'
%left UMINUS /* supplies precedence for unary minus */
%% /* beginning of rules section */
list : /* empty */
| list stat '\n'
| list error '\n'
{ yyerrok ; }
;
stat : expr
{ printf("%d\n",$1);}
| LETTER '=' expr
{ regs[$1] = $3; }
;
expr : '(' expr ')'
{ $$ = $2; }
| expr OP_ADD expr
{ $$ = $1 + $3; }
| expr OP_SUB expr
{ $$ = $1 - $3; }
| expr OP_MUL expr
{ $$ = $1 * $3; }
| expr OP_DIV expr
{ $$ = $1 / $3; }
| expr OP_MOD expr
{ $$ = $1 % $3; }
| expr OP_AND expr
{ $$ = $1 & $3; }
| expr '|' expr
{ $$ = $1 | $3; }
| OP_SUB expr %prec UMINUS
{ $$ = - $2; }
| LETTER
{ $$ = regs[$1]; }
| number
;
number: DIGIT
{ $$ = $1; base = ($1==0) ? 8 : 10; }
| number DIGIT
{ $$ = base * $1 + $2; }
;
%% /* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}

View File

@@ -0,0 +1,557 @@
0 $accept : list $end
1 list :
2 | list stat '\n'
3 | list error '\n'
4 stat : expr
5 | LETTER '=' expr
6 expr : '(' expr ')'
7 | expr "ADD-operator" expr
8 | expr "SUB-operator" expr
9 | expr "MUL-operator" expr
10 | expr "DIV-operator" expr
11 | expr "MOD-operator" expr
12 | expr "AND-operator" expr
13 | expr '|' expr
14 | "SUB-operator" expr
15 | LETTER
16 | number
17 number : DIGIT
18 | number DIGIT
state 0
$accept : . list $end (0)
list : . (1)
. reduce 1
list goto 1
state 1
$accept : list . $end (0)
list : list . stat '\n' (2)
list : list . error '\n' (3)
$end accept
error shift 2
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 5
'(' shift 6
. error
stat goto 7
expr goto 8
number goto 9
state 2
list : list error . '\n' (3)
'\n' shift 10
. error
state 3
expr : "SUB-operator" . expr (14)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 12
number goto 9
state 4
number : DIGIT . (17)
. reduce 17
state 5
stat : LETTER . '=' expr (5)
expr : LETTER . (15)
'=' shift 13
"ADD-operator" reduce 15
"SUB-operator" reduce 15
"MUL-operator" reduce 15
"DIV-operator" reduce 15
"MOD-operator" reduce 15
"AND-operator" reduce 15
'|' reduce 15
'\n' reduce 15
state 6
expr : '(' . expr ')' (6)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 14
number goto 9
state 7
list : list stat . '\n' (2)
'\n' shift 15
. error
state 8
stat : expr . (4)
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 4
state 9
expr : number . (16)
number : number . DIGIT (18)
DIGIT shift 23
"ADD-operator" reduce 16
"SUB-operator" reduce 16
"MUL-operator" reduce 16
"DIV-operator" reduce 16
"MOD-operator" reduce 16
"AND-operator" reduce 16
'|' reduce 16
'\n' reduce 16
')' reduce 16
state 10
list : list error '\n' . (3)
. reduce 3
state 11
expr : LETTER . (15)
. reduce 15
12: shift/reduce conflict (shift 16, reduce 14) on "ADD-operator"
12: shift/reduce conflict (shift 17, reduce 14) on "SUB-operator"
12: shift/reduce conflict (shift 18, reduce 14) on "MUL-operator"
12: shift/reduce conflict (shift 19, reduce 14) on "DIV-operator"
12: shift/reduce conflict (shift 20, reduce 14) on "MOD-operator"
12: shift/reduce conflict (shift 21, reduce 14) on "AND-operator"
state 12
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
expr : "SUB-operator" expr . (14)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' reduce 14
'\n' reduce 14
')' reduce 14
state 13
stat : LETTER '=' . expr (5)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 24
number goto 9
state 14
expr : '(' expr . ')' (6)
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
')' shift 25
. error
state 15
list : list stat '\n' . (2)
. reduce 2
state 16
expr : expr "ADD-operator" . expr (7)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 26
number goto 9
state 17
expr : expr "SUB-operator" . expr (8)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 27
number goto 9
state 18
expr : expr "MUL-operator" . expr (9)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 28
number goto 9
state 19
expr : expr "DIV-operator" . expr (10)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 29
number goto 9
state 20
expr : expr "MOD-operator" . expr (11)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 30
number goto 9
state 21
expr : expr "AND-operator" . expr (12)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 31
number goto 9
state 22
expr : expr '|' . expr (13)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 32
number goto 9
state 23
number : number DIGIT . (18)
. reduce 18
state 24
stat : LETTER '=' expr . (5)
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 5
state 25
expr : '(' expr ')' . (6)
. reduce 6
26: shift/reduce conflict (shift 16, reduce 7) on "ADD-operator"
26: shift/reduce conflict (shift 17, reduce 7) on "SUB-operator"
26: shift/reduce conflict (shift 18, reduce 7) on "MUL-operator"
26: shift/reduce conflict (shift 19, reduce 7) on "DIV-operator"
26: shift/reduce conflict (shift 20, reduce 7) on "MOD-operator"
26: shift/reduce conflict (shift 21, reduce 7) on "AND-operator"
26: shift/reduce conflict (shift 22, reduce 7) on '|'
state 26
expr : expr . "ADD-operator" expr (7)
expr : expr "ADD-operator" expr . (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 7
')' reduce 7
27: shift/reduce conflict (shift 16, reduce 8) on "ADD-operator"
27: shift/reduce conflict (shift 17, reduce 8) on "SUB-operator"
27: shift/reduce conflict (shift 18, reduce 8) on "MUL-operator"
27: shift/reduce conflict (shift 19, reduce 8) on "DIV-operator"
27: shift/reduce conflict (shift 20, reduce 8) on "MOD-operator"
27: shift/reduce conflict (shift 21, reduce 8) on "AND-operator"
27: shift/reduce conflict (shift 22, reduce 8) on '|'
state 27
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr "SUB-operator" expr . (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 8
')' reduce 8
28: shift/reduce conflict (shift 16, reduce 9) on "ADD-operator"
28: shift/reduce conflict (shift 17, reduce 9) on "SUB-operator"
28: shift/reduce conflict (shift 18, reduce 9) on "MUL-operator"
28: shift/reduce conflict (shift 19, reduce 9) on "DIV-operator"
28: shift/reduce conflict (shift 20, reduce 9) on "MOD-operator"
28: shift/reduce conflict (shift 21, reduce 9) on "AND-operator"
28: shift/reduce conflict (shift 22, reduce 9) on '|'
state 28
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr "MUL-operator" expr . (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 9
')' reduce 9
29: shift/reduce conflict (shift 16, reduce 10) on "ADD-operator"
29: shift/reduce conflict (shift 17, reduce 10) on "SUB-operator"
29: shift/reduce conflict (shift 18, reduce 10) on "MUL-operator"
29: shift/reduce conflict (shift 19, reduce 10) on "DIV-operator"
29: shift/reduce conflict (shift 20, reduce 10) on "MOD-operator"
29: shift/reduce conflict (shift 21, reduce 10) on "AND-operator"
29: shift/reduce conflict (shift 22, reduce 10) on '|'
state 29
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr "DIV-operator" expr . (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 10
')' reduce 10
30: shift/reduce conflict (shift 16, reduce 11) on "ADD-operator"
30: shift/reduce conflict (shift 17, reduce 11) on "SUB-operator"
30: shift/reduce conflict (shift 18, reduce 11) on "MUL-operator"
30: shift/reduce conflict (shift 19, reduce 11) on "DIV-operator"
30: shift/reduce conflict (shift 20, reduce 11) on "MOD-operator"
30: shift/reduce conflict (shift 21, reduce 11) on "AND-operator"
30: shift/reduce conflict (shift 22, reduce 11) on '|'
state 30
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr "MOD-operator" expr . (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 11
')' reduce 11
31: shift/reduce conflict (shift 16, reduce 12) on "ADD-operator"
31: shift/reduce conflict (shift 17, reduce 12) on "SUB-operator"
31: shift/reduce conflict (shift 18, reduce 12) on "MUL-operator"
31: shift/reduce conflict (shift 19, reduce 12) on "DIV-operator"
31: shift/reduce conflict (shift 20, reduce 12) on "MOD-operator"
31: shift/reduce conflict (shift 21, reduce 12) on "AND-operator"
31: shift/reduce conflict (shift 22, reduce 12) on '|'
state 31
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr "AND-operator" expr . (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 12
')' reduce 12
32: shift/reduce conflict (shift 16, reduce 13) on "ADD-operator"
32: shift/reduce conflict (shift 17, reduce 13) on "SUB-operator"
32: shift/reduce conflict (shift 18, reduce 13) on "MUL-operator"
32: shift/reduce conflict (shift 19, reduce 13) on "DIV-operator"
32: shift/reduce conflict (shift 20, reduce 13) on "MOD-operator"
32: shift/reduce conflict (shift 21, reduce 13) on "AND-operator"
state 32
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
expr : expr '|' expr . (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' reduce 13
'\n' reduce 13
')' reduce 13
State 12 contains 6 shift/reduce conflicts.
State 26 contains 7 shift/reduce conflicts.
State 27 contains 7 shift/reduce conflicts.
State 28 contains 7 shift/reduce conflicts.
State 29 contains 7 shift/reduce conflicts.
State 30 contains 7 shift/reduce conflicts.
State 31 contains 7 shift/reduce conflicts.
State 32 contains 6 shift/reduce conflicts.
28 terminals, 5 nonterminals
19 grammar rules, 33 states

View File

@@ -0,0 +1,690 @@
/* $NetBSD: quote_calc4-s.tab.c,v 1.1.1.1 2013/04/06 14:45:30 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#ifndef yyparse
#define yyparse quote_calc4_parse
#endif /* yyparse */
#ifndef yylex
#define yylex quote_calc4_lex
#endif /* yylex */
#ifndef yyerror
#define yyerror quote_calc4_error
#endif /* yyerror */
#ifndef yychar
#define yychar quote_calc4_char
#endif /* yychar */
#ifndef yyval
#define yyval quote_calc4_val
#endif /* yyval */
#ifndef yylval
#define yylval quote_calc4_lval
#endif /* yylval */
#ifndef yydebug
#define yydebug quote_calc4_debug
#endif /* yydebug */
#ifndef yynerrs
#define yynerrs quote_calc4_nerrs
#endif /* yynerrs */
#ifndef yyerrflag
#define yyerrflag quote_calc4_errflag
#endif /* yyerrflag */
#ifndef yylhs
#define yylhs quote_calc4_lhs
#endif /* yylhs */
#ifndef yylen
#define yylen quote_calc4_len
#endif /* yylen */
#ifndef yydefred
#define yydefred quote_calc4_defred
#endif /* yydefred */
#ifndef yydgoto
#define yydgoto quote_calc4_dgoto
#endif /* yydgoto */
#ifndef yysindex
#define yysindex quote_calc4_sindex
#endif /* yysindex */
#ifndef yyrindex
#define yyrindex quote_calc4_rindex
#endif /* yyrindex */
#ifndef yygindex
#define yygindex quote_calc4_gindex
#endif /* yygindex */
#ifndef yytable
#define yytable quote_calc4_table
#endif /* yytable */
#ifndef yycheck
#define yycheck quote_calc4_check
#endif /* yycheck */
#ifndef yyname
#define yyname quote_calc4_name
#endif /* yyname */
#ifndef yyrule
#define yyrule quote_calc4_rule
#endif /* yyrule */
#define YYPREFIX "quote_calc4_"
#define YYPURE 0
#line 2 "quote_calc4.y"
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
#line 109 "quote_calc4-s.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271
#define YYERRCODE 256
static const short quote_calc4_lhs[] = { -1,
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3,
};
static const short quote_calc4_len[] = { 2,
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 2, 1, 1, 1, 2,
};
static const short quote_calc4_defred[] = { 1,
0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
0, 0,
};
static const short quote_calc4_dgoto[] = { 1,
7, 8, 9,
};
static const short quote_calc4_sindex[] = { 0,
-38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
-36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
-121, -243,
};
static const short quote_calc4_rindex[] = { 0,
0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
3, -4,
};
static const short quote_calc4_gindex[] = { 0,
0, 42, 0,
};
#define YYTABLESIZE 259
static const short quote_calc4_table[] = { 16,
15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
18, 0, 19, 0, 20, 0, 21, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
15, 16, 15, 16, 15, 16, 15, 16, 15,
};
static const short quote_calc4_check[] = { 10,
10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
-1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
-1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
262, -1, 264, -1, 266, -1, 268, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
-1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
260, 262, 262, 264, 264, 266, 266, 268, 268,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 271
#if YYDEBUG
static const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",
};
static const char *yyrule[] = {
"$accept : list",
"list :",
"list : list stat '\\n'",
"list : list error '\\n'",
"stat : expr",
"stat : LETTER '=' expr",
"expr : '(' expr ')'",
"expr : expr \"ADD-operator\" expr",
"expr : expr \"SUB-operator\" expr",
"expr : expr \"MUL-operator\" expr",
"expr : expr \"DIV-operator\" expr",
"expr : expr \"MOD-operator\" expr",
"expr : expr \"AND-operator\" expr",
"expr : expr '|' expr",
"expr : \"SUB-operator\" expr",
"expr : LETTER",
"expr : number",
"number : DIGIT",
"number : number DIGIT",
};
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
typedef struct {
unsigned stacksize;
short *s_base;
short *s_mark;
short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 73 "quote_calc4.y"
/* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}
#line 362 "quote_calc4-s.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
data->l_base = newvs;
data->l_mark = newvs + i;
data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0;
}
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
YYPARSE_DECL()
{
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
yystate = 0;
#if YYPURE
memset(&yystack, 0, sizeof(yystack));
#endif
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0;
*yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
goto yyerrlab;
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yystack.s_mark);
#endif
if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yystack.s_mark;
--yystack.l_mark;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
if (yym)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 3:
#line 35 "quote_calc4.y"
{ yyerrok ; }
break;
case 4:
#line 39 "quote_calc4.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 41 "quote_calc4.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 45 "quote_calc4.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 47 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 49 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 51 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 53 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 55 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 57 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 59 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 61 "quote_calc4.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 63 "quote_calc4.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 68 "quote_calc4.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 70 "quote_calc4.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 628 "quote_calc4-s.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yystack.s_mark = YYFINAL;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
*++yystack.s_mark = (short) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
yyfreestack(&yystack);
return (1);
yyaccept:
yyfreestack(&yystack);
return (0);
}

View File

@@ -0,0 +1,11 @@
/* $NetBSD: quote_calc4-s.tab.h,v 1.1.1.1 2013/04/06 14:45:29 christos Exp $ */
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271

View File

@@ -0,0 +1,557 @@
0 $accept : list $end
1 list :
2 | list stat '\n'
3 | list error '\n'
4 stat : expr
5 | LETTER '=' expr
6 expr : '(' expr ')'
7 | expr "ADD-operator" expr
8 | expr "SUB-operator" expr
9 | expr "MUL-operator" expr
10 | expr "DIV-operator" expr
11 | expr "MOD-operator" expr
12 | expr "AND-operator" expr
13 | expr '|' expr
14 | "SUB-operator" expr
15 | LETTER
16 | number
17 number : DIGIT
18 | number DIGIT
state 0
$accept : . list $end (0)
list : . (1)
. reduce 1
list goto 1
state 1
$accept : list . $end (0)
list : list . stat '\n' (2)
list : list . error '\n' (3)
$end accept
error shift 2
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 5
'(' shift 6
. error
stat goto 7
expr goto 8
number goto 9
state 2
list : list error . '\n' (3)
'\n' shift 10
. error
state 3
expr : "SUB-operator" . expr (14)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 12
number goto 9
state 4
number : DIGIT . (17)
. reduce 17
state 5
stat : LETTER . '=' expr (5)
expr : LETTER . (15)
'=' shift 13
"ADD-operator" reduce 15
"SUB-operator" reduce 15
"MUL-operator" reduce 15
"DIV-operator" reduce 15
"MOD-operator" reduce 15
"AND-operator" reduce 15
'|' reduce 15
'\n' reduce 15
state 6
expr : '(' . expr ')' (6)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 14
number goto 9
state 7
list : list stat . '\n' (2)
'\n' shift 15
. error
state 8
stat : expr . (4)
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 4
state 9
expr : number . (16)
number : number . DIGIT (18)
DIGIT shift 23
"ADD-operator" reduce 16
"SUB-operator" reduce 16
"MUL-operator" reduce 16
"DIV-operator" reduce 16
"MOD-operator" reduce 16
"AND-operator" reduce 16
'|' reduce 16
'\n' reduce 16
')' reduce 16
state 10
list : list error '\n' . (3)
. reduce 3
state 11
expr : LETTER . (15)
. reduce 15
12: shift/reduce conflict (shift 16, reduce 14) on "ADD-operator"
12: shift/reduce conflict (shift 17, reduce 14) on "SUB-operator"
12: shift/reduce conflict (shift 18, reduce 14) on "MUL-operator"
12: shift/reduce conflict (shift 19, reduce 14) on "DIV-operator"
12: shift/reduce conflict (shift 20, reduce 14) on "MOD-operator"
12: shift/reduce conflict (shift 21, reduce 14) on "AND-operator"
state 12
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
expr : "SUB-operator" expr . (14)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' reduce 14
'\n' reduce 14
')' reduce 14
state 13
stat : LETTER '=' . expr (5)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 24
number goto 9
state 14
expr : '(' expr . ')' (6)
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
')' shift 25
. error
state 15
list : list stat '\n' . (2)
. reduce 2
state 16
expr : expr "ADD-operator" . expr (7)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 26
number goto 9
state 17
expr : expr "SUB-operator" . expr (8)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 27
number goto 9
state 18
expr : expr "MUL-operator" . expr (9)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 28
number goto 9
state 19
expr : expr "DIV-operator" . expr (10)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 29
number goto 9
state 20
expr : expr "MOD-operator" . expr (11)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 30
number goto 9
state 21
expr : expr "AND-operator" . expr (12)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 31
number goto 9
state 22
expr : expr '|' . expr (13)
"SUB-operator" shift 3
DIGIT shift 4
LETTER shift 11
'(' shift 6
. error
expr goto 32
number goto 9
state 23
number : number DIGIT . (18)
. reduce 18
state 24
stat : LETTER '=' expr . (5)
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 5
state 25
expr : '(' expr ')' . (6)
. reduce 6
26: shift/reduce conflict (shift 16, reduce 7) on "ADD-operator"
26: shift/reduce conflict (shift 17, reduce 7) on "SUB-operator"
26: shift/reduce conflict (shift 18, reduce 7) on "MUL-operator"
26: shift/reduce conflict (shift 19, reduce 7) on "DIV-operator"
26: shift/reduce conflict (shift 20, reduce 7) on "MOD-operator"
26: shift/reduce conflict (shift 21, reduce 7) on "AND-operator"
26: shift/reduce conflict (shift 22, reduce 7) on '|'
state 26
expr : expr . "ADD-operator" expr (7)
expr : expr "ADD-operator" expr . (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 7
')' reduce 7
27: shift/reduce conflict (shift 16, reduce 8) on "ADD-operator"
27: shift/reduce conflict (shift 17, reduce 8) on "SUB-operator"
27: shift/reduce conflict (shift 18, reduce 8) on "MUL-operator"
27: shift/reduce conflict (shift 19, reduce 8) on "DIV-operator"
27: shift/reduce conflict (shift 20, reduce 8) on "MOD-operator"
27: shift/reduce conflict (shift 21, reduce 8) on "AND-operator"
27: shift/reduce conflict (shift 22, reduce 8) on '|'
state 27
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr "SUB-operator" expr . (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 8
')' reduce 8
28: shift/reduce conflict (shift 16, reduce 9) on "ADD-operator"
28: shift/reduce conflict (shift 17, reduce 9) on "SUB-operator"
28: shift/reduce conflict (shift 18, reduce 9) on "MUL-operator"
28: shift/reduce conflict (shift 19, reduce 9) on "DIV-operator"
28: shift/reduce conflict (shift 20, reduce 9) on "MOD-operator"
28: shift/reduce conflict (shift 21, reduce 9) on "AND-operator"
28: shift/reduce conflict (shift 22, reduce 9) on '|'
state 28
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr "MUL-operator" expr . (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 9
')' reduce 9
29: shift/reduce conflict (shift 16, reduce 10) on "ADD-operator"
29: shift/reduce conflict (shift 17, reduce 10) on "SUB-operator"
29: shift/reduce conflict (shift 18, reduce 10) on "MUL-operator"
29: shift/reduce conflict (shift 19, reduce 10) on "DIV-operator"
29: shift/reduce conflict (shift 20, reduce 10) on "MOD-operator"
29: shift/reduce conflict (shift 21, reduce 10) on "AND-operator"
29: shift/reduce conflict (shift 22, reduce 10) on '|'
state 29
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr "DIV-operator" expr . (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 10
')' reduce 10
30: shift/reduce conflict (shift 16, reduce 11) on "ADD-operator"
30: shift/reduce conflict (shift 17, reduce 11) on "SUB-operator"
30: shift/reduce conflict (shift 18, reduce 11) on "MUL-operator"
30: shift/reduce conflict (shift 19, reduce 11) on "DIV-operator"
30: shift/reduce conflict (shift 20, reduce 11) on "MOD-operator"
30: shift/reduce conflict (shift 21, reduce 11) on "AND-operator"
30: shift/reduce conflict (shift 22, reduce 11) on '|'
state 30
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr "MOD-operator" expr . (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 11
')' reduce 11
31: shift/reduce conflict (shift 16, reduce 12) on "ADD-operator"
31: shift/reduce conflict (shift 17, reduce 12) on "SUB-operator"
31: shift/reduce conflict (shift 18, reduce 12) on "MUL-operator"
31: shift/reduce conflict (shift 19, reduce 12) on "DIV-operator"
31: shift/reduce conflict (shift 20, reduce 12) on "MOD-operator"
31: shift/reduce conflict (shift 21, reduce 12) on "AND-operator"
31: shift/reduce conflict (shift 22, reduce 12) on '|'
state 31
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr "AND-operator" expr . (12)
expr : expr . '|' expr (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' shift 22
'\n' reduce 12
')' reduce 12
32: shift/reduce conflict (shift 16, reduce 13) on "ADD-operator"
32: shift/reduce conflict (shift 17, reduce 13) on "SUB-operator"
32: shift/reduce conflict (shift 18, reduce 13) on "MUL-operator"
32: shift/reduce conflict (shift 19, reduce 13) on "DIV-operator"
32: shift/reduce conflict (shift 20, reduce 13) on "MOD-operator"
32: shift/reduce conflict (shift 21, reduce 13) on "AND-operator"
state 32
expr : expr . "ADD-operator" expr (7)
expr : expr . "SUB-operator" expr (8)
expr : expr . "MUL-operator" expr (9)
expr : expr . "DIV-operator" expr (10)
expr : expr . "MOD-operator" expr (11)
expr : expr . "AND-operator" expr (12)
expr : expr . '|' expr (13)
expr : expr '|' expr . (13)
"ADD-operator" shift 16
"SUB-operator" shift 17
"MUL-operator" shift 18
"DIV-operator" shift 19
"MOD-operator" shift 20
"AND-operator" shift 21
'|' reduce 13
'\n' reduce 13
')' reduce 13
State 12 contains 6 shift/reduce conflicts.
State 26 contains 7 shift/reduce conflicts.
State 27 contains 7 shift/reduce conflicts.
State 28 contains 7 shift/reduce conflicts.
State 29 contains 7 shift/reduce conflicts.
State 30 contains 7 shift/reduce conflicts.
State 31 contains 7 shift/reduce conflicts.
State 32 contains 6 shift/reduce conflicts.
28 terminals, 5 nonterminals
19 grammar rules, 33 states

View File

@@ -0,0 +1,690 @@
/* $NetBSD: quote_calc4.tab.c,v 1.1.1.1 2013/04/06 14:45:29 christos Exp $ */
#ifndef lint
static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#endif
#define YYBYACC 1
#define YYMAJOR 1
#define YYMINOR 9
#define YYEMPTY (-1)
#define yyclearin (yychar = YYEMPTY)
#define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0)
#ifndef yyparse
#define yyparse quote_calc4_parse
#endif /* yyparse */
#ifndef yylex
#define yylex quote_calc4_lex
#endif /* yylex */
#ifndef yyerror
#define yyerror quote_calc4_error
#endif /* yyerror */
#ifndef yychar
#define yychar quote_calc4_char
#endif /* yychar */
#ifndef yyval
#define yyval quote_calc4_val
#endif /* yyval */
#ifndef yylval
#define yylval quote_calc4_lval
#endif /* yylval */
#ifndef yydebug
#define yydebug quote_calc4_debug
#endif /* yydebug */
#ifndef yynerrs
#define yynerrs quote_calc4_nerrs
#endif /* yynerrs */
#ifndef yyerrflag
#define yyerrflag quote_calc4_errflag
#endif /* yyerrflag */
#ifndef yylhs
#define yylhs quote_calc4_lhs
#endif /* yylhs */
#ifndef yylen
#define yylen quote_calc4_len
#endif /* yylen */
#ifndef yydefred
#define yydefred quote_calc4_defred
#endif /* yydefred */
#ifndef yydgoto
#define yydgoto quote_calc4_dgoto
#endif /* yydgoto */
#ifndef yysindex
#define yysindex quote_calc4_sindex
#endif /* yysindex */
#ifndef yyrindex
#define yyrindex quote_calc4_rindex
#endif /* yyrindex */
#ifndef yygindex
#define yygindex quote_calc4_gindex
#endif /* yygindex */
#ifndef yytable
#define yytable quote_calc4_table
#endif /* yytable */
#ifndef yycheck
#define yycheck quote_calc4_check
#endif /* yycheck */
#ifndef yyname
#define yyname quote_calc4_name
#endif /* yyname */
#ifndef yyrule
#define yyrule quote_calc4_rule
#endif /* yyrule */
#define YYPREFIX "quote_calc4_"
#define YYPURE 0
#line 2 "quote_calc4.y"
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
#line 109 "quote_calc4.tab.c"
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271
#define YYERRCODE 256
static const short quote_calc4_lhs[] = { -1,
0, 0, 0, 1, 1, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 3, 3,
};
static const short quote_calc4_len[] = { 2,
0, 3, 3, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 2, 1, 1, 1, 2,
};
static const short quote_calc4_defred[] = { 1,
0, 0, 0, 17, 0, 0, 0, 0, 0, 3,
15, 0, 0, 0, 2, 0, 0, 0, 0, 0,
0, 0, 18, 0, 6, 0, 0, 0, 0, 0,
0, 0,
};
static const short quote_calc4_dgoto[] = { 1,
7, 8, 9,
};
static const short quote_calc4_sindex[] = { 0,
-38, 4, -36, 0, -51, -36, 6, -121, -249, 0,
0, -243, -36, -23, 0, -36, -36, -36, -36, -36,
-36, -36, 0, -121, 0, -121, -121, -121, -121, -121,
-121, -243,
};
static const short quote_calc4_rindex[] = { 0,
0, 0, 0, 0, -9, 0, 0, 12, -10, 0,
0, -5, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 14, 0, -3, -2, -1, 1, 2,
3, -4,
};
static const short quote_calc4_gindex[] = { 0,
0, 42, 0,
};
#define YYTABLESIZE 259
static const short quote_calc4_table[] = { 16,
15, 6, 22, 6, 14, 13, 7, 8, 9, 13,
10, 11, 12, 10, 16, 15, 17, 25, 18, 23,
19, 4, 20, 5, 21, 0, 0, 0, 0, 0,
16, 0, 0, 0, 0, 14, 13, 7, 8, 9,
0, 10, 11, 12, 12, 0, 0, 14, 0, 0,
0, 0, 0, 0, 24, 0, 0, 26, 27, 28,
29, 30, 31, 32, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
22, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 16, 15, 0, 0, 0, 14, 13,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 16, 0, 17, 0,
18, 0, 19, 0, 20, 0, 21, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 2, 0, 0,
0, 3, 0, 3, 0, 0, 0, 0, 0, 0,
4, 5, 4, 11, 16, 0, 17, 0, 18, 0,
19, 0, 20, 0, 21, 0, 0, 16, 15, 16,
15, 16, 15, 16, 15, 16, 15, 16, 15,
};
static const short quote_calc4_check[] = { 10,
10, 40, 124, 40, 10, 10, 10, 10, 10, 61,
10, 10, 10, 10, 258, 10, 260, 41, 262, 269,
264, 10, 266, 10, 268, -1, -1, -1, -1, -1,
41, -1, -1, -1, -1, 41, 41, 41, 41, 41,
-1, 41, 41, 41, 3, -1, -1, 6, -1, -1,
-1, -1, -1, -1, 13, -1, -1, 16, 17, 18,
19, 20, 21, 22, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
124, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 124, 124, -1, -1, -1, 124, 124,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, 258, -1, 260, -1,
262, -1, 264, -1, 266, -1, 268, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, 256, -1, -1,
-1, 260, -1, 260, -1, -1, -1, -1, -1, -1,
269, 270, 269, 270, 258, -1, 260, -1, 262, -1,
264, -1, 266, -1, 268, -1, -1, 258, 258, 260,
260, 262, 262, 264, 264, 266, 266, 268, 268,
};
#define YYFINAL 1
#ifndef YYDEBUG
#define YYDEBUG 0
#endif
#define YYMAXTOKEN 271
#if YYDEBUG
static const char *yyname[] = {
"end-of-file",0,0,0,0,0,0,0,0,0,"'\\n'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
0,0,0,0,0,0,"'='",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,"OP_ADD","\"ADD-operator\"","OP_SUB","\"SUB-operator\"","OP_MUL",
"\"MUL-operator\"","OP_DIV","\"DIV-operator\"","OP_MOD","\"MOD-operator\"",
"OP_AND","\"AND-operator\"","DIGIT","LETTER","UMINUS",
};
static const char *yyrule[] = {
"$accept : list",
"list :",
"list : list stat '\\n'",
"list : list error '\\n'",
"stat : expr",
"stat : LETTER '=' expr",
"expr : '(' expr ')'",
"expr : expr \"ADD-operator\" expr",
"expr : expr \"SUB-operator\" expr",
"expr : expr \"MUL-operator\" expr",
"expr : expr \"DIV-operator\" expr",
"expr : expr \"MOD-operator\" expr",
"expr : expr \"AND-operator\" expr",
"expr : expr '|' expr",
"expr : \"SUB-operator\" expr",
"expr : LETTER",
"expr : number",
"number : DIGIT",
"number : number DIGIT",
};
#endif
int yydebug;
int yynerrs;
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
#undef YYMAXDEPTH
#define YYMAXDEPTH YYSTACKSIZE
#else
#ifdef YYMAXDEPTH
#define YYSTACKSIZE YYMAXDEPTH
#else
#define YYSTACKSIZE 500
#define YYMAXDEPTH 500
#endif
#endif
#define YYINITSTACKSIZE 500
typedef struct {
unsigned stacksize;
short *s_base;
short *s_mark;
short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
#line 73 "quote_calc4.y"
/* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}
#line 362 "quote_calc4.tab.c"
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
data->s_base = newss;
data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
data->l_base = newvs;
data->l_mark = newvs + i;
data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0;
}
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort
#define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
#define YYERROR goto yyerrlab
int
YYPARSE_DECL()
{
int yym, yyn, yystate;
#if YYDEBUG
const char *yys;
if ((yys = getenv("YYDEBUG")) != 0)
{
yyn = *yys;
if (yyn >= '0' && yyn <= '9')
yydebug = yyn - '0';
}
#endif
yynerrs = 0;
yyerrflag = 0;
yychar = YYEMPTY;
yystate = 0;
#if YYPURE
memset(&yystack, 0, sizeof(yystack));
#endif
if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0;
*yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
}
if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
}
if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
{
yyn = yytable[yyn];
goto yyreduce;
}
if (yyerrflag) goto yyinrecovery;
yyerror("syntax error");
goto yyerrlab;
yyerrlab:
++yynerrs;
yyinrecovery:
if (yyerrflag < 3)
{
yyerrflag = 3;
for (;;)
{
if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
*++yystack.s_mark = yytable[yyn];
*++yystack.l_mark = yylval;
goto yyloop;
}
else
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yystack.s_mark);
#endif
if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yystack.s_mark;
--yystack.l_mark;
}
}
}
else
{
if (yychar == 0) goto yyabort;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
YYPREFIX, yystate, yychar, yys);
}
#endif
yychar = YYEMPTY;
goto yyloop;
}
yyreduce:
#if YYDEBUG
if (yydebug)
printf("%sdebug: state %d, reducing by rule %d (%s)\n",
YYPREFIX, yystate, yyn, yyrule[yyn]);
#endif
yym = yylen[yyn];
if (yym)
yyval = yystack.l_mark[1-yym];
else
memset(&yyval, 0, sizeof yyval);
switch (yyn)
{
case 3:
#line 35 "quote_calc4.y"
{ yyerrok ; }
break;
case 4:
#line 39 "quote_calc4.y"
{ printf("%d\n",yystack.l_mark[0]);}
break;
case 5:
#line 41 "quote_calc4.y"
{ regs[yystack.l_mark[-2]] = yystack.l_mark[0]; }
break;
case 6:
#line 45 "quote_calc4.y"
{ yyval = yystack.l_mark[-1]; }
break;
case 7:
#line 47 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] + yystack.l_mark[0]; }
break;
case 8:
#line 49 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] - yystack.l_mark[0]; }
break;
case 9:
#line 51 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] * yystack.l_mark[0]; }
break;
case 10:
#line 53 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] / yystack.l_mark[0]; }
break;
case 11:
#line 55 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] % yystack.l_mark[0]; }
break;
case 12:
#line 57 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] & yystack.l_mark[0]; }
break;
case 13:
#line 59 "quote_calc4.y"
{ yyval = yystack.l_mark[-2] | yystack.l_mark[0]; }
break;
case 14:
#line 61 "quote_calc4.y"
{ yyval = - yystack.l_mark[0]; }
break;
case 15:
#line 63 "quote_calc4.y"
{ yyval = regs[yystack.l_mark[0]]; }
break;
case 17:
#line 68 "quote_calc4.y"
{ yyval = yystack.l_mark[0]; base = (yystack.l_mark[0]==0) ? 8 : 10; }
break;
case 18:
#line 70 "quote_calc4.y"
{ yyval = base * yystack.l_mark[-1] + yystack.l_mark[0]; }
break;
#line 628 "quote_calc4.tab.c"
}
yystack.s_mark -= yym;
yystate = *yystack.s_mark;
yystack.l_mark -= yym;
yym = yylhs[yyn];
if (yystate == 0 && yym == 0)
{
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state 0 to\
state %d\n", YYPREFIX, YYFINAL);
#endif
yystate = YYFINAL;
*++yystack.s_mark = YYFINAL;
*++yystack.l_mark = yyval;
if (yychar < 0)
{
if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
yys = 0;
if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
if (!yys) yys = "illegal-symbol";
printf("%sdebug: state %d, reading %d (%s)\n",
YYPREFIX, YYFINAL, yychar, yys);
}
#endif
}
if (yychar == 0) goto yyaccept;
goto yyloop;
}
if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
yystate = yytable[yyn];
else
yystate = yydgoto[yym];
#if YYDEBUG
if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif
if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
*++yystack.s_mark = (short) yystate;
*++yystack.l_mark = yyval;
goto yyloop;
yyoverflow:
yyerror("yacc stack overflow");
yyabort:
yyfreestack(&yystack);
return (1);
yyaccept:
yyfreestack(&yystack);
return (0);
}

View File

@@ -0,0 +1,11 @@
/* $NetBSD: quote_calc4.tab.h,v 1.1.1.1 2013/04/06 14:45:27 christos Exp $ */
#define OP_ADD 257
#define OP_SUB 259
#define OP_MUL 261
#define OP_DIV 263
#define OP_MOD 265
#define OP_AND 267
#define DIGIT 269
#define LETTER 270
#define UMINUS 271

View File

@@ -0,0 +1,114 @@
/* $NetBSD: quote_calc4.y,v 1.1.1.1 2013/04/06 14:45:29 christos Exp $ */
%{
# include <stdio.h>
# include <ctype.h>
int regs[26];
int base;
int yylex(void);
static void yyerror(const char *s);
%}
%start list
%token OP_ADD "ADD-operator"
%token OP_SUB "SUB-operator"
%token OP_MUL "MUL-operator"
%token OP_DIV "DIV-operator"
%token OP_MOD "MOD-operator"
%token OP_AND "AND-operator"
%token DIGIT LETTER
%left '|'
%left '&'
%left '+' '-'
%left '*' '/' '%'
%left UMINUS /* supplies precedence for unary minus */
%% /* beginning of rules section */
list : /* empty */
| list stat '\n'
| list error '\n'
{ yyerrok ; }
;
stat : expr
{ printf("%d\n",$1);}
| LETTER '=' expr
{ regs[$1] = $3; }
;
expr : '(' expr ')'
{ $$ = $2; }
| expr "ADD-operator" expr
{ $$ = $1 + $3; }
| expr "SUB-operator" expr
{ $$ = $1 - $3; }
| expr "MUL-operator" expr
{ $$ = $1 * $3; }
| expr "DIV-operator" expr
{ $$ = $1 / $3; }
| expr "MOD-operator" expr
{ $$ = $1 % $3; }
| expr "AND-operator" expr
{ $$ = $1 & $3; }
| expr '|' expr
{ $$ = $1 | $3; }
| "SUB-operator" expr %prec UMINUS
{ $$ = - $2; }
| LETTER
{ $$ = regs[$1]; }
| number
;
number: DIGIT
{ $$ = $1; base = ($1==0) ? 8 : 10; }
| number DIGIT
{ $$ = base * $1 + $2; }
;
%% /* start of programs */
int
main (void)
{
while(!feof(stdin)) {
yyparse();
}
return 0;
}
static void
yyerror(const char *s)
{
fprintf(stderr, "%s\n", s);
}
int
yylex(void) {
/* lexical analysis routine */
/* returns LETTER for a lower case letter, yylval = 0 through 25 */
/* return DIGIT for a digit, yylval = 0 through 9 */
/* all other characters are returned immediately */
int c;
while( (c=getchar()) == ' ' ) { /* skip blanks */ }
/* c is now nonblank */
if( islower( c )) {
yylval = c - 'a';
return ( LETTER );
}
if( isdigit( c )) {
yylval = c - '0';
return ( DIGIT );
}
return( c );
}

View File

@@ -1,5 +1,5 @@
#!/bin/sh
# Id: run_lint.sh,v 1.1 2010/06/08 09:00:58 tom Exp
# Id: run_lint.sh,v 1.1 2010/06/08 09:00:58 tom Exp
# vi:ts=4 sw=4:
# run lint on each of the ".c" files in the test directory

View File

@@ -1,9 +1,11 @@
#!/bin/sh
# Id: run_make.sh,v 1.1 2010/06/08 09:00:39 tom Exp
# Id: run_make.sh,v 1.9 2012/01/15 22:35:01 tom Exp
# vi:ts=4 sw=4:
# do a test-compile on each of the ".c" files in the test-directory
BISON=`bison --version 2>/dev/null | head -n 1 | sed -e 's/^[^0-9.]*//' -e 's/[^0-9.]*$//'`
if test $# = 1
then
PROG_DIR=`pwd`
@@ -13,10 +15,125 @@ else
TEST_DIR=.
fi
MY_MAKE="make -f $PROG_DIR/makefile srcdir=$PROG_DIR VPATH=$TEST_DIR"
echo '** '`date`
for i in ${TEST_DIR}/*.c
for input in ${TEST_DIR}/*.c
do
obj=`echo "$i" |sed -e 's/\.c$/.o/'`
make -f $PROG_DIR/makefile $obj C_FILES=$i srcdir=$PROG_DIR
test -f "$input" || continue
obj=`basename "$input" .c`.o
$MY_MAKE $obj C_FILES=$input
test -f $obj && rm $obj
DEFS=
case $input in #(vi
${TEST_DIR}/pure_*)
# DEFS="-DYYLEX_PARAM=flag -DYYLEX_PARAM_TYPE=int"
;;
esac
if test "x$DEFS" != "x"
then
$MY_MAKE $obj C_FILES=$input DEFINES="$DEFS"
test -f $obj && rm -f $obj
fi
done
if test -n "$BISON"
then
echo "** compare with bison $BISON"
for input in ${TEST_DIR}/*.y
do
test -f "$input" || continue
# Bison does not support pure-parser from command-line.
# Also, its support for %expect is generally broken.
# Work around these issues using a temporary file.
echo "... testing $input"
rm -f run_make.[coy]
case $input in
pure_*)
if test -z `fgrep -l '%pure-parser' $input`
then
echo "%pure-parser" >>run_make.y
fi
;;
esac
sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y
bison -y run_make.y
sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c
rm -f y.tab.c
input=run_make.c
object=run_make.o
if test -f $input
then
$MY_MAKE $object DEFINES='-DYYENABLE_NLS=0 -DYYLTYPE_IS_TRIVIAL=1 -DYYSTACK_USE_ALLOCA=0 -DYYMAXDEPTH=0'
else
echo "?? $input not found"
fi
rm -f run_make.[coy]
done
fi
YACC=
for name in /usr/ccs/bin/yacc
do
if test -f $name
then
YACC=$name
fi
done
if test -n "$YACC"
then
echo "** compare with $YACC"
for input in ${TEST_DIR}/*.y
do
test -f "$input" || continue
echo "... testing $input"
rm -f run_make.[coy]
case $input in
pure_*)
echo "... skipping $input"
continue;
;;
*)
if fgrep '%pure-parser' $input >/dev/null ||
fgrep '%parse-param' $input >/dev/null ||
fgrep '%lex-param' $input >/dev/null ||
fgrep 'YYLEX_PARAM' $input >/dev/null
then
echo "... skipping $input"
continue;
fi
;;
esac
sed -e '/^%expect/s,%expect.*,,' $input >>run_make.y
$YACC run_make.y
sed -e '/^#line/s,"run_make.y","'$input'",' y.tab.c >run_make.c
rm -f y.tab.c
input=run_make.c
object=run_make.o
if test -f $input
then
$MY_MAKE $object
else
echo "?? $input not found"
fi
rm -f run_make.[coy]
done
fi

View File

@@ -1,5 +1,5 @@
#!/bin/sh
# Id: run_test.sh,v 1.6 2010/06/08 08:53:38 tom Exp
# Id: run_test.sh,v 1.8 2012/01/15 11:50:35 tom Exp
# vi:ts=4 sw=4:
if test $# = 1
@@ -14,22 +14,24 @@ fi
YACC=$PROG_DIR/yacc
tmpfile=temp$$
rm -f test-*
echo '** '`date`
for i in ${TEST_DIR}/*.y
for input in ${TEST_DIR}/*.y
do
case $i in
case $input in
test*)
echo "?? ignored $i"
echo "?? ignored $input"
;;
*)
root=`basename $i .y`
root=`basename $input .y`
ROOT="test-$root"
prefix=${root}_
OPTS=
OPT2=
TYPE=".output .tab.c .tab.h"
case $i in
case $input in
${TEST_DIR}/code_*)
OPTS="$OPTS -r"
TYPE="$TYPE .code.c"
@@ -39,34 +41,41 @@ do
OPTS="$OPTS -P"
prefix=`echo "$prefix" | sed -e 's/^pure_//'`
;;
${TEST_DIR}/quote_*)
OPT2="-s"
;;
esac
$YACC $OPTS -v -d -p $prefix -b $ROOT $i
for type in $TYPE
for opt2 in "" $OPT2
do
REF=${TEST_DIR}/${root}${type}
CMP=${ROOT}${type}
if test ! -f $CMP ; then
echo "...not found $CMP"
continue
fi
sed -e s,$CMP,$REF, \
-e /YYPATCH/d \
-e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \
< $CMP >$tmpfile \
&& mv $tmpfile $CMP
if test ! -f $REF
then
mv $CMP $REF
echo "...saved $REF"
elif ( cmp -s $REF $CMP )
then
echo "...ok $REF"
rm -f $CMP
else
echo "...diff $REF"
diff -u $REF $CMP
fi
$YACC $OPTS $opt2 -v -d -p $prefix -b $ROOT${opt2} $input
for type in $TYPE
do
REF=${TEST_DIR}/${root}${opt2}${type}
CMP=${ROOT}${opt2}${type}
if test ! -f $CMP
then
echo "...not found $CMP"
else
sed -e s,$CMP,$REF, \
-e /YYPATCH/d \
-e 's,#line \([1-9][0-9]*\) "'$TEST_DIR'/,#line \1 ",' \
< $CMP >$tmpfile \
&& mv $tmpfile $CMP
if test ! -f $REF
then
mv $CMP $REF
echo "...saved $REF"
elif ( cmp -s $REF $CMP )
then
echo "...ok $REF"
rm -f $CMP
else
echo "...diff $REF"
diff -u $REF $CMP
fi
fi
done
done
;;
esac

View File

@@ -1,10 +1,11 @@
/* $NetBSD: verbose.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: verbose.c,v 1.9 2010/06/09 08:58:29 tom Exp */
/* $NetBSD: verbose.c,v 1.7 2013/04/06 14:52:24 christos Exp $ */
/* Id: verbose.c,v 1.10 2012/05/26 00:45:17 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: verbose.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: verbose.c,v 1.7 2013/04/06 14:52:24 christos Exp $");
static void log_conflicts(void);
static void log_unused(void);
@@ -27,7 +28,7 @@ verbose(void)
if (!vflag)
return;
null_rules = (short *)MALLOC((unsigned)nrules * sizeof(short));
null_rules = TMALLOC(short, nrules);
NO_SPACE(null_rules);
fprintf(verbose_file, "\f\n");

View File

@@ -1,4 +1,4 @@
$! Id: vmsbuild.com,v 1.1 2000/11/21 00:38:46 tom Exp
$! Id: vmsbuild.com,v 1.1 2000/11/21 00:38:46 tom Exp
$! VMS build-script for BYACC. Requires installed C compiler
$!
$! Screen Configurations

View File

@@ -1,10 +1,11 @@
/* $NetBSD: warshall.c,v 1.6 2011/09/10 21:29:04 christos Exp $ */
/* Id: warshall.c,v 1.7 2010/06/06 22:48:51 tom Exp */
/* $NetBSD: warshall.c,v 1.7 2013/04/06 14:52:24 christos Exp $ */
/* Id: warshall.c,v 1.7 2010/06/06 22:48:51 tom Exp */
#include "defs.h"
#include <sys/cdefs.h>
__RCSID("$NetBSD: warshall.c,v 1.6 2011/09/10 21:29:04 christos Exp $");
__RCSID("$NetBSD: warshall.c,v 1.7 2013/04/06 14:52:24 christos Exp $");
static void
transitive_closure(unsigned *R, int n)

View File

@@ -1,9 +1,23 @@
.\" $NetBSD: yacc.1,v 1.4 2011/09/10 21:29:04 christos Exp $
.\" $NetBSD: yacc.1,v 1.5 2013/04/06 14:52:24 christos Exp $
.\"
.\" Id: yacc.1,v 1.12 2011/09/08 00:40:44 tom Exp
.\" Id: yacc.1,v 1.18 2012/01/15 18:12:28 tom Exp
.\"
.\" .TH YACC 1 "July\ 15,\ 1990"
.\" .UC 6
.de ES
.ne 8
.nf
.sp
.in +4
..
.de EE
.in -4
.fi
..
.\" Bulleted paragraph
.de bP
.IP \(bu 4
..
.TH YACC 1 "September 7, 2011" "Berkeley Yacc" "User Commands"
.SH NAME
Yacc \- an LALR(1) parser generator
@@ -26,7 +40,7 @@ normally writes the parse tables and the driver routine to the file
.IR y.tab.c.
.PP
The following options are available:
.TP
.TP 5
\fB\-b \fP\fIfile_prefix\fR
The
.B \-b
@@ -107,6 +121,31 @@ and the tables file is named
.IR y.tab.c.
The prefix "\fIy.\fP" can be overridden using the \fB\-b\fP option.
.TP
.B \-s
suppress "\fB#define\fP" statements generated for string literals in
a "\fB%token\fP" statement, to more closely match original \fByacc\fP behavior.
.IP
Normally when \fByacc\fP sees a line such as
.ES
%token OP_ADD "ADD"
.EE
.IP
it notices that the quoted "ADD" is a valid C identifier,
and generates a #define not only for OP_ADD,
but for ADD as well,
e.g.,
.ES
#define OP_ADD 257
.br
#define ADD 258
.EE
.IP
The original \fByacc\fP does not generate the second "\fB#define\fP".
The \fB\-s\fP option suppresses this "\fB#define\fP".
.IP
POSIX (IEEE 1003.1 2004) documents only names and numbers for "\fB%token\fP",
though original \fByacc\fP and bison also accept string literals.
.TP
.B \-t
The
.B \-t
@@ -123,6 +162,10 @@ be written to the file
.TP
.B \-V
print the version number to the standard output.
.TP
.B \-y
\fByacc\fP ignores this option,
which bison supports for ostensible POSIX compatibility.
.SH EXTENSIONS
.B yacc
provides some extensions for compatibility with bison and other implementations
@@ -142,13 +185,57 @@ By default, the lexer accepts no parameters, e.g., \fByylex()\fP.
Use this directive to add parameter declarations for your customized lexer.
.TP
\fB %parse-param\fP { \fIargument-declaration\fP }
By default, the parser accepts no parameters, e.g., \fByyparse()\fP.
By default, the parser accepts no parameters, e.g., \fByyparse()\fP.
Use this directive to add parameter declarations for your customized parser.
.TP
\fB %pure-parser\fP
Most variables (other than \fByydebug\fP and \fByynerrs\fP) are
allocated on the stack within \fByyparse\fP, making the parser reasonably
reentrant.
.SH PORTABILITY
According to Robert Corbett,
.ES
Berkeley Yacc is an LALR(1) parser generator. Berkeley Yacc has been made
as compatible as possible with AT&T Yacc. Berkeley Yacc can accept any input
specification that conforms to the AT&T Yacc documentation. Specifications
that take advantage of undocumented features of AT&T Yacc will probably be
rejected.
.EE
.PP
The rationale in
.ES
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/yacc.html
.EE
.PP
documents some features of AT&T yacc which are no longer required for POSIX
compliance.
.PP
That said, you may be interested in reusing grammary files with some
other implementation which is not strictly compatible with AT&T yacc.
For instance, there is bison.
Here are a few differences:
.bP
\fBYacc\fP accepts an equals mark preceding the left curly brace
of an action (as in the original grammar file \fBftp.y\fP):
.ES
| STAT CRLF
= {
statcmd();
}
.EE
.bP
\fBYacc\fP and bison emit code in different order, and in particular bison
makes forward reference to common functions such as yylex, yyparse and
yyerror without providing prototypes.
.bP
Bison's support for "%expect" is broken in more than one release.
For best results using bison, delete that directive.
.bP
Bison has no equivalent for some of \fByacc\fP's commmand-line options,
relying on directives embedded in the grammar file.
.bP
Bison's "\fB\-y\fP" option does not affect bison's lack of support for
features of AT&T yacc which were deemed obsolescent.
.
.SH DIAGNOSTICS
If there are rules that are never reduced, the number of such rules is

View File

@@ -1,10 +1,53 @@
/* config.h. Generated automatically by configure. */
/* @configure_input@ */
/* $Id: config.h,v 1.2 2011/09/10 21:32:25 christos Exp $ */
/* config_h.in. Generated automatically from configure.in by autoheader. */
#define SYSTEM_NAME "netbsd"
#define MIXEDCASE_FILENAMES 1
#define CC_HAS_PROTOS 1
/* Define to noreturn-attribute for gcc */
/* #undef GCC_NORETURN */
/* Define to 1 if the compiler supports gcc-like printf attribute. */
/* #undef GCC_PRINTF */
/* Define to printf-attribute for gcc */
/* #undef GCC_PRINTFLIKE */
/* Define to 1 if the compiler supports gcc-like scanf attribute. */
/* #undef GCC_SCANF */
/* Define to sscanf-attribute for gcc */
/* #undef GCC_SCANFLIKE */
/* Define to unused-attribute for gcc */
/* #undef GCC_UNUSED */
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
#define HAVE_ATEXIT 1
/* Define if you have the `dbmalloc' library (-ldbmalloc). */
/* #undef HAVE_LIBDBMALLOC */
/* Define if you have the `dmalloc' library (-ldmalloc). */
/* #undef HAVE_LIBDMALLOC */
/* Define to 1 if mkstemp() is available and working. */
#define HAVE_MKSTEMP 1
/* Define to 1 if filesystem supports mixed-case filenames. */
#define MIXEDCASE_FILENAMES 1
/* Define to 1 if you want to perform memory-leak testing. */
/* #undef NO_LEAKS */
/* Define to the system name. */
#define SYSTEM_NAME "minix"
/* "Define to 1 if you want to use dbmalloc for testing." */
/* #undef USE_DBMALLOC */
/* "Define to 1 if you want to use dmalloc for testing." */
/* #undef USE_DMALLOC */
/* "Define to 1 if you want to use valgrind for testing." */
/* #undef USE_VALGRIND */
/* Define to 1 if you want to perform memory-leak testing. */
/* #undef YY_NO_LEAKS */

View File

@@ -1,4 +1,4 @@
/* $NetBSD: bzip2.c,v 1.3 2012/05/07 00:45:47 wiz Exp $ */
/* $NetBSD: bzip2.c,v 1.4 2013/10/20 03:14:21 christos Exp $ */
/*-----------------------------------------------------------*/
@@ -557,7 +557,7 @@ static
Bool testStream ( FILE *zStream )
{
BZFILE* bzf = NULL;
Int32 bzerr, bzerr_dummy, ret, nread, streamNo, i;
Int32 bzerr, bzerr_dummy, ret, streamNo, i;
UChar obuf[5000];
UChar unused[BZ_MAX_UNUSED];
Int32 nUnused;
@@ -580,7 +580,7 @@ Bool testStream ( FILE *zStream )
streamNo++;
while (bzerr == BZ_OK) {
nread = BZ2_bzRead ( &bzerr, bzf, obuf, 5000 );
(void)BZ2_bzRead ( &bzerr, bzf, obuf, 5000 );
if (bzerr == BZ_DATA_ERROR_MAGIC) goto errhandler;
}
if (bzerr != BZ_STREAM_END) goto errhandler;

View File

@@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.1 2009/05/08 17:28:01 christos Exp $
# $NetBSD: Makefile,v 1.2 2013/03/23 16:15:57 christos Exp $
.include <bsd.own.mk>
.include <bsd.sys.mk>
@@ -20,6 +20,9 @@ CLEANFILES+= magic.mgc
realall: file magic.mgc
.endif
LIBMAGIC!= cd ${.CURDIR}/../lib && ${PRINTOBJDIR}
CPPFLAGS+=-I${LIBMAGIC}
.if ${MKSHARE} != "no"
magic.mgc: ${TOOL_MKMAGIC}
${_MKTARGET_CREATE}

View File

@@ -1,3 +1,80 @@
2013-03-06 21:24 Christos Zoulas <christos@zoulas.com>
* fix recursive magic separator printing
2013-02-26 19:28 Christos Zoulas <christos@zoulas.com>
* limit recursion level for mget
* fix pread() related breakage in cdf
* handle offsets properly in recursive "use"
2013-02-18 10:39 Christos Zoulas <christos@zoulas.com>
* add elf reading of debug info to determine if file is stripped
(Jan Kaluza)
* use pread()
2013-01-25 18:05 Christos Zoulas <christos@zoulas.com>
* change mime description size from 64 to 80 to accommodate OOXML.
2013-01-11 14:50 Christos Zoulas <christos@zoulas.com>
* Warn about inconsistent continuation levels.
* Change fsmagic to add a space after it prints.
2013-01-10 21:00 Christos Zoulas <christos@zoulas.com>
* Make getline public so that file can link against it.
Perhaps it is better to rename it, or hide it differently.
Fixes builds on platforms that do not provide it.
2013-01-07 16:30 Christos Zoulas <christos@zoulas.com>
* Add SuS d{,1,2,4,8}, u{,1,2,4,8} and document
what long, int, short, etc is (Guy Harris)
2013-01-06 11:20 Christos Zoulas <christos@zoulas.com>
* add magic_version function and constant
* Redo memory allocation and de-allocation.
(prevents double frees on non mmap platforms)
* Fix bug with name/use having to do with passing
found state from the parent to the child and back.
2012-12-19 8:47 Christos Zoulas <christos@zoulas.com>
* Only print elf capabilities for archs we know (Jan Kaluza)
2012-10-30 19:14 Christos Zoulas <christos@zoulas.com>
* Add "name" and "use" file types in order to look
inside mach-o files.
2012-09-06 10:40 Christos Zoulas <christos@zoulas.com>
* make --version exit 0 (Matthew Schultz)
* add string/T (Jan Kaluza)
2012-08-09 2:15 Christos Zoulas <christos@zoulas.com>
* add z and t modifiers for our own vasprintf
* search for $HOME/.magic.mgc if it is there first
* fix reads from a pipe, and preserve errno
2012-05-15 13:12 Christos Zoulas <christos@zoulas.com>
* use ctime_r, asctime_r
2012-04-06 17:18 Christos Zoulas <christos@zoulas.com>
* Fixes for indirect offsets to handle apple disk formats
2012-04-03 18:26 Christos Zoulas <christos@zoulas.com>
* Add windows date field types
* More info for windows shortcuts (incomplete)
2012-02-20 17:33 Christos Zoulas <christos@zoulas.com>
* Fix CDF parsing issues found by CERT's fuzzing tool (Will Dormann)

View File

@@ -1,9 +1,8 @@
# Makefile.in generated by automake 1.11 from Makefile.am.
# Makefile.in generated by automake 1.12.4 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
# Inc.
# Copyright (C) 1994-2012 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -15,6 +14,23 @@
@SET_MAKE@
VPATH = @srcdir@
am__make_dryrun = \
{ \
am__dry=no; \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \
| grep '^AM OK$$' >/dev/null || am__dry=yes;; \
*) \
for am__flg in $$MAKEFLAGS; do \
case $$am__flg in \
*=*|--*) ;; \
*n*) am__dry=yes; break;; \
esac; \
done;; \
esac; \
test $$am__dry = yes; \
}
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
@@ -51,12 +67,18 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo " GEN " $@;
AM_V_at = $(am__v_at_$(V))
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
@@ -66,21 +88,30 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
install-pdf-recursive install-ps-recursive install-recursive \
installcheck-recursive installdirs-recursive pdf-recursive \
ps-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
$(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
distdir dist dist-all distcheck
cscope distdir dist dist-all distcheck
ETAGS = etags
CTAGS = ctags
CSCOPE = cscope
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d "$(distdir)" \
|| { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr "$(distdir)"; }; }
if test -d "$(distdir)"; then \
find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -rf "$(distdir)" \
|| { sleep 5 && rm -rf "$(distdir)"; }; \
else :; fi
am__post_remove_distdir = $(am__remove_distdir)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
@@ -108,7 +139,10 @@ am__relativize = \
reldir="$$dir2"
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
DIST_TARGETS = dist-gzip
distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
pkgdatadir = @pkgdatadir@
ACLOCAL = @ACLOCAL@
@@ -122,6 +156,7 @@ AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CFLAG_VISIBILITY = @CFLAG_VISIBILITY@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
@@ -136,6 +171,7 @@ EGREP = @EGREP@
EXEEXT = @EXEEXT@
FGREP = @FGREP@
GREP = @GREP@
HAVE_VISIBILITY = @HAVE_VISIBILITY@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -234,21 +270,21 @@ all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive
.SUFFIXES:
am--refresh:
am--refresh: Makefile
@:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
$(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
$(AUTOMAKE) --foreign Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
@@ -270,10 +306,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
else :; fi
@if test ! -f $@; then rm -f stamp-h1; else :; fi
@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
@@ -296,13 +330,13 @@ distclean-libtool:
-rm -f libtool config.lt
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@failcom='exit 1'; \
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(RECURSIVE_TARGETS) $(RECURSIVE_CLEAN_TARGETS):
@fail= failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
@@ -311,7 +345,11 @@ $(RECURSIVE_TARGETS):
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
@@ -325,37 +363,6 @@ $(RECURSIVE_TARGETS):
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
$(RECURSIVE_CLEAN_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
@@ -364,6 +371,10 @@ ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
cscopelist-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) cscopelist); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
@@ -427,8 +438,32 @@ GTAGS:
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscope: cscope.files
test ! -s cscope.files \
|| $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
clean-cscope:
-rm -f cscope.files
cscope.files: clean-cscope cscopelist-recursive cscopelist
cscopelist: cscopelist-recursive $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS) $(LISP)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
distdir: $(DISTFILES)
$(am__remove_distdir)
@@ -464,13 +499,10 @@ distdir: $(DISTFILES)
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
@@ -491,43 +523,44 @@ distdir: $(DISTFILES)
fi; \
done
-test -n "$(am__skip_mode_fix)" \
|| find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
|| find "$(distdir)" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)"
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
$(am__post_remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
$(am__post_remove_distdir)
dist-lzma: distdir
tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
$(am__remove_distdir)
dist-lzip: distdir
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
$(am__post_remove_distdir)
dist-xz: distdir
tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
$(am__remove_distdir)
tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
$(am__post_remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
$(am__post_remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
$(am__post_remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
$(am__post_remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist dist-all:
$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
$(am__post_remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
@@ -535,23 +568,23 @@ dist dist-all: distdir
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lzma*) \
unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
*.tar.xz*) \
xz -dc $(distdir).tar.xz | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod -R a-w $(distdir)
chmod u+w $(distdir)
mkdir $(distdir)/_build $(distdir)/_inst
chmod a-w $(distdir)
test -d $(distdir)/_build || exit 0; \
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
@@ -559,6 +592,7 @@ distcheck: dist
&& am__cwd=`pwd` \
&& $(am__cd) $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(AM_DISTCHECK_CONFIGURE_FLAGS) \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
@@ -582,13 +616,21 @@ distcheck: dist
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
&& cd "$$am__cwd" \
|| exit 1
$(am__remove_distdir)
$(am__post_remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
distuninstallcheck:
@$(am__cd) '$(distuninstallcheck_dir)' \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
@test -n '$(distuninstallcheck_dir)' || { \
echo 'ERROR: trying to run $@ with an empty' \
'$$(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
$(am__cd) '$(distuninstallcheck_dir)' || { \
echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
exit 1; \
}; \
test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
@@ -619,10 +661,15 @@ install-am: all-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
@@ -705,13 +752,15 @@ ps-am:
uninstall-am:
.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
ctags-recursive install-am install-strip tags-recursive
cscopelist-recursive ctags-recursive install-am install-strip \
tags-recursive
.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
all all-am am--refresh check check-am clean clean-generic \
clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \
distcheck distclean distclean-generic distclean-hdr \
all all-am am--refresh check check-am clean clean-cscope \
clean-generic clean-libtool cscope cscopelist \
cscopelist-recursive ctags ctags-recursive dist dist-all \
dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ dist-xz \
dist-zip distcheck distclean distclean-generic distclean-hdr \
distclean-libtool distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-data install-data-am install-dvi \

View File

@@ -1,5 +1,5 @@
** README for file(1) Command **
@(#) $File: README,v 1.44 2011/03/24 13:03:39 rrt Exp $
@(#) $File: README,v 1.45 2013/01/11 16:51:01 christos Exp $
Mailing List: file@mx.gw.com
Bug tracker: http://bugs.gw.com/
@@ -68,15 +68,19 @@ src/apprentice.c - parses /etc/magic to learn magic
src/apptype.c - used for OS/2 specific application type magic
src/asprintf.c - replacement for OS's that don't have it.
src/ascmagic.c - third & last set of tests, based on hardwired assumptions.
src/asctime_r.c - for systems that don't have it.
src/asprintf.c - for systems that don't have it.
src/cdf.c - parser for Microsoft Compound Document Files
src/cdf_time.c - time converter for CDF.
src/compress.c - handles decompressing files to look inside.
src/ctime_r.c - for systems that don't have it.
src/encoding.c - handles unicode encodings
src/file.c - the main program
src/file.h - header file
src/fsmagic.c - first set of tests the program runs, based on filesystem info
src/funcs.c - utilility functions
src/getopt_long.c - used for OS/2 specific application type magic
src/getopt_long.c - for systems that don't have it.
src/getline.c - for systems that don't have it.
src/is_tar.c, tar.h - knows about tarchives (courtesy John Gilmore).
src/names.h - header file for ascmagic.c
src/magic.c - the libmagic api
@@ -84,14 +88,13 @@ src/print.c - print results, errors, warnings.
src/readcdf.c - CDF wrapper.
src/readelf.[ch] - Stand-alone elf parsing code.
src/softmagic.c - 2nd set of tests, based on /etc/magic
src/strlcat.c - used for OS/2 specific application type magic
src/strlcpy.c - used for OS/2 specific application type magic
src/vasprintf.c - used for OS/2 specific application type magic
doc/file.1 - man page for the command
doc/magic.4 - man page for the magic file, courtesy Guy Harris.
src/strlcat.c - for systems that don't have it.
src/strlcpy.c - for systems that don't have it.
src/vasprintf.c - for systems that don't have it.
doc/file.man - man page for the command
doc/magic.man - man page for the magic file, courtesy Guy Harris.
Install as magic.4 on USG and magic.5 on V7 or Berkeley; cf Makefile.
Magdir - directory of /etc/magic pieces
------------------------------------------------------------------------------
If you submit a new magic entry please make sure you read the following

View File

@@ -1,6 +1,16 @@
TODOs live in the TODO section of doc/file.man (i.e. file(1)). They
are more visible there, so please add any further TODOs to that file,
not here.
Most TODOs live in the TODO section of doc/file.man (i.e. file(1)).
They are more visible there, so please add any further TODOs to that
file, not here. More speculative material can live here.
(This change was made when Reuben Thomas noticed that all the bugs
listed in the BUGS section of the man page had been fixed!)
---
It would be nice to simplify file considerably. For example,
reimplement the apprentice and non-pattern magic methods in Python,
and compile the magic patterns to a giant regex (or something similar)
so that only a small amount of C is needed (because fast execution is
typically only required for soft magic, not the more detailed
information given by hard-wired routines). In this regard, note that
hplip, which is BSD-licensed, has a magic reimplementation in Python.

Some files were not shown because too many files have changed in this diff Show More