summaryrefslogtreecommitdiff
path: root/bc
diff options
context:
space:
mode:
Diffstat (limited to 'bc')
-rw-r--r--bc/Makefile.am36
-rw-r--r--bc/Makefile.in773
-rw-r--r--bc/bc.c3976
-rw-r--r--bc/bc.h174
-rw-r--r--bc/bc.y397
-rw-r--r--bc/bcdefs.h44
-rw-r--r--bc/const.h23
-rw-r--r--bc/execute.c135
-rw-r--r--bc/global.c24
-rw-r--r--bc/global.h38
-rw-r--r--bc/libmath.b85
-rw-r--r--bc/libmath.h40
-rw-r--r--bc/load.c80
-rw-r--r--bc/main.c128
-rw-r--r--bc/proto.h167
-rw-r--r--bc/sbc.y58
-rw-r--r--bc/scan.c2082
-rw-r--r--bc/scan.l72
-rw-r--r--bc/storage.c232
-rw-r--r--bc/util.c319
-rw-r--r--bc/warranty.c75
21 files changed, 5345 insertions, 3613 deletions
diff --git a/bc/Makefile.am b/bc/Makefile.am
index 9187339..d9d412e 100644
--- a/bc/Makefile.am
+++ b/bc/Makefile.am
@@ -1,42 +1,46 @@
## Process this file with automake to produce Makefile.in
bin_PROGRAMS = bc
-bc_SOURCES = main.c bc.y scan.l execute.c load.c storage.c util.c global.c
+bc_SOURCES = main.c bc.y scan.l execute.c load.c storage.c util.c global.c \
+ warranty.c
EXTRA_DIST = bc.h bcdefs.h const.h fix-libmath_h global.h libmath.b proto.h \
sbc.y
noinst_HEADERS = libmath.h
-DISTCLEANFILES = sbc sbc.c sbc.h
+DISTCLEANFILES = sbc sbc.c sbc.h libmath.h
-MAINTAINERCLEANFILES = Makefile.in libmath.h bc.c bc.h scan.c
+MAINTAINERCLEANFILES = Makefile.in bc.c bc.h scan.c \
+ bc.y bcdefs.h const.h execute.c fix-libmath_h \
+ global.c global.h libmath.b load.c main.c \
+ proto.h scan.l storage.c util.c
-INCLUDES = -I$(srcdir) -I$(srcdir)/../h
+AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../h
LIBBC = ../lib/libbc.a
LIBL = @LEXLIB@
LDADD = $(LIBBC) $(LIBL) @READLINELIB@
-YFLAGS = -d
+AM_YFLAGS = -d
-CFLAGS = @CFLAGS@ -Wall -funsigned-char
+AM_CFLAGS = @CFLAGS@
-$(PROGRAMS): $(LIBBC)
+$(PROGRAMS): libmath.h $(LIBBC)
scan.o: bc.h
global.o: libmath.h
-libmath.h: libmath.b
+fbcOBJ = main.o bc.o scan.o execute.o load.o storage.o util.o warranty.o
+
+libmath.h: libmath.b $(fbcOBJ) $(LIBBC)
echo '{0}' > libmath.h
- $(MAKE) fbc
+ $(MAKE) global.o
+ $(LINK) -o fbc $(fbcOBJ) global.o $(LIBBC) $(LIBL) $(READLINELIB) $(LIBS)
./fbc -c $(srcdir)/libmath.b </dev/null >libmath.h
$(srcdir)/fix-libmath_h
- rm -f ./fbc
-
-fbcOBJ = main.o bc.o scan.o execute.o global.o load.o storage.o util.o
-fbc: $(fbcOBJ)
- $(LINK) $(fbcOBJ) $(LIBBC) $(LIBL) $(READLINELIB) $(LIBS)
+ rm -f ./fbc ./global.o
-sbcOBJ = main.o sbc.o scan.o execute.o global.o load.o storage.o util.o
+sbcOBJ = main.o sbc.o scan.o execute.o global.o load.o storage.o util.o \
+ warranty.o
sbc.o: sbc.c
-sbc: $(sbcOBJ)
+sbc: $(sbcOBJ) $(LIBBC)
$(LINK) $(sbcOBJ) $(LIBBC) $(LIBL) $(READLINELIB) $(LIBS)
diff --git a/bc/Makefile.in b/bc/Makefile.in
index 18ebce0..74332f5 100644
--- a/bc/Makefile.in
+++ b/bc/Makefile.in
@@ -1,6 +1,8 @@
-# Makefile.in generated automatically by automake 1.4 from Makefile.am
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
-# Copyright (C) 1994, 1995-8, 1999 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.
@@ -10,334 +12,627 @@
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
+@SET_MAKE@
-SHELL = @SHELL@
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
VPATH = @srcdir@
-prefix = @prefix@
-exec_prefix = @exec_prefix@
-
-bindir = @bindir@
-sbindir = @sbindir@
-libexecdir = @libexecdir@
-datadir = @datadir@
-sysconfdir = @sysconfdir@
-sharedstatedir = @sharedstatedir@
-localstatedir = @localstatedir@
-libdir = @libdir@
-infodir = @infodir@
-mandir = @mandir@
-includedir = @includedir@
-oldincludedir = /usr/include
-
-DESTDIR =
-
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
-pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
-
-top_builddir = ..
-
-ACLOCAL = @ACLOCAL@
-AUTOCONF = @AUTOCONF@
-AUTOMAKE = @AUTOMAKE@
-AUTOHEADER = @AUTOHEADER@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-transform = @program_transform_name@
-
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
+bin_PROGRAMS = bc$(EXEEXT)
+subdir = bc
+DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am bc.h bc.c \
+ scan.c $(top_srcdir)/depcomp $(top_srcdir)/ylwrap \
+ $(noinst_HEADERS)
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS)
+am_bc_OBJECTS = main.$(OBJEXT) bc.$(OBJEXT) scan.$(OBJEXT) \
+ execute.$(OBJEXT) load.$(OBJEXT) storage.$(OBJEXT) \
+ util.$(OBJEXT) global.$(OBJEXT) warranty.$(OBJEXT)
+bc_OBJECTS = $(am_bc_OBJECTS)
+bc_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+bc_DEPENDENCIES = $(LIBBC) $(am__DEPENDENCIES_1)
+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 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+LEXCOMPILE = $(LEX) $(AM_LFLAGS) $(LFLAGS)
+AM_V_LEX = $(am__v_LEX_@AM_V@)
+am__v_LEX_ = $(am__v_LEX_@AM_DEFAULT_V@)
+am__v_LEX_0 = @echo " LEX " $@;
+am__v_LEX_1 =
+YLWRAP = $(top_srcdir)/ylwrap
+am__yacc_c2h = sed -e s/cc$$/hh/ -e s/cpp$$/hpp/ -e s/cxx$$/hxx/ \
+ -e s/c++$$/h++/ -e s/c$$/h/
+YACCCOMPILE = $(YACC) $(AM_YFLAGS) $(YFLAGS)
+AM_V_YACC = $(am__v_YACC_@AM_V@)
+am__v_YACC_ = $(am__v_YACC_@AM_DEFAULT_V@)
+am__v_YACC_0 = @echo " YACC " $@;
+am__v_YACC_1 =
+SOURCES = $(bc_SOURCES)
+DIST_SOURCES = $(bc_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+HEADERS = $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BC_VERSION = @BC_VERSION@
CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC_VERSION = @DC_VERSION@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
READLINELIB = @READLINELIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
VERSION = @VERSION@
YACC = @YACC@
+YFLAGS = @YFLAGS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build_alias = @build_alias@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+bc_SOURCES = main.c bc.y scan.l execute.c load.c storage.c util.c global.c \
+ warranty.c
-bin_PROGRAMS = bc
-
-bc_SOURCES = main.c bc.y scan.l execute.c load.c storage.c util.c global.c
-
-EXTRA_DIST = bc.h bcdefs.h const.h fix-libmath_h global.h libmath.b proto.h sbc.y
+EXTRA_DIST = bc.h bcdefs.h const.h fix-libmath_h global.h libmath.b proto.h \
+ sbc.y
noinst_HEADERS = libmath.h
+DISTCLEANFILES = sbc sbc.c sbc.h libmath.h
+MAINTAINERCLEANFILES = Makefile.in bc.c bc.h scan.c \
+ bc.y bcdefs.h const.h execute.c fix-libmath_h \
+ global.c global.h libmath.b load.c main.c \
+ proto.h scan.l storage.c util.c
-DISTCLEANFILES = sbc sbc.c sbc.h
-
-MAINTAINERCLEANFILES = Makefile.in libmath.h bc.c bc.h scan.c
-
-INCLUDES = -I$(srcdir) -I$(srcdir)/../h
+AM_CPPFLAGS = -I$(srcdir) -I$(srcdir)/../h
LIBBC = ../lib/libbc.a
LIBL = @LEXLIB@
LDADD = $(LIBBC) $(LIBL) @READLINELIB@
+AM_YFLAGS = -d
+AM_CFLAGS = @CFLAGS@
+fbcOBJ = main.o bc.o scan.o execute.o load.o storage.o util.o warranty.o
+sbcOBJ = main.o sbc.o scan.o execute.o global.o load.o storage.o util.o \
+ warranty.o
-YFLAGS = -d
+all: all-am
-CFLAGS = @CFLAGS@ -Wall -funsigned-char
-
-fbcOBJ = main.o bc.o scan.o execute.o global.o load.o storage.o util.o
-
-sbcOBJ = main.o sbc.o scan.o execute.o global.o load.o storage.o util.o
-mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
-CONFIG_HEADER = ../config.h
-CONFIG_CLEAN_FILES =
-PROGRAMS = $(bin_PROGRAMS)
-
-
-DEFS = @DEFS@ -I. -I$(srcdir) -I..
-CPPFLAGS = @CPPFLAGS@
-LDFLAGS = @LDFLAGS@
-LIBS = @LIBS@
-bc_OBJECTS = main.o bc.o scan.o execute.o load.o storage.o util.o \
-global.o
-bc_LDADD = $(LDADD)
-bc_DEPENDENCIES = ../lib/libbc.a
-bc_LDFLAGS =
-LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
-LEXLIB = @LEXLIB@
-COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
-HEADERS = $(noinst_HEADERS)
-
-DIST_COMMON = Makefile.am Makefile.in bc.c scan.c
-
-
-DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
-
-TAR = tar
-GZIP_ENV = --best
-SOURCES = $(bc_SOURCES)
-OBJECTS = $(bc_OBJECTS)
-
-all: all-redirect
.SUFFIXES:
-.SUFFIXES: .S .c .l .o .s .y
-$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
- cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps bc/Makefile
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- cd $(top_builddir) \
- && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-
-mostlyclean-binPROGRAMS:
-
-clean-binPROGRAMS:
- -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
-
-distclean-binPROGRAMS:
-
-maintainer-clean-binPROGRAMS:
-
+.SUFFIXES: .c .l .o .obj .y
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu bc/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu bc/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
- $(mkinstalldirs) $(DESTDIR)$(bindir)
- @list='$(bin_PROGRAMS)'; for p in $$list; do \
- if test -f $$p; then \
- echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \
- $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
- else :; fi; \
- done
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+ fi; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p \
+ ; then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' \
+ -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
- list='$(bin_PROGRAMS)'; for p in $$list; do \
- rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \
- done
-
-.c.o:
- $(COMPILE) -c $<
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' \
+ `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
-.s.o:
- $(COMPILE) -c $<
+clean-binPROGRAMS:
+ -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+bc.h: bc.c
+ @if test ! -f $@; then rm -f bc.c; else :; fi
+ @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) bc.c; else :; fi
-.S.o:
- $(COMPILE) -c $<
+bc$(EXEEXT): $(bc_OBJECTS) $(bc_DEPENDENCIES) $(EXTRA_bc_DEPENDENCIES)
+ @rm -f bc$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(bc_OBJECTS) $(bc_LDADD) $(LIBS)
mostlyclean-compile:
- -rm -f *.o core *.core
-
-clean-compile:
+ -rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
-maintainer-clean-compile:
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bc.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/execute.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/global.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/load.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scan.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/storage.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/warranty.Po@am__quote@
-bc: $(bc_OBJECTS) $(bc_DEPENDENCIES)
- @rm -f bc
- $(LINK) $(bc_LDFLAGS) $(bc_OBJECTS) $(bc_LDADD) $(LIBS)
-.l.c:
- $(LEX) $(AM_LFLAGS) $(LFLAGS) $< && mv $(LEX_OUTPUT_ROOT).c $@
-.y.c:
- $(YACC) $(AM_YFLAGS) $(YFLAGS) $< && mv y.tab.c $*.c
- if test -f y.tab.h; then \
- if cmp -s y.tab.h $*.h; then rm -f y.tab.h; else mv y.tab.h $*.h; fi; \
- else :; fi
-bc.h: bc.c
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+.l.c:
+ $(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE)
-tags: TAGS
+.y.c:
+ $(AM_V_YACC)$(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h `echo $@ | $(am__yacc_c2h)` y.output $*.output -- $(YACCCOMPILE)
-ID: $(HEADERS) $(SOURCES) $(LISP)
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- here=`pwd` && cd $(srcdir) \
- && mkid -f$$here/ID $$unique $(LISP)
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
-TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
- tags=; \
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
here=`pwd`; \
- list='$(SOURCES) $(HEADERS)'; \
- unique=`for i in $$list; do echo $$i; done | \
- awk ' { files[$$0] = 1; } \
- END { for (i in files) print i; }'`; \
- test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
- || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
-
-mostlyclean-tags:
-
-clean-tags:
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ 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
-
-maintainer-clean-tags:
-
-distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
-
-subdir = bc
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
- @for file in $(DISTFILES); do \
- d=$(srcdir); \
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
- cp -pr $$/$$file $(distdir)/$$file; \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
- test -f $(distdir)/$$file \
- || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
- || cp -p $$d/$$file $(distdir)/$$file || :; \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
fi; \
done
-bc.o: bc.c bcdefs.h ../config.h const.h ../h/number.h global.h proto.h
-execute.o: execute.c bcdefs.h ../config.h const.h ../h/number.h global.h \
- proto.h
-global.o: global.c bcdefs.h ../config.h const.h ../h/number.h global.h \
- libmath.h
-load.o: load.c bcdefs.h ../config.h const.h ../h/number.h global.h \
- proto.h
-main.o: main.c bcdefs.h ../config.h const.h ../h/number.h global.h \
- proto.h ../h/getopt.h
-scan.o: scan.c bcdefs.h ../config.h const.h ../h/number.h bc.h global.h \
- proto.h
-storage.o: storage.c bcdefs.h ../config.h const.h ../h/number.h global.h \
- proto.h
-util.o: util.c bcdefs.h ../config.h const.h ../h/number.h global.h \
- proto.h
-
-info-am:
-info: info-am
-dvi-am:
-dvi: dvi-am
check-am: all-am
check: check-am
-installcheck-am:
-installcheck: installcheck-am
-install-exec-am: install-binPROGRAMS
+all-am: Makefile $(PROGRAMS) $(HEADERS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
install-exec: install-exec-am
-
-install-data-am:
install-data: install-data-am
+uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-install: install-am
-uninstall-am: uninstall-binPROGRAMS
-uninstall: uninstall-am
-all-am: Makefile $(PROGRAMS) $(HEADERS)
-all-redirect: all-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
-installdirs:
- $(mkinstalldirs) $(DESTDIR)$(bindir)
-
+installcheck: installcheck-am
+install-strip:
+ 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:
distclean-generic:
- -rm -f Makefile $(CONFIG_CLEAN_FILES)
- -rm -f config.cache config.log stamp-h stamp-h[0-9]*
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
maintainer-clean-generic:
- -test -z "scanlbchbcc$(MAINTAINERCLEANFILES)" || rm -f scanl bch bcc $(MAINTAINERCLEANFILES)
-mostlyclean-am: mostlyclean-binPROGRAMS mostlyclean-compile \
- mostlyclean-tags mostlyclean-generic
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -rm -f bc.c
+ -rm -f bc.h
+ -rm -f scan.c
+ -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
-mostlyclean: mostlyclean-am
+clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
-clean-am: clean-binPROGRAMS clean-compile clean-tags clean-generic \
- mostlyclean-am
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
-clean: clean-am
+dvi: dvi-am
-distclean-am: distclean-binPROGRAMS distclean-compile distclean-tags \
- distclean-generic clean-am
+dvi-am:
-distclean: distclean-am
+html: html-am
-maintainer-clean-am: maintainer-clean-binPROGRAMS \
- maintainer-clean-compile maintainer-clean-tags \
- maintainer-clean-generic distclean-am
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may require special tools to rebuild."
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-strip
-.PHONY: mostlyclean-binPROGRAMS distclean-binPROGRAMS clean-binPROGRAMS \
-maintainer-clean-binPROGRAMS uninstall-binPROGRAMS install-binPROGRAMS \
-mostlyclean-compile distclean-compile clean-compile \
-maintainer-clean-compile tags mostlyclean-tags distclean-tags \
-clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
-check-am installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
+ clean-binPROGRAMS clean-generic cscopelist-am ctags ctags-am \
+ distclean distclean-compile distclean-generic distclean-tags \
+ distdir dvi dvi-am html html-am info info-am install \
+ install-am install-binPROGRAMS install-data install-data-am \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
+ install-man install-pdf install-pdf-am install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
+ ps ps-am tags tags-am uninstall uninstall-am \
+ uninstall-binPROGRAMS
-$(PROGRAMS): $(LIBBC)
+$(PROGRAMS): libmath.h $(LIBBC)
scan.o: bc.h
global.o: libmath.h
-libmath.h: libmath.b
+libmath.h: libmath.b $(fbcOBJ) $(LIBBC)
echo '{0}' > libmath.h
- $(MAKE) fbc
+ $(MAKE) global.o
+ $(LINK) -o fbc $(fbcOBJ) global.o $(LIBBC) $(LIBL) $(READLINELIB) $(LIBS)
./fbc -c $(srcdir)/libmath.b </dev/null >libmath.h
$(srcdir)/fix-libmath_h
- rm -f ./fbc
-fbc: $(fbcOBJ)
- $(LINK) $(fbcOBJ) $(LIBBC) $(LIBL) $(READLINELIB) $(LIBS)
+ rm -f ./fbc ./global.o
sbc.o: sbc.c
-sbc: $(sbcOBJ)
+sbc: $(sbcOBJ) $(LIBBC)
$(LINK) $(sbcOBJ) $(LIBBC) $(LIBL) $(READLINELIB) $(LIBS)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
diff --git a/bc/bc.c b/bc/bc.c
index 6750bb6..d2bb848 100644
--- a/bc/bc.c
+++ b/bc/bc.c
@@ -1,1431 +1,2185 @@
+/* A Bison parser, made by GNU Bison 3.0.2. */
-/* A Bison parser, made from bc.y
- by GNU Bison version 1.27
- */
+/* Bison implementation for Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+
+ This program 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+/* C LALR(1) parser skeleton written by Richard Stallman, by
+ simplifying the original so-called "semantic" parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Bison version. */
+#define YYBISON_VERSION "3.0.2"
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 0
+
+/* Push parsers. */
+#define YYPUSH 0
+
+/* Pull parsers. */
+#define YYPULL 1
+
+
+
+
+/* Copy the first part of user declarations. */
+#line 31 "../../bc/bc.y" /* yacc.c:339 */
-#define YYBISON 1 /* Identify Bison output. */
-
-#define ENDOFLINE 257
-#define AND 258
-#define OR 259
-#define NOT 260
-#define STRING 261
-#define NAME 262
-#define NUMBER 263
-#define ASSIGN_OP 264
-#define REL_OP 265
-#define INCR_DECR 266
-#define Define 267
-#define Break 268
-#define Quit 269
-#define Length 270
-#define Return 271
-#define For 272
-#define If 273
-#define While 274
-#define Sqrt 275
-#define Else 276
-#define Scale 277
-#define Ibase 278
-#define Obase 279
-#define Auto 280
-#define Read 281
-#define Warranty 282
-#define Halt 283
-#define Last 284
-#define Continue 285
-#define Print 286
-#define Limits 287
-#define UNARY_MINUS 288
-#define HistoryVar 289
-
-#line 1 "bc.y"
-
-/* bc.y: The grammar for a POSIX compatable bc processor with some
- extensions to the language. */
-
-/* This file is part of GNU bc.
- Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
-
- This program 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
- (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.
-
- You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to:
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
-
- You may contact the author by:
- e-mail: philnelson@acm.org
- us-mail: Philip A. Nelson
- Computer Science Department, 9062
- Western Washington University
- Bellingham, WA 98226-9062
-
-*************************************************************************/
#include "bcdefs.h"
#include "global.h"
#include "proto.h"
-#line 40 "bc.y"
-typedef union {
+/* current function number. */
+int cur_func = -1;
+
+/* Expression encoded information -- See comment at expression rules. */
+#define EX_ASSGN 0
+#define EX_REG 1
+#define EX_COMP 2
+#define EX_PAREN 4
+#define EX_VOID 8
+#define EX_EMPTY 16
+
+
+#line 85 "bc.c" /* yacc.c:339 */
+
+# ifndef YY_NULLPTR
+# if defined __cplusplus && 201103L <= __cplusplus
+# define YY_NULLPTR nullptr
+# else
+# define YY_NULLPTR 0
+# endif
+# endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+/* In a future release of Bison, this section will be replaced
+ by #include "y.tab.h". */
+#ifndef YY_YY_BC_H_INCLUDED
+# define YY_YY_BC_H_INCLUDED
+/* Debug traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+#if YYDEBUG
+extern int yydebug;
+#endif
+
+/* Token type. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ enum yytokentype
+ {
+ ENDOFLINE = 258,
+ AND = 259,
+ OR = 260,
+ NOT = 261,
+ STRING = 262,
+ NAME = 263,
+ NUMBER = 264,
+ ASSIGN_OP = 265,
+ REL_OP = 266,
+ INCR_DECR = 267,
+ Define = 268,
+ Break = 269,
+ Quit = 270,
+ Length = 271,
+ Return = 272,
+ For = 273,
+ If = 274,
+ While = 275,
+ Sqrt = 276,
+ Else = 277,
+ Scale = 278,
+ Ibase = 279,
+ Obase = 280,
+ Auto = 281,
+ Read = 282,
+ Random = 283,
+ Warranty = 284,
+ Halt = 285,
+ Last = 286,
+ Continue = 287,
+ Print = 288,
+ Limits = 289,
+ UNARY_MINUS = 290,
+ HistoryVar = 291,
+ Void = 292
+ };
+#endif
+/* Tokens. */
+#define ENDOFLINE 258
+#define AND 259
+#define OR 260
+#define NOT 261
+#define STRING 262
+#define NAME 263
+#define NUMBER 264
+#define ASSIGN_OP 265
+#define REL_OP 266
+#define INCR_DECR 267
+#define Define 268
+#define Break 269
+#define Quit 270
+#define Length 271
+#define Return 272
+#define For 273
+#define If 274
+#define While 275
+#define Sqrt 276
+#define Else 277
+#define Scale 278
+#define Ibase 279
+#define Obase 280
+#define Auto 281
+#define Read 282
+#define Random 283
+#define Warranty 284
+#define Halt 285
+#define Last 286
+#define Continue 287
+#define Print 288
+#define Limits 289
+#define UNARY_MINUS 290
+#define HistoryVar 291
+#define Void 292
+
+/* Value type. */
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE YYSTYPE;
+union YYSTYPE
+{
+#line 52 "../../bc/bc.y" /* yacc.c:355 */
+
char *s_value;
char c_value;
int i_value;
arg_list *a_value;
- } YYSTYPE;
-#include <stdio.h>
+
+
+#line 207 "bc.c" /* yacc.c:355 */
+};
+# define YYSTYPE_IS_TRIVIAL 1
+# define YYSTYPE_IS_DECLARED 1
+#endif
+
+
+extern YYSTYPE yylval;
+
+int yyparse (void);
+
+#endif /* !YY_YY_BC_H_INCLUDED */
+
+/* Copy the second part of user declarations. */
+
+#line 222 "bc.c" /* yacc.c:358 */
+
+#ifdef short
+# undef short
+#endif
-#ifndef __cplusplus
-#ifndef __STDC__
-#define const
+#ifdef YYTYPE_UINT8
+typedef YYTYPE_UINT8 yytype_uint8;
+#else
+typedef unsigned char yytype_uint8;
#endif
+
+#ifdef YYTYPE_INT8
+typedef YYTYPE_INT8 yytype_int8;
+#else
+typedef signed char yytype_int8;
#endif
+#ifdef YYTYPE_UINT16
+typedef YYTYPE_UINT16 yytype_uint16;
+#else
+typedef unsigned short int yytype_uint16;
+#endif
+#ifdef YYTYPE_INT16
+typedef YYTYPE_INT16 yytype_int16;
+#else
+typedef short int yytype_int16;
+#endif
-#define YYFINAL 185
-#define YYFLAG -32768
-#define YYNTBASE 50
-
-#define YYTRANSLATE(x) ((unsigned)(x) <= 289 ? yytranslate[x] : 84)
-
-static const char yytranslate[] = { 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 40, 2, 2, 43,
- 44, 38, 36, 47, 37, 2, 39, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 42, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 48, 2, 49, 41, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 45, 2, 46, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
- 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
- 27, 28, 29, 30, 31, 32, 33, 34, 35
-};
+#ifndef YYSIZE_T
+# ifdef __SIZE_TYPE__
+# define YYSIZE_T __SIZE_TYPE__
+# elif defined size_t
+# define YYSIZE_T size_t
+# elif ! defined YYSIZE_T
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# else
+# define YYSIZE_T unsigned int
+# endif
+#endif
-#if YYDEBUG != 0
-static const short yyprhs[] = { 0,
- 0, 1, 4, 7, 9, 12, 13, 15, 16, 18,
- 22, 25, 26, 28, 31, 35, 38, 42, 44, 47,
- 49, 51, 53, 55, 57, 59, 61, 63, 66, 67,
- 68, 69, 70, 85, 86, 95, 96, 97, 106, 110,
- 111, 115, 117, 121, 123, 125, 126, 127, 132, 133,
- 146, 147, 149, 150, 154, 158, 160, 164, 169, 173,
- 179, 186, 187, 189, 191, 195, 199, 205, 206, 208,
- 209, 211, 212, 217, 218, 223, 224, 229, 232, 236,
- 240, 244, 248, 252, 256, 260, 263, 265, 267, 271,
- 276, 279, 282, 287, 292, 297, 301, 303, 308, 310,
- 312, 314, 316, 318, 319, 321
-};
+#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
+
+#ifndef YY_
+# if defined YYENABLE_NLS && YYENABLE_NLS
+# if ENABLE_NLS
+# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
+# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
+# endif
+# endif
+# ifndef YY_
+# define YY_(Msgid) Msgid
+# endif
+#endif
-static const short yyrhs[] = { -1,
- 50, 51, 0, 53, 3, 0, 69, 0, 1, 3,
- 0, 0, 3, 0, 0, 55, 0, 53, 42, 55,
- 0, 53, 42, 0, 0, 55, 0, 54, 3, 0,
- 54, 3, 55, 0, 54, 42, 0, 54, 42, 56,
- 0, 56, 0, 1, 56, 0, 28, 0, 33, 0,
- 78, 0, 7, 0, 14, 0, 31, 0, 15, 0,
- 29, 0, 17, 77, 0, 0, 0, 0, 0, 18,
- 57, 43, 76, 42, 58, 76, 42, 59, 76, 44,
- 60, 52, 56, 0, 0, 19, 43, 78, 44, 61,
- 52, 56, 67, 0, 0, 0, 20, 62, 43, 78,
- 63, 44, 52, 56, 0, 45, 54, 46, 0, 0,
- 32, 64, 65, 0, 66, 0, 66, 47, 65, 0,
- 7, 0, 78, 0, 0, 0, 22, 68, 52, 56,
- 0, 0, 13, 8, 43, 71, 44, 52, 45, 83,
- 72, 70, 54, 46, 0, 0, 73, 0, 0, 26,
- 73, 3, 0, 26, 73, 42, 0, 8, 0, 8,
- 48, 49, 0, 38, 8, 48, 49, 0, 73, 47,
- 8, 0, 73, 47, 8, 48, 49, 0, 73, 47,
- 38, 8, 48, 49, 0, 0, 75, 0, 78, 0,
- 8, 48, 49, 0, 75, 47, 78, 0, 75, 47,
- 8, 48, 49, 0, 0, 78, 0, 0, 78, 0,
- 0, 82, 10, 79, 78, 0, 0, 78, 4, 80,
- 78, 0, 0, 78, 5, 81, 78, 0, 6, 78,
- 0, 78, 11, 78, 0, 78, 36, 78, 0, 78,
- 37, 78, 0, 78, 38, 78, 0, 78, 39, 78,
- 0, 78, 40, 78, 0, 78, 41, 78, 0, 37,
- 78, 0, 82, 0, 9, 0, 43, 78, 44, 0,
- 8, 43, 74, 44, 0, 12, 82, 0, 82, 12,
- 0, 16, 43, 78, 44, 0, 21, 43, 78, 44,
- 0, 23, 43, 78, 44, 0, 27, 43, 44, 0,
- 8, 0, 8, 48, 78, 49, 0, 24, 0, 25,
- 0, 23, 0, 35, 0, 30, 0, 0, 3, 0,
- 83, 3, 0
-};
+#ifndef YY_ATTRIBUTE
+# if (defined __GNUC__ \
+ && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
+ || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
+# define YY_ATTRIBUTE(Spec) __attribute__(Spec)
+# else
+# define YY_ATTRIBUTE(Spec) /* empty */
+# endif
+#endif
+#ifndef YY_ATTRIBUTE_PURE
+# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
#endif
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
- 107, 116, 118, 120, 122, 128, 129, 132, 134, 135,
- 136, 138, 140, 141, 142, 143, 144, 146, 147, 150,
- 152, 154, 163, 170, 180, 191, 193, 195, 197, 202,
- 212, 223, 233, 241, 248, 254, 260, 267, 273, 275,
- 278, 279, 280, 282, 288, 291, 292, 300, 301, 315,
- 321, 323, 325, 327, 329, 332, 334, 336, 338, 340,
- 342, 345, 347, 349, 354, 360, 365, 381, 386, 388,
- 393, 401, 413, 428, 436, 441, 449, 457, 463, 491,
- 496, 501, 506, 511, 516, 521, 526, 535, 551, 553,
- 569, 588, 611, 613, 615, 617, 623, 625, 630, 632,
- 634, 636, 640, 647, 648, 649
+#ifndef YY_ATTRIBUTE_UNUSED
+# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
+#endif
+
+#if !defined _Noreturn \
+ && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
+# if defined _MSC_VER && 1200 <= _MSC_VER
+# define _Noreturn __declspec (noreturn)
+# else
+# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
+# endif
+#endif
+
+/* Suppress unused-variable warnings by "using" E. */
+#if ! defined lint || defined __GNUC__
+# define YYUSE(E) ((void) (E))
+#else
+# define YYUSE(E) /* empty */
+#endif
+
+#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+/* Suppress an incorrect diagnostic about yylval being uninitialized. */
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+ _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+ _Pragma ("GCC diagnostic pop")
+#else
+# define YY_INITIAL_VALUE(Value) Value
+#endif
+#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END
+#endif
+#ifndef YY_INITIAL_VALUE
+# define YY_INITIAL_VALUE(Value) /* Nothing. */
+#endif
+
+
+#if ! defined yyoverflow || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# ifdef YYSTACK_USE_ALLOCA
+# if YYSTACK_USE_ALLOCA
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# elif defined __BUILTIN_VA_ARG_INCR
+# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
+# elif defined _AIX
+# define YYSTACK_ALLOC __alloca
+# elif defined _MSC_VER
+# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
+# define alloca _alloca
+# else
+# define YYSTACK_ALLOC alloca
+# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+ /* Use EXIT_SUCCESS as a witness for stdlib.h. */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's 'empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
+# ifndef YYSTACK_ALLOC_MAXIMUM
+ /* The OS might guarantee only one guard page at the bottom of the stack,
+ and a page size can be as small as 4096 bytes. So we cannot safely
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
+ to allow for a few compiler-allocated temporary stack slots. */
+# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
+# endif
+# else
+# define YYSTACK_ALLOC YYMALLOC
+# define YYSTACK_FREE YYFREE
+# ifndef YYSTACK_ALLOC_MAXIMUM
+# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
+# endif
+# if (defined __cplusplus && ! defined EXIT_SUCCESS \
+ && ! ((defined YYMALLOC || defined malloc) \
+ && (defined YYFREE || defined free)))
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# ifndef EXIT_SUCCESS
+# define EXIT_SUCCESS 0
+# endif
+# endif
+# ifndef YYMALLOC
+# define YYMALLOC malloc
+# if ! defined malloc && ! defined EXIT_SUCCESS
+void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# ifndef YYFREE
+# define YYFREE free
+# if ! defined free && ! defined EXIT_SUCCESS
+void free (void *); /* INFRINGES ON USER NAME SPACE */
+# endif
+# endif
+# endif
+#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
+
+
+#if (! defined yyoverflow \
+ && (! defined __cplusplus \
+ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ yytype_int16 yyss_alloc;
+ YYSTYPE yyvs_alloc;
};
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+# define YYCOPY_NEEDED 1
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
+ Stack = &yyptr->Stack_alloc; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (0)
+
#endif
+#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
+/* Copy COUNT objects from SRC to DST. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if defined __GNUC__ && 1 < __GNUC__
+# define YYCOPY(Dst, Src, Count) \
+ __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
+# else
+# define YYCOPY(Dst, Src, Count) \
+ do \
+ { \
+ YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (Dst)[yyi] = (Src)[yyi]; \
+ } \
+ while (0)
+# endif
+# endif
+#endif /* !YYCOPY_NEEDED */
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 2
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 719
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 53
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 36
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 112
+/* YYNSTATES -- Number of states. */
+#define YYNSTATES 198
+
+/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
+ by yylex, with out-of-bounds checking. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 292
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
+ as returned by yylex, without out-of-bounds checking. */
+static const yytype_uint8 yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 42, 52, 2,
+ 45, 46, 40, 38, 49, 39, 2, 41, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 44,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 50, 2, 51, 43, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 47, 2, 48, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 36, 37
+};
-#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
+#if YYDEBUG
+ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
+static const yytype_uint16 yyrline[] =
+{
+ 0, 123, 123, 131, 133, 135, 137, 143, 144, 148,
+ 149, 150, 151, 154, 155, 156, 157, 158, 159, 161,
+ 162, 165, 167, 169, 178, 185, 196, 208, 210, 212,
+ 215, 220, 232, 247, 214, 267, 266, 282, 290, 281,
+ 306, 309, 308, 312, 313, 315, 321, 328, 330, 329,
+ 342, 340, 367, 368, 375, 376, 379, 380, 382, 385,
+ 387, 389, 393, 397, 399, 401, 405, 411, 412, 414,
+ 422, 429, 437, 456, 460, 463, 469, 484, 483, 513,
+ 512, 528, 527, 545, 553, 584, 591, 598, 605, 612,
+ 619, 626, 633, 642, 658, 664, 684, 703, 726, 733,
+ 740, 747, 753, 760, 762, 770, 772, 774, 776, 780,
+ 787, 788, 789
+};
+#endif
-static const char * const yytname[] = { "$","error","$undefined.","ENDOFLINE",
-"AND","OR","NOT","STRING","NAME","NUMBER","ASSIGN_OP","REL_OP","INCR_DECR","Define",
-"Break","Quit","Length","Return","For","If","While","Sqrt","Else","Scale","Ibase",
-"Obase","Auto","Read","Warranty","Halt","Last","Continue","Print","Limits","UNARY_MINUS",
-"HistoryVar","'+'","'-'","'*'","'/'","'%'","'^'","';'","'('","')'","'{'","'}'",
-"','","'['","']'","program","input_item","opt_newline","semicolon_list","statement_list",
-"statement_or_error","statement","@1","@2","@3","@4","@5","@6","@7","@8","print_list",
-"print_element","opt_else","@9","function","@10","opt_parameter_list","opt_auto_define_list",
-"define_list","opt_argument_list","argument_list","opt_expression","return_expression",
-"expression","@11","@12","@13","named_expression","required_eol", NULL
+#if YYDEBUG || YYERROR_VERBOSE || 0
+/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "ENDOFLINE", "AND", "OR", "NOT",
+ "STRING", "NAME", "NUMBER", "ASSIGN_OP", "REL_OP", "INCR_DECR", "Define",
+ "Break", "Quit", "Length", "Return", "For", "If", "While", "Sqrt",
+ "Else", "Scale", "Ibase", "Obase", "Auto", "Read", "Random", "Warranty",
+ "Halt", "Last", "Continue", "Print", "Limits", "UNARY_MINUS",
+ "HistoryVar", "Void", "'+'", "'-'", "'*'", "'/'", "'%'", "'^'", "';'",
+ "'('", "')'", "'{'", "'}'", "','", "'['", "']'", "'&'", "$accept",
+ "program", "input_item", "opt_newline", "semicolon_list",
+ "statement_list", "statement_or_error", "statement", "$@1", "$@2", "@3",
+ "$@4", "$@5", "$@6", "$@7", "$@8", "print_list", "print_element",
+ "opt_else", "$@9", "function", "$@10", "opt_void", "opt_parameter_list",
+ "opt_auto_define_list", "define_list", "opt_argument_list",
+ "argument_list", "opt_expression", "return_expression", "expression",
+ "$@11", "$@12", "$@13", "named_expression", "required_eol", YY_NULLPTR
};
#endif
-static const short yyr1[] = { 0,
- 50, 50, 51, 51, 51, 52, 52, 53, 53, 53,
- 53, 54, 54, 54, 54, 54, 54, 55, 55, 56,
- 56, 56, 56, 56, 56, 56, 56, 56, 57, 58,
- 59, 60, 56, 61, 56, 62, 63, 56, 56, 64,
- 56, 65, 65, 66, 66, 67, 68, 67, 70, 69,
- 71, 71, 72, 72, 72, 73, 73, 73, 73, 73,
- 73, 74, 74, 75, 75, 75, 75, 76, 76, 77,
- 77, 79, 78, 80, 78, 81, 78, 78, 78, 78,
- 78, 78, 78, 78, 78, 78, 78, 78, 78, 78,
- 78, 78, 78, 78, 78, 78, 82, 82, 82, 82,
- 82, 82, 82, 83, 83, 83
+# ifdef YYPRINT
+/* YYTOKNUM[NUM] -- (External) token number corresponding to the
+ (internal) symbol number NUM (which must be that of a token). */
+static const yytype_uint16 yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
+ 285, 286, 287, 288, 289, 290, 291, 292, 43, 45,
+ 42, 47, 37, 94, 59, 40, 41, 123, 125, 44,
+ 91, 93, 38
};
+# endif
+
+#define YYPACT_NINF -144
+
+#define yypact_value_is_default(Yystate) \
+ (!!((Yystate) == (-144)))
-static const short yyr2[] = { 0,
- 0, 2, 2, 1, 2, 0, 1, 0, 1, 3,
- 2, 0, 1, 2, 3, 2, 3, 1, 2, 1,
- 1, 1, 1, 1, 1, 1, 1, 2, 0, 0,
- 0, 0, 14, 0, 8, 0, 0, 8, 3, 0,
- 3, 1, 3, 1, 1, 0, 0, 4, 0, 12,
- 0, 1, 0, 3, 3, 1, 3, 4, 3, 5,
- 6, 0, 1, 1, 3, 3, 5, 0, 1, 0,
- 1, 0, 4, 0, 4, 0, 4, 2, 3, 3,
- 3, 3, 3, 3, 3, 2, 1, 1, 3, 4,
- 2, 2, 4, 4, 4, 3, 1, 4, 1, 1,
- 1, 1, 1, 0, 1, 2
+#define YYTABLE_NINF -16
+
+#define yytable_value_is_error(Yytable_value) \
+ 0
+
+ /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+static const yytype_int16 yypact[] =
+{
+ -144, 188, -144, 392, 595, -144, -36, -144, 484, -31,
+ -144, -144, -32, 595, -144, -11, -144, -10, -7, -144,
+ -144, -6, -5, -144, -144, -144, -144, -144, -144, -144,
+ 595, 595, 222, -144, 2, -144, -144, -144, 676, 14,
+ -144, -144, 131, 621, 595, -27, -144, -144, -144, 54,
+ 595, -144, 676, 20, 595, 21, 595, 595, 13, 37,
+ 569, -144, 425, 535, 1, -144, -144, 318, -144, -144,
+ 595, 595, 595, 595, 595, 595, 595, -144, -144, -23,
+ 41, 36, 676, 39, 43, 436, 595, 445, 595, 485,
+ 494, -144, -144, -144, -144, 40, 676, -144, 270, 535,
+ -144, -144, 595, 595, -22, 51, 51, 4, 4, 4,
+ 4, 595, 105, -144, 647, -144, 23, -144, 53, 676,
+ -144, 676, -144, -144, 569, -144, -144, 131, 123, -22,
+ -144, -20, 676, 45, 91, 94, 57, 55, -144, 102,
+ 60, -144, 352, 56, 58, 65, 102, 24, 595, -144,
+ 535, 102, -144, -144, 67, 68, 69, 70, 115, 116,
+ 81, 109, 535, -144, -144, 132, 86, 88, 89, -144,
+ -144, -144, -144, -144, 7, -144, 92, 97, 595, 102,
+ -144, 23, -144, -144, -144, 99, 535, 12, 222, -144,
+ -144, -144, -144, 9, 102, -144, 535, -144
};
-static const short yydefact[] = { 1,
- 0, 0, 0, 23, 97, 88, 0, 0, 24, 26,
- 0, 70, 29, 0, 36, 0, 101, 99, 100, 0,
- 20, 27, 103, 25, 40, 21, 102, 0, 0, 0,
- 2, 0, 9, 18, 4, 22, 87, 5, 19, 78,
- 62, 0, 97, 101, 91, 0, 0, 28, 71, 0,
- 0, 0, 0, 0, 0, 0, 86, 0, 0, 0,
- 13, 3, 0, 74, 76, 0, 0, 0, 0, 0,
- 0, 0, 72, 92, 97, 0, 63, 64, 0, 51,
- 0, 68, 0, 0, 0, 0, 96, 44, 41, 42,
- 45, 89, 0, 16, 39, 10, 0, 0, 79, 80,
- 81, 82, 83, 84, 85, 0, 0, 90, 0, 98,
- 56, 0, 0, 52, 93, 0, 69, 34, 37, 94,
- 95, 0, 15, 17, 75, 77, 73, 65, 97, 66,
- 0, 0, 6, 0, 30, 6, 0, 43, 0, 57,
- 0, 7, 0, 59, 0, 68, 0, 6, 67, 58,
- 104, 0, 0, 0, 46, 0, 105, 53, 60, 0,
- 31, 47, 35, 38, 106, 0, 49, 61, 68, 6,
- 0, 0, 0, 0, 54, 55, 0, 32, 48, 50,
- 6, 0, 33, 0, 0
+ /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
+ Performed when YYTABLE does not specify something else to do. Zero
+ means the default is an error. */
+static const yytype_uint8 yydefact[] =
+{
+ 2, 0, 1, 0, 0, 24, 103, 93, 0, 52,
+ 25, 27, 0, 75, 30, 0, 37, 0, 107, 105,
+ 106, 0, 0, 21, 28, 109, 26, 41, 22, 108,
+ 0, 0, 0, 3, 0, 10, 19, 5, 23, 92,
+ 6, 20, 83, 67, 0, 103, 107, 96, 53, 0,
+ 0, 29, 76, 0, 0, 0, 0, 0, 0, 0,
+ 0, 91, 0, 0, 0, 14, 4, 0, 79, 81,
+ 0, 0, 0, 0, 0, 0, 0, 77, 97, 103,
+ 0, 68, 69, 0, 0, 0, 73, 0, 0, 0,
+ 0, 101, 102, 45, 42, 43, 46, 94, 0, 17,
+ 40, 11, 0, 0, 84, 85, 86, 87, 88, 89,
+ 90, 0, 0, 95, 0, 104, 54, 98, 0, 74,
+ 35, 38, 99, 100, 0, 16, 18, 80, 82, 78,
+ 70, 103, 71, 59, 0, 0, 0, 55, 31, 7,
+ 0, 44, 0, 0, 0, 0, 7, 0, 73, 8,
+ 0, 7, 72, 60, 0, 0, 0, 63, 0, 0,
+ 0, 47, 0, 61, 62, 110, 0, 0, 0, 32,
+ 48, 36, 39, 111, 56, 64, 0, 0, 73, 7,
+ 112, 0, 50, 65, 66, 0, 0, 0, 0, 33,
+ 49, 57, 58, 0, 7, 51, 0, 34
};
-static const short yydefgoto[] = { 1,
- 31, 143, 32, 60, 61, 34, 50, 146, 169, 181,
- 136, 52, 137, 56, 89, 90, 163, 170, 35, 172,
- 113, 167, 114, 76, 77, 116, 48, 36, 106, 97,
- 98, 37, 158
+ /* YYPGOTO[NTERM-NUM]. */
+static const yytype_int16 yypgoto[] =
+{
+ -144, -144, -144, -143, -144, -39, 0, -3, -144, -144,
+ -144, -144, -144, -144, -144, -144, 27, -144, -144, -144,
+ -144, -144, -144, -144, -144, -29, -144, -144, -141, -144,
+ -2, -144, -144, -144, 145, -144
};
-static const short yypact[] = {-32768,
- 170, 375, 567,-32768, -25,-32768, -3, 7,-32768,-32768,
- -32, 567,-32768, -29,-32768, -26, -7,-32768,-32768, -5,
--32768,-32768,-32768,-32768,-32768,-32768,-32768, 567, 567, 213,
--32768, 16,-32768,-32768,-32768, 642, 14,-32768,-32768, 63,
- 597, 567, -9,-32768,-32768, 18, 567,-32768, 642, 19,
- 567, 20, 567, 567, 15, 537,-32768, 122, 505, 3,
--32768,-32768, 305,-32768,-32768, 567, 567, 567, 567, 567,
- 567, 567,-32768,-32768, -18, 21, 26, 642, 39, -4,
- 410, 567, 419, 567, 428, 466,-32768,-32768,-32768, 36,
- 642,-32768, 259, 505,-32768,-32768, 567, 567, 404, 316,
- 316, 44, 44, 44, 44, 567, 107,-32768, 627,-32768,
- -8, 79, 45, 43,-32768, 49, 642,-32768, 642,-32768,
--32768, 537,-32768,-32768, 63, 652, 404,-32768, 38, 642,
- 46, 48, 90, -1,-32768, 90, 61,-32768, 337,-32768,
- 59,-32768, 65, 64, 103, 567, 505, 90,-32768,-32768,
- 111, 68, 70, 78, 99, 505,-32768, 5,-32768, 75,
--32768,-32768,-32768,-32768,-32768, -4,-32768,-32768, 567, 90,
- 13, 213, 81, 505,-32768,-32768, 6,-32768,-32768,-32768,
- 90, 505,-32768, 129,-32768
+ /* YYDEFGOTO[NTERM-NUM]. */
+static const yytype_int16 yydefgoto[] =
+{
+ -1, 1, 33, 150, 34, 64, 65, 36, 53, 148,
+ 178, 194, 139, 55, 140, 60, 94, 95, 171, 179,
+ 37, 188, 49, 136, 182, 137, 80, 81, 118, 51,
+ 38, 111, 102, 103, 39, 174
};
-static const short yypgoto[] = {-32768,
--32768, -135,-32768, -37, 1, -2,-32768,-32768,-32768,-32768,
--32768,-32768,-32768,-32768, 25,-32768,-32768,-32768,-32768,-32768,
--32768,-32768, -30,-32768,-32768, -136,-32768, 0,-32768,-32768,
--32768, 131,-32768
+ /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule whose
+ number is the opposite. If YYTABLE_NINF, syntax error. */
+static const yytype_int16 yytable[] =
+{
+ 41, 35, 42, 156, 98, 66, 48, 160, 162, 43,
+ 180, 52, 98, 50, 44, 191, 71, 72, 73, 74,
+ 75, 76, 43, 44, 77, 43, 78, 112, 61, 62,
+ 142, 133, 157, 181, 54, 56, 186, 185, 57, 58,
+ 59, 82, 83, 68, 69, 99, 67, 76, 85, 100,
+ 70, 196, 87, 99, 89, 90, 192, 195, 96, 91,
+ 41, 147, 84, 134, 158, 86, 88, 101, 104, 105,
+ 106, 107, 108, 109, 110, 135, 159, 71, 72, 73,
+ 74, 75, 76, 92, 119, 114, 121, 113, 116, 124,
+ 115, 73, 74, 75, 76, 143, 126, 138, 125, 144,
+ 127, 128, 145, 146, 147, 149, 151, 153, 154, 129,
+ 83, 4, 132, 6, 7, 155, 165, 8, 163, 164,
+ 166, 12, 96, 167, 168, 169, 17, 68, 18, 19,
+ 20, 170, 21, 22, 70, 173, 25, 175, 176, 177,
+ 83, 29, 70, 183, 30, 189, 119, 161, 184, 193,
+ 31, 141, 187, 47, 0, 0, 130, 0, 0, 172,
+ 0, 71, 72, 73, 74, 75, 76, 0, 0, 71,
+ 72, 73, 74, 75, 76, 0, 119, 0, 0, 0,
+ 0, 0, 0, 190, 0, 0, 0, 0, 2, 3,
+ 0, -9, 0, 197, 4, 5, 6, 7, 0, 0,
+ 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
+ 0, 18, 19, 20, 0, 21, 22, 23, 24, 25,
+ 26, 27, 28, 63, 29, -13, 0, 30, 4, 5,
+ 6, 7, -9, 31, 8, 32, 10, 11, 12, 13,
+ 14, 15, 16, 17, 0, 18, 19, 20, 0, 21,
+ 22, 23, 24, 25, 26, 27, 28, 0, 29, 0,
+ 0, 30, 0, 0, 0, 0, -13, 31, 0, 32,
+ -13, 63, 0, -15, 0, 0, 4, 5, 6, 7,
+ 0, 0, 8, 0, 10, 11, 12, 13, 14, 15,
+ 16, 17, 0, 18, 19, 20, 0, 21, 22, 23,
+ 24, 25, 26, 27, 28, 0, 29, 0, 0, 30,
+ 0, 0, 0, 0, -15, 31, 0, 32, -15, 63,
+ 0, -12, 0, 0, 4, 5, 6, 7, 0, 0,
+ 8, 0, 10, 11, 12, 13, 14, 15, 16, 17,
+ 0, 18, 19, 20, 0, 21, 22, 23, 24, 25,
+ 26, 27, 28, 0, 29, 0, 0, 30, 4, 0,
+ 6, 7, -12, 31, 8, 32, 0, 0, 12, 0,
+ 0, 0, 0, 17, 0, 18, 19, 20, 0, 21,
+ 22, 0, 0, 25, 0, 0, 0, 0, 29, 0,
+ 0, 30, 0, 0, 0, 40, 0, 31, 4, 5,
+ 6, 7, 0, 152, 8, 0, 10, 11, 12, 13,
+ 14, 15, 16, 17, 0, 18, 19, 20, 0, 21,
+ 22, 23, 24, 25, 26, 27, 28, 0, 29, 68,
+ 69, 30, 0, 0, 0, 0, 70, 31, 0, 32,
+ 68, 69, 0, 0, 0, 0, 0, 70, 0, 68,
+ 69, 0, 0, 0, 0, 0, 70, 0, 0, 0,
+ 0, 0, 0, 71, 72, 73, 74, 75, 76, 0,
+ 0, 97, 0, 0, 71, 72, 73, 74, 75, 76,
+ 0, 0, 117, 71, 72, 73, 74, 75, 76, 68,
+ 69, 120, 45, 0, 0, 0, 70, 0, 68, 69,
+ 0, 0, 0, 0, 0, 70, 0, 46, 19, 20,
+ 0, 0, 0, 0, 0, 25, 0, 0, 0, 0,
+ 29, 0, 0, 71, 72, 73, 74, 75, 76, 0,
+ 0, 122, 71, 72, 73, 74, 75, 76, 0, 0,
+ 123, 4, 5, 6, 7, 0, 0, 8, 0, 10,
+ 11, 12, 13, 14, 15, 16, 17, 0, 18, 19,
+ 20, 0, 21, 22, 23, 24, 25, 26, 27, 28,
+ 0, 29, 0, 0, 30, 4, 93, 6, 7, 0,
+ 31, 8, 32, 0, 0, 12, 0, 0, 0, 0,
+ 17, 0, 18, 19, 20, 0, 21, 22, 0, 0,
+ 25, 4, 0, 6, 7, 29, 0, 8, 30, 0,
+ 0, 12, 0, 0, 31, 0, 17, 0, 18, 19,
+ 20, 0, 21, 22, 0, 0, 25, 4, 0, 79,
+ 7, 29, 0, 8, 30, 0, 0, 12, 0, 0,
+ 31, 0, 17, 0, 18, 19, 20, 0, 21, 22,
+ 0, 0, 25, 4, 0, 131, 7, 29, 0, 8,
+ 30, 0, 0, 12, 0, 0, 31, 0, 17, 0,
+ 18, 19, 20, 0, 21, 22, 0, 0, 25, 0,
+ 68, 69, 0, 29, 0, 0, 30, 70, 0, 0,
+ 0, 0, 31, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 71, 72, 73, 74, 75, 76
};
+static const yytype_int16 yycheck[] =
+{
+ 3, 1, 4, 146, 3, 3, 37, 148, 151, 45,
+ 3, 13, 3, 45, 50, 3, 38, 39, 40, 41,
+ 42, 43, 45, 50, 10, 45, 12, 50, 30, 31,
+ 50, 8, 8, 26, 45, 45, 179, 178, 45, 45,
+ 45, 43, 44, 4, 5, 44, 44, 43, 50, 48,
+ 11, 194, 54, 44, 56, 57, 44, 48, 60, 46,
+ 63, 49, 8, 40, 40, 45, 45, 67, 70, 71,
+ 72, 73, 74, 75, 76, 52, 52, 38, 39, 40,
+ 41, 42, 43, 46, 86, 49, 88, 46, 45, 49,
+ 51, 40, 41, 42, 43, 50, 99, 44, 98, 8,
+ 102, 103, 8, 46, 49, 3, 46, 51, 50, 111,
+ 112, 6, 114, 8, 9, 50, 47, 12, 51, 51,
+ 50, 16, 124, 8, 8, 44, 21, 4, 23, 24,
+ 25, 22, 27, 28, 11, 3, 31, 51, 50, 50,
+ 142, 36, 11, 51, 39, 46, 148, 150, 51, 188,
+ 45, 124, 181, 8, -1, -1, 51, -1, -1, 162,
+ -1, 38, 39, 40, 41, 42, 43, -1, -1, 38,
+ 39, 40, 41, 42, 43, -1, 178, -1, -1, -1,
+ -1, -1, -1, 186, -1, -1, -1, -1, 0, 1,
+ -1, 3, -1, 196, 6, 7, 8, 9, -1, -1,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ -1, 23, 24, 25, -1, 27, 28, 29, 30, 31,
+ 32, 33, 34, 1, 36, 3, -1, 39, 6, 7,
+ 8, 9, 44, 45, 12, 47, 14, 15, 16, 17,
+ 18, 19, 20, 21, -1, 23, 24, 25, -1, 27,
+ 28, 29, 30, 31, 32, 33, 34, -1, 36, -1,
+ -1, 39, -1, -1, -1, -1, 44, 45, -1, 47,
+ 48, 1, -1, 3, -1, -1, 6, 7, 8, 9,
+ -1, -1, 12, -1, 14, 15, 16, 17, 18, 19,
+ 20, 21, -1, 23, 24, 25, -1, 27, 28, 29,
+ 30, 31, 32, 33, 34, -1, 36, -1, -1, 39,
+ -1, -1, -1, -1, 44, 45, -1, 47, 48, 1,
+ -1, 3, -1, -1, 6, 7, 8, 9, -1, -1,
+ 12, -1, 14, 15, 16, 17, 18, 19, 20, 21,
+ -1, 23, 24, 25, -1, 27, 28, 29, 30, 31,
+ 32, 33, 34, -1, 36, -1, -1, 39, 6, -1,
+ 8, 9, 44, 45, 12, 47, -1, -1, 16, -1,
+ -1, -1, -1, 21, -1, 23, 24, 25, -1, 27,
+ 28, -1, -1, 31, -1, -1, -1, -1, 36, -1,
+ -1, 39, -1, -1, -1, 3, -1, 45, 6, 7,
+ 8, 9, -1, 51, 12, -1, 14, 15, 16, 17,
+ 18, 19, 20, 21, -1, 23, 24, 25, -1, 27,
+ 28, 29, 30, 31, 32, 33, 34, -1, 36, 4,
+ 5, 39, -1, -1, -1, -1, 11, 45, -1, 47,
+ 4, 5, -1, -1, -1, -1, -1, 11, -1, 4,
+ 5, -1, -1, -1, -1, -1, 11, -1, -1, -1,
+ -1, -1, -1, 38, 39, 40, 41, 42, 43, -1,
+ -1, 46, -1, -1, 38, 39, 40, 41, 42, 43,
+ -1, -1, 46, 38, 39, 40, 41, 42, 43, 4,
+ 5, 46, 8, -1, -1, -1, 11, -1, 4, 5,
+ -1, -1, -1, -1, -1, 11, -1, 23, 24, 25,
+ -1, -1, -1, -1, -1, 31, -1, -1, -1, -1,
+ 36, -1, -1, 38, 39, 40, 41, 42, 43, -1,
+ -1, 46, 38, 39, 40, 41, 42, 43, -1, -1,
+ 46, 6, 7, 8, 9, -1, -1, 12, -1, 14,
+ 15, 16, 17, 18, 19, 20, 21, -1, 23, 24,
+ 25, -1, 27, 28, 29, 30, 31, 32, 33, 34,
+ -1, 36, -1, -1, 39, 6, 7, 8, 9, -1,
+ 45, 12, 47, -1, -1, 16, -1, -1, -1, -1,
+ 21, -1, 23, 24, 25, -1, 27, 28, -1, -1,
+ 31, 6, -1, 8, 9, 36, -1, 12, 39, -1,
+ -1, 16, -1, -1, 45, -1, 21, -1, 23, 24,
+ 25, -1, 27, 28, -1, -1, 31, 6, -1, 8,
+ 9, 36, -1, 12, 39, -1, -1, 16, -1, -1,
+ 45, -1, 21, -1, 23, 24, 25, -1, 27, 28,
+ -1, -1, 31, 6, -1, 8, 9, 36, -1, 12,
+ 39, -1, -1, 16, -1, -1, 45, -1, 21, -1,
+ 23, 24, 25, -1, 27, 28, -1, -1, 31, -1,
+ 4, 5, -1, 36, -1, -1, 39, 11, -1, -1,
+ -1, -1, 45, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 38, 39, 40, 41, 42, 43
+};
-#define YYLAST 693
-
-
-static const short yytable[] = { 39,
- 147, 33, 40, 111, 43, 93, 144, 165, 93, 154,
- 47, 49, 156, 51, 46, 175, 53, 41, 62, 44,
- 18, 19, 42, 73, 41, 74, 23, 57, 58, 107,
- 166, 27, 173, 112, 174, 54, 145, 55, 42, 131,
- 78, 79, 64, 65, 94, 182, 81, 94, 95, 66,
- 83, 180, 85, 86, 176, 91, 39, 63, 87, 134,
- 80, 82, 84, 96, 108, 99, 100, 101, 102, 103,
- 104, 105, 109, 66, 67, 68, 69, 70, 71, 72,
- 41, 117, 122, 119, 72, 139, 132, 110, 133, 134,
- 135, 124, 142, 123, 140, 141, 125, 126, 67, 68,
- 69, 70, 71, 72, 148, 127, 79, 150, 130, 151,
- 153, 152, 3, 157, 5, 6, 159, 160, 7, 161,
- 162, 91, 11, 168, 178, 64, 65, 16, 185, 17,
- 18, 19, 66, 20, 177, 171, 23, 45, 79, 0,
- 0, 27, 0, 28, 155, 117, 138, 0, 0, 29,
- 0, 0, 0, 164, 0, 128, 0, 67, 68, 69,
- 70, 71, 72, 0, 0, 92, 0, 0, 117, 184,
- 2, 179, -8, 0, 0, 3, 4, 5, 6, 183,
- 0, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 0, 17, 18, 19, 0, 20, 21, 22, 23,
- 24, 25, 26, 0, 27, 0, 28, 0, 0, 0,
- 0, -8, 29, 59, 30, -12, 0, 0, 3, 4,
- 5, 6, 0, 0, 7, 0, 9, 10, 11, 12,
- 13, 14, 15, 16, 0, 17, 18, 19, 0, 20,
- 21, 22, 23, 24, 25, 26, 0, 27, 0, 28,
- 0, 0, 0, 0, -12, 29, 0, 30, -12, 59,
- 0, -14, 0, 0, 3, 4, 5, 6, 0, 0,
- 7, 0, 9, 10, 11, 12, 13, 14, 15, 16,
- 0, 17, 18, 19, 0, 20, 21, 22, 23, 24,
- 25, 26, 0, 27, 0, 28, 0, 0, 0, 0,
- -14, 29, 0, 30, -14, 59, 0, -11, 0, 0,
- 3, 4, 5, 6, 0, 0, 7, 0, 9, 10,
- 11, 12, 13, 14, 15, 16, 0, 17, 18, 19,
- 0, 20, 21, 22, 23, 24, 25, 26, 0, 27,
- 0, 28, 3, 0, 5, 6, -11, 29, 7, 30,
- 0, 0, 11, 69, 70, 71, 72, 16, 0, 17,
- 18, 19, 0, 20, 0, 0, 23, 0, 0, 0,
- 0, 27, 0, 28, 0, 0, 0, 38, 0, 29,
- 3, 4, 5, 6, 0, 149, 7, 0, 9, 10,
- 11, 12, 13, 14, 15, 16, 0, 17, 18, 19,
- 0, 20, 21, 22, 23, 24, 25, 26, 0, 27,
- 0, 28, 0, 64, 65, 0, 0, 29, 0, 30,
- 66, 0, 64, 65, 0, 0, 0, 0, 0, 66,
- 0, 64, 65, 0, 0, 0, 0, 0, 66, 67,
- 68, 69, 70, 71, 72, 67, 68, 69, 70, 71,
- 72, 0, 0, 115, 67, 68, 69, 70, 71, 72,
- 0, 0, 118, 67, 68, 69, 70, 71, 72, 64,
- 65, 120, 0, 0, 0, 0, 66, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 67, 68, 69, 70, 71, 72, 0, 0, 121,
- 3, 4, 5, 6, 0, 0, 7, 0, 9, 10,
- 11, 12, 13, 14, 15, 16, 0, 17, 18, 19,
- 0, 20, 21, 22, 23, 24, 25, 26, 0, 27,
- 0, 28, 3, 88, 5, 6, 0, 29, 7, 30,
- 0, 0, 11, 0, 0, 0, 0, 16, 0, 17,
- 18, 19, 0, 20, 0, 0, 23, 0, 0, 0,
- 0, 27, 3, 28, 5, 6, 0, 0, 7, 29,
- 0, 0, 11, 0, 0, 0, 0, 16, 0, 17,
- 18, 19, 0, 20, 0, 0, 23, 0, 0, 0,
- 0, 27, 3, 28, 75, 6, 0, 0, 7, 29,
- 0, 0, 11, 0, 0, 0, 0, 16, 0, 17,
- 18, 19, 0, 20, 0, 0, 23, 0, 0, 0,
- 0, 27, 3, 28, 129, 6, 0, 0, 7, 29,
- 0, 0, 11, 0, 0, 64, 65, 16, 0, 17,
- 18, 19, 66, 20, 0, 64, 23, 0, 0, 0,
- 0, 27, 66, 28, 0, 0, 0, 0, 0, 29,
- 0, 0, 0, 0, 0, 0, 0, 67, 68, 69,
- 70, 71, 72, 0, 0, 0, 0, 67, 68, 69,
- 70, 71, 72
+ /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const yytype_uint8 yystos[] =
+{
+ 0, 54, 0, 1, 6, 7, 8, 9, 12, 13,
+ 14, 15, 16, 17, 18, 19, 20, 21, 23, 24,
+ 25, 27, 28, 29, 30, 31, 32, 33, 34, 36,
+ 39, 45, 47, 55, 57, 59, 60, 73, 83, 87,
+ 3, 60, 83, 45, 50, 8, 23, 87, 37, 75,
+ 45, 82, 83, 61, 45, 66, 45, 45, 45, 45,
+ 68, 83, 83, 1, 58, 59, 3, 44, 4, 5,
+ 11, 38, 39, 40, 41, 42, 43, 10, 12, 8,
+ 79, 80, 83, 83, 8, 83, 45, 83, 45, 83,
+ 83, 46, 46, 7, 69, 70, 83, 46, 3, 44,
+ 48, 59, 85, 86, 83, 83, 83, 83, 83, 83,
+ 83, 84, 50, 46, 49, 51, 45, 46, 81, 83,
+ 46, 83, 46, 46, 49, 59, 60, 83, 83, 83,
+ 51, 8, 83, 8, 40, 52, 76, 78, 44, 65,
+ 67, 69, 50, 50, 8, 8, 46, 49, 62, 3,
+ 56, 46, 51, 51, 50, 50, 56, 8, 40, 52,
+ 81, 60, 56, 51, 51, 47, 50, 8, 8, 44,
+ 22, 71, 60, 3, 88, 51, 50, 50, 63, 72,
+ 3, 26, 77, 51, 51, 81, 56, 78, 74, 46,
+ 60, 3, 44, 58, 64, 48, 56, 60
};
-static const short yycheck[] = { 2,
- 136, 1, 3, 8, 8, 3, 8, 3, 3, 146,
- 43, 12, 148, 43, 8, 3, 43, 43, 3, 23,
- 24, 25, 48, 10, 43, 12, 30, 28, 29, 48,
- 26, 35, 169, 38, 170, 43, 38, 43, 48, 48,
- 41, 42, 4, 5, 42, 181, 47, 42, 46, 11,
- 51, 46, 53, 54, 42, 56, 59, 42, 44, 47,
- 43, 43, 43, 63, 44, 66, 67, 68, 69, 70,
- 71, 72, 47, 11, 36, 37, 38, 39, 40, 41,
- 43, 82, 47, 84, 41, 48, 8, 49, 44, 47,
- 42, 94, 3, 93, 49, 48, 97, 98, 36, 37,
- 38, 39, 40, 41, 44, 106, 107, 49, 109, 45,
- 8, 48, 6, 3, 8, 9, 49, 48, 12, 42,
- 22, 122, 16, 49, 44, 4, 5, 21, 0, 23,
- 24, 25, 11, 27, 172, 166, 30, 7, 139, -1,
- -1, 35, -1, 37, 147, 146, 122, -1, -1, 43,
- -1, -1, -1, 156, -1, 49, -1, 36, 37, 38,
- 39, 40, 41, -1, -1, 44, -1, -1, 169, 0,
- 1, 174, 3, -1, -1, 6, 7, 8, 9, 182,
- -1, 12, 13, 14, 15, 16, 17, 18, 19, 20,
- 21, -1, 23, 24, 25, -1, 27, 28, 29, 30,
- 31, 32, 33, -1, 35, -1, 37, -1, -1, -1,
- -1, 42, 43, 1, 45, 3, -1, -1, 6, 7,
- 8, 9, -1, -1, 12, -1, 14, 15, 16, 17,
- 18, 19, 20, 21, -1, 23, 24, 25, -1, 27,
- 28, 29, 30, 31, 32, 33, -1, 35, -1, 37,
- -1, -1, -1, -1, 42, 43, -1, 45, 46, 1,
- -1, 3, -1, -1, 6, 7, 8, 9, -1, -1,
- 12, -1, 14, 15, 16, 17, 18, 19, 20, 21,
- -1, 23, 24, 25, -1, 27, 28, 29, 30, 31,
- 32, 33, -1, 35, -1, 37, -1, -1, -1, -1,
- 42, 43, -1, 45, 46, 1, -1, 3, -1, -1,
- 6, 7, 8, 9, -1, -1, 12, -1, 14, 15,
- 16, 17, 18, 19, 20, 21, -1, 23, 24, 25,
- -1, 27, 28, 29, 30, 31, 32, 33, -1, 35,
- -1, 37, 6, -1, 8, 9, 42, 43, 12, 45,
- -1, -1, 16, 38, 39, 40, 41, 21, -1, 23,
- 24, 25, -1, 27, -1, -1, 30, -1, -1, -1,
- -1, 35, -1, 37, -1, -1, -1, 3, -1, 43,
- 6, 7, 8, 9, -1, 49, 12, -1, 14, 15,
- 16, 17, 18, 19, 20, 21, -1, 23, 24, 25,
- -1, 27, 28, 29, 30, 31, 32, 33, -1, 35,
- -1, 37, -1, 4, 5, -1, -1, 43, -1, 45,
- 11, -1, 4, 5, -1, -1, -1, -1, -1, 11,
- -1, 4, 5, -1, -1, -1, -1, -1, 11, 36,
- 37, 38, 39, 40, 41, 36, 37, 38, 39, 40,
- 41, -1, -1, 44, 36, 37, 38, 39, 40, 41,
- -1, -1, 44, 36, 37, 38, 39, 40, 41, 4,
- 5, 44, -1, -1, -1, -1, 11, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, 36, 37, 38, 39, 40, 41, -1, -1, 44,
- 6, 7, 8, 9, -1, -1, 12, -1, 14, 15,
- 16, 17, 18, 19, 20, 21, -1, 23, 24, 25,
- -1, 27, 28, 29, 30, 31, 32, 33, -1, 35,
- -1, 37, 6, 7, 8, 9, -1, 43, 12, 45,
- -1, -1, 16, -1, -1, -1, -1, 21, -1, 23,
- 24, 25, -1, 27, -1, -1, 30, -1, -1, -1,
- -1, 35, 6, 37, 8, 9, -1, -1, 12, 43,
- -1, -1, 16, -1, -1, -1, -1, 21, -1, 23,
- 24, 25, -1, 27, -1, -1, 30, -1, -1, -1,
- -1, 35, 6, 37, 8, 9, -1, -1, 12, 43,
- -1, -1, 16, -1, -1, -1, -1, 21, -1, 23,
- 24, 25, -1, 27, -1, -1, 30, -1, -1, -1,
- -1, 35, 6, 37, 8, 9, -1, -1, 12, 43,
- -1, -1, 16, -1, -1, 4, 5, 21, -1, 23,
- 24, 25, 11, 27, -1, 4, 30, -1, -1, -1,
- -1, 35, 11, 37, -1, -1, -1, -1, -1, 43,
- -1, -1, -1, -1, -1, -1, -1, 36, 37, 38,
- 39, 40, 41, -1, -1, -1, -1, 36, 37, 38,
- 39, 40, 41
+ /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const yytype_uint8 yyr1[] =
+{
+ 0, 53, 54, 54, 55, 55, 55, 56, 56, 57,
+ 57, 57, 57, 58, 58, 58, 58, 58, 58, 59,
+ 59, 60, 60, 60, 60, 60, 60, 60, 60, 60,
+ 61, 62, 63, 64, 60, 65, 60, 66, 67, 60,
+ 60, 68, 60, 69, 69, 70, 70, 71, 72, 71,
+ 74, 73, 75, 75, 76, 76, 77, 77, 77, 78,
+ 78, 78, 78, 78, 78, 78, 78, 79, 79, 80,
+ 80, 80, 80, 81, 81, 82, 82, 84, 83, 85,
+ 83, 86, 83, 83, 83, 83, 83, 83, 83, 83,
+ 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
+ 83, 83, 83, 87, 87, 87, 87, 87, 87, 87,
+ 88, 88, 88
};
-/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/usr/gnu/share/bison.simple"
-/* This file comes from bison-1.27. */
-/* Skeleton output parser for bison,
- Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
+ /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
+static const yytype_uint8 yyr2[] =
+{
+ 0, 2, 0, 2, 2, 1, 2, 0, 1, 0,
+ 1, 3, 2, 0, 1, 2, 3, 2, 3, 1,
+ 2, 1, 1, 1, 1, 1, 1, 1, 1, 2,
+ 0, 0, 0, 0, 14, 0, 8, 0, 0, 8,
+ 3, 0, 3, 1, 3, 1, 1, 0, 0, 4,
+ 0, 13, 0, 1, 0, 1, 0, 3, 3, 1,
+ 3, 4, 4, 3, 5, 6, 6, 0, 1, 1,
+ 3, 3, 5, 0, 1, 0, 1, 0, 4, 0,
+ 4, 0, 4, 2, 3, 3, 3, 3, 3, 3,
+ 3, 2, 1, 1, 3, 4, 2, 2, 4, 4,
+ 4, 3, 3, 1, 4, 1, 1, 1, 1, 1,
+ 0, 1, 2
+};
- This program 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, 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.
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrorlab
- 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., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-/* This is the parser code that is written into each bison parser
- when the %semantic_parser declaration is not specified in the grammar.
- It was written by Richard Stallman by simplifying the hairy parser
- used when %semantic_parser is specified. */
-
-#ifndef YYSTACK_USE_ALLOCA
-#ifdef alloca
-#define YYSTACK_USE_ALLOCA
-#else /* alloca not defined */
-#ifdef __GNUC__
-#define YYSTACK_USE_ALLOCA
-#define alloca __builtin_alloca
-#else /* not GNU C. */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
-#define YYSTACK_USE_ALLOCA
-#include <alloca.h>
-#else /* not sparc */
-/* We think this test detects Watcom and Microsoft C. */
-/* This used to test MSDOS, but that is a bad idea
- since that symbol is in the user namespace. */
-#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
-#if 0 /* No need for malloc.h, which pollutes the namespace;
- instead, just don't use alloca. */
-#include <malloc.h>
-#endif
-#else /* not MSDOS, or __TURBOC__ */
-#if defined(_AIX)
-/* I don't know what this was needed for, but it pollutes the namespace.
- So I turned it off. rms, 2 May 1997. */
-/* #include <malloc.h> */
- #pragma alloca
-#define YYSTACK_USE_ALLOCA
-#else /* not MSDOS, or __TURBOC__, or _AIX */
-#if 0
-#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
- and on HPUX 10. Eventually we can turn this on. */
-#define YYSTACK_USE_ALLOCA
-#define alloca __builtin_alloca
-#endif /* __hpux */
-#endif
-#endif /* not _AIX */
-#endif /* not MSDOS, or __TURBOC__ */
-#endif /* not sparc */
-#endif /* not GNU C */
-#endif /* alloca not defined */
-#endif /* YYSTACK_USE_ALLOCA not defined */
-
-#ifdef YYSTACK_USE_ALLOCA
-#define YYSTACK_ALLOC alloca
-#else
-#define YYSTACK_ALLOC malloc
-#endif
-/* Note: there must be only one dollar sign in this file.
- It is replaced by the list of actions, each action
- as one case of the switch. */
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY -2
-#define YYEOF 0
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrlab1
-/* Like YYERROR except do call yyerror.
- This remains here temporarily to ease the
- transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(token, value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { yychar = (token), yylval = (value); \
- yychar1 = YYTRANSLATE (yychar); \
- YYPOPSTACK; \
- goto yybackup; \
- } \
- else \
- { yyerror ("syntax error: cannot back up"); YYERROR; } \
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
while (0)
-#define YYTERROR 1
-#define YYERRCODE 256
+/* Error token number */
+#define YYTERROR 1
+#define YYERRCODE 256
-#ifndef YYPURE
-#define YYLEX yylex()
-#endif
-#ifdef YYPURE
-#ifdef YYLSP_NEEDED
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval, &yylloc)
-#endif
-#else /* not YYLSP_NEEDED */
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval)
-#endif
-#endif /* not YYLSP_NEEDED */
-#endif
-/* If nonreentrant, generate the variables here */
+/* Enable debugging if requested. */
+#if YYDEBUG
-#ifndef YYPURE
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
-int yychar; /* the lookahead symbol */
-YYSTYPE yylval; /* the semantic value of the */
- /* lookahead symbol */
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (0)
-#ifdef YYLSP_NEEDED
-YYLTYPE yylloc; /* location data for the lookahead */
- /* symbol */
+/* This macro is provided for backward compatibility. */
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
#endif
-int yynerrs; /* number of parse errors so far */
-#endif /* not YYPURE */
-#if YYDEBUG != 0
-int yydebug; /* nonzero means print parse trace */
-/* Since this is uninitialized, it does not stop multiple parsers
- from coexisting. */
-#endif
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yy_symbol_print (stderr, \
+ Type, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (0)
-/* YYINITDEPTH indicates the initial size of the parser's stacks */
-#ifndef YYINITDEPTH
-#define YYINITDEPTH 200
-#endif
+/*----------------------------------------.
+| Print this symbol's value on YYOUTPUT. |
+`----------------------------------------*/
-/* YYMAXDEPTH is the maximum size the stacks can grow to
- (effective only if the built-in stack extension method is used). */
+static void
+yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
+{
+ FILE *yyo = yyoutput;
+ YYUSE (yyo);
+ if (!yyvaluep)
+ return;
+# ifdef YYPRINT
+ if (yytype < YYNTOKENS)
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# endif
+ YYUSE (yytype);
+}
-#if YYMAXDEPTH == 0
-#undef YYMAXDEPTH
-#endif
-#ifndef YYMAXDEPTH
-#define YYMAXDEPTH 10000
-#endif
-
-/* Define __yy_memcpy. Note that the size argument
- should be passed with type unsigned int, because that is what the non-GCC
- definitions require. With GCC, __builtin_memcpy takes an arg
- of type size_t, but it can handle unsigned int. */
-
-#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
-#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
-#else /* not GNU C or C++ */
-#ifndef __cplusplus
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
static void
-__yy_memcpy (to, from, count)
- char *to;
- char *from;
- unsigned int count;
+yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
{
- register char *f = from;
- register char *t = to;
- register int i = count;
+ YYFPRINTF (yyoutput, "%s %s (",
+ yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
- while (i-- > 0)
- *t++ = *f++;
+ yy_symbol_value_print (yyoutput, yytype, yyvaluep);
+ YYFPRINTF (yyoutput, ")");
}
-#else /* __cplusplus */
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (included). |
+`------------------------------------------------------------------*/
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
static void
-__yy_memcpy (char *to, char *from, unsigned int count)
+yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
{
- register char *t = to;
- register char *f = from;
- register int i = count;
+ YYFPRINTF (stderr, "Stack now");
+ for (; yybottom <= yytop; yybottom++)
+ {
+ int yybot = *yybottom;
+ YYFPRINTF (stderr, " %d", yybot);
+ }
+ YYFPRINTF (stderr, "\n");
+}
- while (i-- > 0)
- *t++ = *f++;
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (0)
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+static void
+yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
+{
+ unsigned long int yylno = yyrline[yyrule];
+ int yynrhs = yyr2[yyrule];
+ int yyi;
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
+ yyrule - 1, yylno);
+ /* The symbols being reduced. */
+ for (yyi = 0; yyi < yynrhs; yyi++)
+ {
+ YYFPRINTF (stderr, " $%d = ", yyi + 1);
+ yy_symbol_print (stderr,
+ yystos[yyssp[yyi + 1 - yynrhs]],
+ &(yyvsp[(yyi + 1) - (yynrhs)])
+ );
+ YYFPRINTF (stderr, "\n");
+ }
}
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (yyssp, yyvsp, Rule); \
+} while (0)
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
#endif
-#endif
-
-#line 216 "/usr/gnu/share/bison.simple"
-
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
- into yyparse. The argument should have type void *.
- It should actually point to an object.
- Grammar actions can access the variable by casting it
- to the proper pointer type. */
-
-#ifdef YYPARSE_PARAM
-#ifdef __cplusplus
-#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL
-#else /* not __cplusplus */
-#define YYPARSE_PARAM_ARG YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-#endif /* not __cplusplus */
-#else /* not YYPARSE_PARAM */
-#define YYPARSE_PARAM_ARG
-#define YYPARSE_PARAM_DECL
-#endif /* not YYPARSE_PARAM */
-
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-#ifdef YYPARSE_PARAM
-int yyparse (void *);
-#else
-int yyparse (void);
-#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
#endif
-int
-yyparse(YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined __GLIBC__ && defined _STRING_H
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+static YYSIZE_T
+yystrlen (const char *yystr)
{
- register int yystate;
- register int yyn;
- register short *yyssp;
- register YYSTYPE *yyvsp;
- int yyerrstatus; /* number of tokens to shift before error messages enabled */
- int yychar1 = 0; /* lookahead token as an internal (translated) token number */
+ YYSIZE_T yylen;
+ for (yylen = 0; yystr[yylen]; yylen++)
+ continue;
+ return yylen;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+static char *
+yystpcpy (char *yydest, const char *yysrc)
+{
+ char *yyd = yydest;
+ const char *yys = yysrc;
- short yyssa[YYINITDEPTH]; /* the state stack */
- YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
- short *yyss = yyssa; /* refer to the stacks thru separate pointers */
- YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
+ return yyd - 1;
+}
+# endif
+# endif
+
+# ifndef yytnamerr
+/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
+ quotes and backslashes, so that it's suitable for yyerror. The
+ heuristic is that double-quoting is unnecessary unless the string
+ contains an apostrophe, a comma, or backslash (other than
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
+ null, do not copy; instead, return the length of what the result
+ would have been. */
+static YYSIZE_T
+yytnamerr (char *yyres, const char *yystr)
+{
+ if (*yystr == '"')
+ {
+ YYSIZE_T yyn = 0;
+ char const *yyp = yystr;
+
+ for (;;)
+ switch (*++yyp)
+ {
+ case '\'':
+ case ',':
+ goto do_not_strip_quotes;
+
+ case '\\':
+ if (*++yyp != '\\')
+ goto do_not_strip_quotes;
+ /* Fall through. */
+ default:
+ if (yyres)
+ yyres[yyn] = *yyp;
+ yyn++;
+ break;
+
+ case '"':
+ if (yyres)
+ yyres[yyn] = '\0';
+ return yyn;
+ }
+ do_not_strip_quotes: ;
+ }
-#ifdef YYLSP_NEEDED
- YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
+ if (! yyres)
+ return yystrlen (yystr);
-#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
-#else
-#define YYPOPSTACK (yyvsp--, yyssp--)
-#endif
+ return yystpcpy (yyres, yystr) - yyres;
+}
+# endif
+
+/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
+ about the unexpected token YYTOKEN for the state stack whose top is
+ YYSSP.
+
+ Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
+ not large enough to hold the message. In that case, also set
+ *YYMSG_ALLOC to the required number of bytes. Return 2 if the
+ required number of bytes is too large to store. */
+static int
+yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
+ yytype_int16 *yyssp, int yytoken)
+{
+ YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
+ YYSIZE_T yysize = yysize0;
+ enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
+ /* Internationalized format string. */
+ const char *yyformat = YY_NULLPTR;
+ /* Arguments of yyformat. */
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
+ /* Number of reported tokens (one for the "unexpected", one per
+ "expected"). */
+ int yycount = 0;
+
+ /* There are many possibilities here to consider:
+ - If this state is a consistent state with a default action, then
+ the only way this function was invoked is if the default action
+ is an error action. In that case, don't check for expected
+ tokens because there are none.
+ - The only way there can be no lookahead present (in yychar) is if
+ this state is a consistent state with a default action. Thus,
+ detecting the absence of a lookahead is sufficient to determine
+ that there is no unexpected or expected token to report. In that
+ case, just report a simple "syntax error".
+ - Don't assume there isn't a lookahead just because this state is a
+ consistent state with a default action. There might have been a
+ previous inconsistent state, consistent state with a non-default
+ action, or user semantic action that manipulated yychar.
+ - Of course, the expected token list depends on states to have
+ correct lookahead information, and it depends on the parser not
+ to perform extra reductions after fetching a lookahead from the
+ scanner and before detecting a syntax error. Thus, state merging
+ (from LALR or IELR) and default reductions corrupt the expected
+ token list. However, the list is correct for canonical LR with
+ one exception: it will still contain any token that will not be
+ accepted due to an error action in a later state.
+ */
+ if (yytoken != YYEMPTY)
+ {
+ int yyn = yypact[*yyssp];
+ yyarg[yycount++] = yytname[yytoken];
+ if (!yypact_value_is_default (yyn))
+ {
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. In other words, skip the first -YYN actions for
+ this state because they are default actions. */
+ int yyxbegin = yyn < 0 ? -yyn : 0;
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = YYLAST - yyn + 1;
+ int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
+ int yyx;
+
+ for (yyx = yyxbegin; yyx < yyxend; ++yyx)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
+ && !yytable_value_is_error (yytable[yyx + yyn]))
+ {
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
+ {
+ yycount = 1;
+ yysize = yysize0;
+ break;
+ }
+ yyarg[yycount++] = yytname[yyx];
+ {
+ YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
+ if (! (yysize <= yysize1
+ && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
+ }
+ }
+ }
- int yystacksize = YYINITDEPTH;
- int yyfree_stacks = 0;
+ switch (yycount)
+ {
+# define YYCASE_(N, S) \
+ case N: \
+ yyformat = S; \
+ break
+ YYCASE_(0, YY_("syntax error"));
+ YYCASE_(1, YY_("syntax error, unexpected %s"));
+ YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
+ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
+ YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
+ YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
+# undef YYCASE_
+ }
-#ifdef YYPURE
- int yychar;
- YYSTYPE yylval;
- int yynerrs;
-#ifdef YYLSP_NEEDED
- YYLTYPE yylloc;
-#endif
-#endif
+ {
+ YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
+ if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
+ return 2;
+ yysize = yysize1;
+ }
- YYSTYPE yyval; /* the variable used to return */
- /* semantic values from the action */
- /* routines */
+ if (*yymsg_alloc < yysize)
+ {
+ *yymsg_alloc = 2 * yysize;
+ if (! (yysize <= *yymsg_alloc
+ && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
+ *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
+ return 1;
+ }
- int yylen;
+ /* Avoid sprintf, as that infringes on the user's name space.
+ Don't have undefined behavior even if the translation
+ produced a string with the wrong number of "%s"s. */
+ {
+ char *yyp = *yymsg;
+ int yyi = 0;
+ while ((*yyp = *yyformat) != '\0')
+ if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
+ {
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
+ yyformat += 2;
+ }
+ else
+ {
+ yyp++;
+ yyformat++;
+ }
+ }
+ return 0;
+}
+#endif /* YYERROR_VERBOSE */
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Starting parse\n");
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+static void
+yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
+{
+ YYUSE (yyvaluep);
+ if (!yymsg)
+ yymsg = "Deleting";
+ YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
+
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ YYUSE (yytype);
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
+}
+
+
+
+
+/* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+/* Number of syntax errors so far. */
+int yynerrs;
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+int
+yyparse (void)
+{
+ int yystate;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+
+ /* The stacks and their tools:
+ 'yyss': related to states.
+ 'yyvs': related to semantic values.
+
+ Refer to the stacks through separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ yytype_int16 yyssa[YYINITDEPTH];
+ yytype_int16 *yyss;
+ yytype_int16 *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs;
+ YYSTYPE *yyvsp;
+
+ YYSIZE_T yystacksize;
+
+ int yyn;
+ int yyresult;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken = 0;
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+#if YYERROR_VERBOSE
+ /* Buffer for error messages, and its allocated size. */
+ char yymsgbuf[128];
+ char *yymsg = yymsgbuf;
+ YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
+#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
+
+ /* The number of symbols on the RHS of the reduced rule.
+ Keep to zero when no symbol should be popped. */
+ int yylen = 0;
+
+ yyssp = yyss = yyssa;
+ yyvsp = yyvs = yyvsa;
+ yystacksize = YYINITDEPTH;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
+ yychar = YYEMPTY; /* Cause a token to be read. */
+ goto yysetstate;
- yyssp = yyss - 1;
- yyvsp = yyvs;
-#ifdef YYLSP_NEEDED
- yylsp = yyls;
-#endif
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. So pushing a state here evens the stacks. */
+ yyssp++;
-/* Push a new state, which is found in yystate . */
-/* In all cases, when you get here, the value and location stacks
- have just been pushed. so pushing a state here evens the stacks. */
-yynewstate:
+ yysetstate:
+ *yyssp = yystate;
- *++yyssp = yystate;
-
- if (yyssp >= yyss + yystacksize - 1)
+ if (yyss + yystacksize - 1 <= yyssp)
{
- /* Give user a chance to reallocate the stack */
- /* Use copies of these so that the &'s don't force the real ones into memory. */
- YYSTYPE *yyvs1 = yyvs;
- short *yyss1 = yyss;
-#ifdef YYLSP_NEEDED
- YYLTYPE *yyls1 = yyls;
-#endif
-
/* Get the current used size of the three stacks, in elements. */
- int size = yyssp - yyss + 1;
+ YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
- /* Each stack pointer address is followed by the size of
- the data in use in that stack, in bytes. */
-#ifdef YYLSP_NEEDED
- /* This used to be a conditional around just the two extra args,
- but that might be undefined if yyoverflow is a macro. */
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yyls1, size * sizeof (*yylsp),
- &yystacksize);
-#else
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yystacksize);
-#endif
-
- yyss = yyss1; yyvs = yyvs1;
-#ifdef YYLSP_NEEDED
- yyls = yyls1;
-#endif
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ yytype_int16 *yyss1 = yyss;
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow (YY_("memory exhausted"),
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyexhaustedlab;
+# else
/* Extend the stack our own way. */
- if (yystacksize >= YYMAXDEPTH)
- {
- yyerror("parser stack overflow");
- if (yyfree_stacks)
- {
- free (yyss);
- free (yyvs);
-#ifdef YYLSP_NEEDED
- free (yyls);
-#endif
- }
- return 2;
- }
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyexhaustedlab;
yystacksize *= 2;
- if (yystacksize > YYMAXDEPTH)
- yystacksize = YYMAXDEPTH;
-#ifndef YYSTACK_USE_ALLOCA
- yyfree_stacks = 1;
-#endif
- yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
- __yy_memcpy ((char *)yyss, (char *)yyss1,
- size * (unsigned int) sizeof (*yyssp));
- yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
- __yy_memcpy ((char *)yyvs, (char *)yyvs1,
- size * (unsigned int) sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
- yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
- __yy_memcpy ((char *)yyls, (char *)yyls1,
- size * (unsigned int) sizeof (*yylsp));
-#endif
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ yytype_int16 *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyexhaustedlab;
+ YYSTACK_RELOCATE (yyss_alloc, yyss);
+ YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
#endif /* no yyoverflow */
- yyssp = yyss + size - 1;
- yyvsp = yyvs + size - 1;
-#ifdef YYLSP_NEEDED
- yylsp = yyls + size - 1;
-#endif
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Stack size increased to %d\n", yystacksize);
-#endif
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
- if (yyssp >= yyss + yystacksize - 1)
- YYABORT;
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
}
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Entering state %d\n", yystate);
-#endif
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ if (yystate == YYFINAL)
+ YYACCEPT;
goto yybackup;
- yybackup:
-/* Do appropriate processing given the current state. */
-/* Read a lookahead token if we need one and don't already have one. */
-/* yyresume: */
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
- /* First try to decide what to do without reference to lookahead token. */
+ /* Do appropriate processing given the current state. Read a
+ lookahead token if we need one and don't already have one. */
+ /* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
- if (yyn == YYFLAG)
+ if (yypact_value_is_default (yyn))
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
- /* yychar is either YYEMPTY or YYEOF
- or a valid token in external form. */
-
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
if (yychar == YYEMPTY)
{
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Reading a token: ");
-#endif
- yychar = YYLEX;
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = yylex ();
}
- /* Convert token to internal form (in yychar1) for indexing tables with */
-
- if (yychar <= 0) /* This means end of input. */
+ if (yychar <= YYEOF)
{
- yychar1 = 0;
- yychar = YYEOF; /* Don't call YYLEX any more */
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Now at end of input.\n");
-#endif
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
- yychar1 = YYTRANSLATE(yychar);
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise meaning
- of a token, for further debugging info. */
-#ifdef YYPRINT
- YYPRINT (stderr, yychar, yylval);
-#endif
- fprintf (stderr, ")\n");
- }
-#endif
+ yytoken = YYTRANSLATE (yychar);
+ YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
- yyn += yychar1;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
-
yyn = yytable[yyn];
-
- /* yyn is what to do for this token type in this state.
- Negative => reduce, -yyn is rule number.
- Positive => shift, yyn is new state.
- New state is final state => don't bother to shift,
- just return success.
- 0, or most negative number => error. */
-
- if (yyn < 0)
+ if (yyn <= 0)
{
- if (yyn == YYFLAG)
- goto yyerrlab;
+ if (yytable_value_is_error (yyn))
+ goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
- else if (yyn == 0)
- goto yyerrlab;
- if (yyn == YYFINAL)
- YYACCEPT;
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
/* Shift the lookahead token. */
+ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
-#endif
-
- /* Discard the token being shifted unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
+ /* Discard the shifted token. */
+ yychar = YYEMPTY;
+ yystate = yyn;
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
-#endif
-
- /* count tokens shifted since error; after three, turn off error status. */
- if (yyerrstatus) yyerrstatus--;
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
- yystate = yyn;
goto yynewstate;
-/* Do the default action for the current state. */
-yydefault:
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
+ goto yyreduce;
+
-/* Do a reduction. yyn is the number of a rule to reduce with. */
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
yyreduce:
+ /* yyn is the number of a rule to reduce with. */
yylen = yyr2[yyn];
- if (yylen > 0)
- yyval = yyvsp[1-yylen]; /* implement default value of the action */
-#if YYDEBUG != 0
- if (yydebug)
- {
- int i;
+ /* If YYLEN is nonzero, implement the default value of the action:
+ '$$ = $1'.
- fprintf (stderr, "Reducing via rule %d (line %d), ",
- yyn, yyrline[yyn]);
-
- /* Print the symbols being reduced, and their result. */
- for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
- fprintf (stderr, "%s ", yytname[yyrhs[i]]);
- fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
- }
-#endif
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
- switch (yyn) {
-
-case 1:
-#line 108 "bc.y"
-{
- yyval.i_value = 0;
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 2:
+#line 123 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyval.i_value) = 0;
if (interactive && !quiet)
{
show_bc_version ();
welcome ();
}
- ;
- break;}
-case 3:
-#line 119 "bc.y"
-{ run_code (); ;
- break;}
-case 4:
-#line 121 "bc.y"
-{ run_code (); ;
- break;}
-case 5:
-#line 123 "bc.y"
-{
+ }
+#line 1553 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 4:
+#line 134 "../../bc/bc.y" /* yacc.c:1646 */
+ { run_code (); }
+#line 1559 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 5:
+#line 136 "../../bc/bc.y" /* yacc.c:1646 */
+ { run_code (); }
+#line 1565 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 6:
+#line 138 "../../bc/bc.y" /* yacc.c:1646 */
+ {
yyerrok;
init_gen ();
- ;
- break;}
-case 7:
-#line 130 "bc.y"
-{ warn ("newline not allowed"); ;
- break;}
-case 8:
-#line 133 "bc.y"
-{ yyval.i_value = 0; ;
- break;}
-case 12:
-#line 139 "bc.y"
-{ yyval.i_value = 0; ;
- break;}
-case 19:
-#line 148 "bc.y"
-{ yyval.i_value = yyvsp[0].i_value; ;
- break;}
-case 20:
-#line 151 "bc.y"
-{ warranty (""); ;
- break;}
-case 21:
-#line 153 "bc.y"
-{ limits (); ;
- break;}
-case 22:
-#line 155 "bc.y"
-{
- if (yyvsp[0].i_value & 2)
- warn ("comparison in expression");
- if (yyvsp[0].i_value & 1)
+ }
+#line 1574 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 8:
+#line 145 "../../bc/bc.y" /* yacc.c:1646 */
+ { ct_warn ("newline not allowed"); }
+#line 1580 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 9:
+#line 148 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = 0; }
+#line 1586 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 13:
+#line 154 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = 0; }
+#line 1592 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 20:
+#line 163 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = (yyvsp[0].i_value); }
+#line 1598 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 21:
+#line 166 "../../bc/bc.y" /* yacc.c:1646 */
+ { warranty (""); }
+#line 1604 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 22:
+#line 168 "../../bc/bc.y" /* yacc.c:1646 */
+ { limits (); }
+#line 1610 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 23:
+#line 170 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].i_value) & EX_COMP)
+ ct_warn ("comparison in expression");
+ if ((yyvsp[0].i_value) & EX_REG)
generate ("W");
else
generate ("p");
- ;
- break;}
-case 23:
-#line 164 "bc.y"
-{
- yyval.i_value = 0;
+ }
+#line 1623 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 24:
+#line 179 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyval.i_value) = 0;
generate ("w");
- generate (yyvsp[0].s_value);
- free (yyvsp[0].s_value);
- ;
- break;}
-case 24:
-#line 171 "bc.y"
-{
+ generate ((yyvsp[0].s_value));
+ free ((yyvsp[0].s_value));
+ }
+#line 1634 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 25:
+#line 186 "../../bc/bc.y" /* yacc.c:1646 */
+ {
if (break_label == 0)
yyerror ("Break outside a for/while");
else
{
- sprintf (genstr, "J%1d:", break_label);
+ snprintf (genstr, genlen, "J%1d:",
+ break_label);
generate (genstr);
}
- ;
- break;}
-case 25:
-#line 181 "bc.y"
-{
- warn ("Continue statement");
+ }
+#line 1649 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 26:
+#line 197 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ ct_warn ("Continue statement");
if (continue_label == 0)
yyerror ("Continue outside a for");
else
{
- sprintf (genstr, "J%1d:", continue_label);
+ snprintf (genstr, genlen, "J%1d:",
+ continue_label);
generate (genstr);
}
- ;
- break;}
-case 26:
-#line 192 "bc.y"
-{ exit (0); ;
- break;}
-case 27:
-#line 194 "bc.y"
-{ generate ("h"); ;
- break;}
-case 28:
-#line 196 "bc.y"
-{ generate ("R"); ;
- break;}
-case 29:
-#line 198 "bc.y"
-{
- yyvsp[0].i_value = break_label;
+ }
+#line 1665 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 27:
+#line 209 "../../bc/bc.y" /* yacc.c:1646 */
+ { bc_exit (0); }
+#line 1671 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 28:
+#line 211 "../../bc/bc.y" /* yacc.c:1646 */
+ { generate ("h"); }
+#line 1677 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 29:
+#line 213 "../../bc/bc.y" /* yacc.c:1646 */
+ { generate ("R"); }
+#line 1683 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 30:
+#line 215 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyvsp[0].i_value) = break_label;
break_label = next_label++;
- ;
- break;}
-case 30:
-#line 203 "bc.y"
-{
- if (yyvsp[-1].i_value & 2)
- warn ("Comparison in first for expression");
- if (yyvsp[-1].i_value >= 0)
+ }
+#line 1692 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 31:
+#line 220 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[-1].i_value) & EX_COMP)
+ ct_warn ("Comparison in first for expression");
+ if ((yyvsp[-1].i_value) & EX_VOID)
+ yyerror ("first expression is void");
+ if (!((yyvsp[-1].i_value) & EX_EMPTY))
generate ("p");
- yyvsp[-1].i_value = next_label++;
- sprintf (genstr, "N%1d:", yyvsp[-1].i_value);
+ (yyvsp[-1].i_value) = next_label++;
+ snprintf (genstr, genlen, "N%1d:", (yyvsp[-1].i_value));
generate (genstr);
- ;
- break;}
-case 31:
-#line 213 "bc.y"
-{
- if (yyvsp[-1].i_value < 0) generate ("1");
- yyvsp[-1].i_value = next_label++;
- sprintf (genstr, "B%1d:J%1d:", yyvsp[-1].i_value, break_label);
+ }
+#line 1708 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 32:
+#line 232 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[-1].i_value) & EX_VOID)
+ yyerror ("second expression is void");
+ if ((yyvsp[-1].i_value) & EX_EMPTY ) generate ("1");
+ (yyvsp[-1].i_value) = next_label++;
+ snprintf (genstr, genlen, "B%1d:J%1d:", (yyvsp[-1].i_value),
+ break_label);
generate (genstr);
- yyval.i_value = continue_label;
+ (yyval.i_value) = continue_label;
continue_label = next_label++;
- sprintf (genstr, "N%1d:", continue_label);
+ snprintf (genstr, genlen, "N%1d:",
+ continue_label);
generate (genstr);
- ;
- break;}
-case 32:
-#line 224 "bc.y"
-{
- if (yyvsp[-1].i_value & 2 )
- warn ("Comparison in third for expression");
- if (yyvsp[-1].i_value & 16)
- sprintf (genstr, "J%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value);
+ }
+#line 1727 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 33:
+#line 247 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[-1].i_value) & EX_COMP)
+ ct_warn ("Comparison in third for expression");
+ if ((yyvsp[-1].i_value) & EX_VOID)
+ yyerror ("third expression is void");
+ if ((yyvsp[-1].i_value) & EX_EMPTY)
+ snprintf (genstr, genlen, "J%1d:N%1d:", (yyvsp[-7].i_value), (yyvsp[-4].i_value));
else
- sprintf (genstr, "pJ%1d:N%1d:", yyvsp[-7].i_value, yyvsp[-4].i_value);
+ snprintf (genstr, genlen, "pJ%1d:N%1d:", (yyvsp[-7].i_value), (yyvsp[-4].i_value));
generate (genstr);
- ;
- break;}
-case 33:
-#line 234 "bc.y"
-{
- sprintf (genstr, "J%1d:N%1d:",
+ }
+#line 1743 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 34:
+#line 259 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ snprintf (genstr, genlen, "J%1d:N%1d:",
continue_label, break_label);
generate (genstr);
- break_label = yyvsp[-13].i_value;
- continue_label = yyvsp[-5].i_value;
- ;
- break;}
-case 34:
-#line 242 "bc.y"
-{
- yyvsp[-1].i_value = if_label;
+ break_label = (yyvsp[-13].i_value);
+ continue_label = (yyvsp[-5].i_value);
+ }
+#line 1755 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 35:
+#line 267 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[-1].i_value) & EX_VOID)
+ yyerror ("void expression");
+ (yyvsp[-1].i_value) = if_label;
if_label = next_label++;
- sprintf (genstr, "Z%1d:", if_label);
+ snprintf (genstr, genlen, "Z%1d:", if_label);
generate (genstr);
- ;
- break;}
-case 35:
-#line 249 "bc.y"
-{
- sprintf (genstr, "N%1d:", if_label);
+ }
+#line 1768 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 36:
+#line 276 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ snprintf (genstr, genlen, "N%1d:", if_label);
generate (genstr);
- if_label = yyvsp[-5].i_value;
- ;
- break;}
-case 36:
-#line 255 "bc.y"
-{
- yyvsp[0].i_value = next_label++;
- sprintf (genstr, "N%1d:", yyvsp[0].i_value);
+ if_label = (yyvsp[-5].i_value);
+ }
+#line 1778 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 37:
+#line 282 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyvsp[0].i_value) = continue_label;
+ continue_label = next_label++;
+ snprintf (genstr, genlen, "N%1d:",
+ continue_label);
generate (genstr);
- ;
- break;}
-case 37:
-#line 261 "bc.y"
-{
- yyvsp[0].i_value = break_label;
+ }
+#line 1790 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 38:
+#line 290 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].i_value) & EX_VOID)
+ yyerror ("void expression");
+ (yyvsp[0].i_value) = break_label;
break_label = next_label++;
- sprintf (genstr, "Z%1d:", break_label);
+ snprintf (genstr, genlen, "Z%1d:", break_label);
generate (genstr);
- ;
- break;}
-case 38:
-#line 268 "bc.y"
-{
- sprintf (genstr, "J%1d:N%1d:", yyvsp[-7].i_value, break_label);
+ }
+#line 1803 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 39:
+#line 299 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ snprintf (genstr, genlen, "J%1d:N%1d:",
+ continue_label, break_label);
generate (genstr);
- break_label = yyvsp[-4].i_value;
- ;
- break;}
-case 39:
-#line 274 "bc.y"
-{ yyval.i_value = 0; ;
- break;}
-case 40:
-#line 276 "bc.y"
-{ warn ("print statement"); ;
- break;}
-case 44:
-#line 283 "bc.y"
-{
+ break_label = (yyvsp[-4].i_value);
+ continue_label = (yyvsp[-7].i_value);
+ }
+#line 1815 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 40:
+#line 307 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = 0; }
+#line 1821 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 41:
+#line 309 "../../bc/bc.y" /* yacc.c:1646 */
+ { ct_warn ("print statement"); }
+#line 1827 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 45:
+#line 316 "../../bc/bc.y" /* yacc.c:1646 */
+ {
generate ("O");
- generate (yyvsp[0].s_value);
- free (yyvsp[0].s_value);
- ;
- break;}
-case 45:
-#line 289 "bc.y"
-{ generate ("P"); ;
- break;}
-case 47:
-#line 293 "bc.y"
-{
- warn ("else clause in if statement");
- yyvsp[0].i_value = next_label++;
- sprintf (genstr, "J%d:N%1d:", yyvsp[0].i_value, if_label);
+ generate ((yyvsp[0].s_value));
+ free ((yyvsp[0].s_value));
+ }
+#line 1837 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 46:
+#line 322 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].i_value) & EX_VOID)
+ yyerror ("void expression in print");
+ generate ("P");
+ }
+#line 1847 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 48:
+#line 330 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ ct_warn ("else clause in if statement");
+ (yyvsp[0].i_value) = next_label++;
+ snprintf (genstr, genlen, "J%d:N%1d:", (yyvsp[0].i_value),
+ if_label);
generate (genstr);
- if_label = yyvsp[0].i_value;
- ;
- break;}
-case 49:
-#line 303 "bc.y"
-{
+ if_label = (yyvsp[0].i_value);
+ }
+#line 1860 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 50:
+#line 342 "../../bc/bc.y" /* yacc.c:1646 */
+ { char *params, *autos;
/* Check auto list against parameter list? */
- check_params (yyvsp[-5].a_value,yyvsp[0].a_value);
- sprintf (genstr, "F%d,%s.%s[",
- lookup(yyvsp[-7].s_value,FUNCTDEF),
- arg_str (yyvsp[-5].a_value), arg_str (yyvsp[0].a_value));
+ check_params ((yyvsp[-5].a_value),(yyvsp[0].a_value));
+ params = arg_str ((yyvsp[-5].a_value));
+ autos = arg_str ((yyvsp[0].a_value));
+ set_genstr_size (30 + strlen (params)
+ + strlen (autos));
+ cur_func = lookup((yyvsp[-7].s_value),FUNCTDEF);
+ snprintf (genstr, genlen, "F%d,%s.%s[", cur_func,
+ params, autos);
generate (genstr);
- free_args (yyvsp[-5].a_value);
- free_args (yyvsp[0].a_value);
- yyvsp[-8].i_value = next_label;
+ functions[cur_func].f_void = (yyvsp[-8].i_value);
+ free_args ((yyvsp[-5].a_value));
+ free_args ((yyvsp[0].a_value));
+ (yyvsp[-9].i_value) = next_label;
next_label = 1;
- ;
- break;}
-case 50:
-#line 316 "bc.y"
-{
+ }
+#line 1882 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 51:
+#line 360 "../../bc/bc.y" /* yacc.c:1646 */
+ {
generate ("0R]");
- next_label = yyvsp[-11].i_value;
- ;
- break;}
-case 51:
-#line 322 "bc.y"
-{ yyval.a_value = NULL; ;
- break;}
-case 53:
-#line 326 "bc.y"
-{ yyval.a_value = NULL; ;
- break;}
-case 54:
-#line 328 "bc.y"
-{ yyval.a_value = yyvsp[-1].a_value; ;
- break;}
-case 55:
-#line 330 "bc.y"
-{ yyval.a_value = yyvsp[-1].a_value; ;
- break;}
-case 56:
-#line 333 "bc.y"
-{ yyval.a_value = nextarg (NULL, lookup (yyvsp[0].s_value,SIMPLE), FALSE);;
- break;}
-case 57:
-#line 335 "bc.y"
-{ yyval.a_value = nextarg (NULL, lookup (yyvsp[-2].s_value,ARRAY), FALSE); ;
- break;}
-case 58:
-#line 337 "bc.y"
-{ yyval.a_value = nextarg (NULL, lookup (yyvsp[-2].s_value,ARRAY), TRUE); ;
- break;}
-case 59:
-#line 339 "bc.y"
-{ yyval.a_value = nextarg (yyvsp[-2].a_value, lookup (yyvsp[0].s_value,SIMPLE), FALSE); ;
- break;}
-case 60:
-#line 341 "bc.y"
-{ yyval.a_value = nextarg (yyvsp[-4].a_value, lookup (yyvsp[-2].s_value,ARRAY), FALSE); ;
- break;}
-case 61:
-#line 343 "bc.y"
-{ yyval.a_value = nextarg (yyvsp[-5].a_value, lookup (yyvsp[-2].s_value,ARRAY), TRUE); ;
- break;}
-case 62:
-#line 346 "bc.y"
-{ yyval.a_value = NULL; ;
- break;}
-case 64:
-#line 350 "bc.y"
-{
- if (yyvsp[0].i_value & 2) warn ("comparison in argument");
- yyval.a_value = nextarg (NULL,0,FALSE);
- ;
- break;}
-case 65:
-#line 355 "bc.y"
-{
- sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY));
+ next_label = (yyvsp[-12].i_value);
+ cur_func = -1;
+ }
+#line 1892 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 52:
+#line 367 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = 0; }
+#line 1898 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 53:
+#line 369 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyval.i_value) = 1;
+ ct_warn ("void functions");
+ }
+#line 1907 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 54:
+#line 375 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = NULL; }
+#line 1913 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 56:
+#line 379 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = NULL; }
+#line 1919 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 57:
+#line 381 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = (yyvsp[-1].a_value); }
+#line 1925 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 58:
+#line 383 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = (yyvsp[-1].a_value); }
+#line 1931 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 59:
+#line 386 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = nextarg (NULL, lookup ((yyvsp[0].s_value),SIMPLE), FALSE);}
+#line 1937 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 60:
+#line 388 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = nextarg (NULL, lookup ((yyvsp[-2].s_value),ARRAY), FALSE); }
+#line 1943 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 61:
+#line 390 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = nextarg (NULL, lookup ((yyvsp[-2].s_value),ARRAY), TRUE);
+ ct_warn ("Call by variable arrays");
+ }
+#line 1951 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 62:
+#line 394 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = nextarg (NULL, lookup ((yyvsp[-2].s_value),ARRAY), TRUE);
+ ct_warn ("Call by variable arrays");
+ }
+#line 1959 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 63:
+#line 398 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = nextarg ((yyvsp[-2].a_value), lookup ((yyvsp[0].s_value),SIMPLE), FALSE); }
+#line 1965 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 64:
+#line 400 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = nextarg ((yyvsp[-4].a_value), lookup ((yyvsp[-2].s_value),ARRAY), FALSE); }
+#line 1971 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 65:
+#line 402 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = nextarg ((yyvsp[-5].a_value), lookup ((yyvsp[-2].s_value),ARRAY), TRUE);
+ ct_warn ("Call by variable arrays");
+ }
+#line 1979 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 66:
+#line 406 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = nextarg ((yyvsp[-5].a_value), lookup ((yyvsp[-2].s_value),ARRAY), TRUE);
+ ct_warn ("Call by variable arrays");
+ }
+#line 1987 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 67:
+#line 411 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.a_value) = NULL; }
+#line 1993 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 69:
+#line 415 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].i_value) & EX_COMP)
+ ct_warn ("comparison in argument");
+ if ((yyvsp[0].i_value) & EX_VOID)
+ yyerror ("void argument");
+ (yyval.a_value) = nextarg (NULL,0,FALSE);
+ }
+#line 2005 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 70:
+#line 423 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ snprintf (genstr, genlen, "K%d:",
+ -lookup ((yyvsp[-2].s_value),ARRAY));
generate (genstr);
- yyval.a_value = nextarg (NULL,1,FALSE);
- ;
- break;}
-case 66:
-#line 361 "bc.y"
-{
- if (yyvsp[0].i_value & 2) warn ("comparison in argument");
- yyval.a_value = nextarg (yyvsp[-2].a_value,0,FALSE);
- ;
- break;}
-case 67:
-#line 366 "bc.y"
-{
- sprintf (genstr, "K%d:", -lookup (yyvsp[-2].s_value,ARRAY));
+ (yyval.a_value) = nextarg (NULL,1,FALSE);
+ }
+#line 2016 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 71:
+#line 430 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].i_value) & EX_COMP)
+ ct_warn ("comparison in argument");
+ if ((yyvsp[0].i_value) & EX_VOID)
+ yyerror ("void argument");
+ (yyval.a_value) = nextarg ((yyvsp[-2].a_value),0,FALSE);
+ }
+#line 2028 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 72:
+#line 438 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ snprintf (genstr, genlen, "K%d:",
+ -lookup ((yyvsp[-2].s_value),ARRAY));
generate (genstr);
- yyval.a_value = nextarg (yyvsp[-4].a_value,1,FALSE);
- ;
- break;}
-case 68:
-#line 382 "bc.y"
-{
- yyval.i_value = 16;
- warn ("Missing expression in for statement");
- ;
- break;}
-case 70:
-#line 389 "bc.y"
-{
- yyval.i_value = 0;
+ (yyval.a_value) = nextarg ((yyvsp[-4].a_value),1,FALSE);
+ }
+#line 2039 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 73:
+#line 456 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyval.i_value) = EX_EMPTY;
+ ct_warn ("Missing expression in for statement");
+ }
+#line 2048 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 75:
+#line 463 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyval.i_value) = 0;
generate ("0");
- ;
- break;}
-case 71:
-#line 394 "bc.y"
-{
- if (yyvsp[0].i_value & 2)
- warn ("comparison in return expresion");
- if (!(yyvsp[0].i_value & 4))
- warn ("return expression requires parenthesis");
- ;
- break;}
-case 72:
-#line 402 "bc.y"
-{
- if (yyvsp[0].c_value != '=')
+ if (cur_func == -1)
+ yyerror("Return outside of a function.");
+ }
+#line 2059 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 76:
+#line 470 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].i_value) & EX_COMP)
+ ct_warn ("comparison in return expresion");
+ if (!((yyvsp[0].i_value) & EX_PAREN))
+ ct_warn ("return expression requires parenthesis");
+ if ((yyvsp[0].i_value) & EX_VOID)
+ yyerror("return requires non-void expression");
+ if (cur_func == -1)
+ yyerror("Return outside of a function.");
+ else if (functions[cur_func].f_void)
+ yyerror("Return expression in a void function.");
+ }
+#line 2076 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 77:
+#line 484 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].c_value) != '=')
{
- if (yyvsp[-1].i_value < 0)
- sprintf (genstr, "DL%d:", -yyvsp[-1].i_value);
+ if ((yyvsp[-1].i_value) < 0)
+ snprintf (genstr, genlen, "DL%d:", -(yyvsp[-1].i_value));
else
- sprintf (genstr, "l%d:", yyvsp[-1].i_value);
+ snprintf (genstr, genlen, "l%d:", (yyvsp[-1].i_value));
generate (genstr);
}
- ;
- break;}
-case 73:
-#line 413 "bc.y"
-{
- if (yyvsp[0].i_value & 2) warn("comparison in assignment");
- if (yyvsp[-2].c_value != '=')
+ }
+#line 2091 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 78:
+#line 495 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].i_value) & EX_ASSGN)
+ ct_warn("comparison in assignment");
+ if ((yyvsp[0].i_value) & EX_VOID)
+ yyerror("Assignment of a void expression");
+ if ((yyvsp[-2].c_value) != '=')
{
- sprintf (genstr, "%c", yyvsp[-2].c_value);
+ snprintf (genstr, genlen, "%c", (yyvsp[-2].c_value));
generate (genstr);
}
- if (yyvsp[-3].i_value < 0)
- sprintf (genstr, "S%d:", -yyvsp[-3].i_value);
+ if ((yyvsp[-3].i_value) < 0)
+ snprintf (genstr, genlen, "S%d:", -(yyvsp[-3].i_value));
else
- sprintf (genstr, "s%d:", yyvsp[-3].i_value);
+ snprintf (genstr, genlen, "s%d:", (yyvsp[-3].i_value));
generate (genstr);
- yyval.i_value = 0;
- ;
- break;}
-case 74:
-#line 429 "bc.y"
-{
- warn("&& operator");
- yyvsp[0].i_value = next_label++;
- sprintf (genstr, "DZ%d:p", yyvsp[0].i_value);
+ (yyval.i_value) = EX_ASSGN;
+ }
+#line 2113 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 79:
+#line 513 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ ct_warn("&& operator");
+ (yyvsp[0].i_value) = next_label++;
+ snprintf (genstr, genlen, "DZ%d:p", (yyvsp[0].i_value));
generate (genstr);
- ;
- break;}
-case 75:
-#line 436 "bc.y"
-{
- sprintf (genstr, "DZ%d:p1N%d:", yyvsp[-2].i_value, yyvsp[-2].i_value);
+ }
+#line 2124 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 80:
+#line 520 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if (((yyvsp[-3].i_value) & EX_VOID) || ((yyvsp[0].i_value) & EX_VOID))
+ yyerror ("void expression with &&");
+ snprintf (genstr, genlen, "DZ%d:p1N%d:", (yyvsp[-2].i_value), (yyvsp[-2].i_value));
generate (genstr);
- yyval.i_value = (yyvsp[-3].i_value | yyvsp[0].i_value) & ~4;
- ;
- break;}
-case 76:
-#line 442 "bc.y"
-{
- warn("|| operator");
- yyvsp[0].i_value = next_label++;
- sprintf (genstr, "B%d:", yyvsp[0].i_value);
+ (yyval.i_value) = ((yyvsp[-3].i_value) | (yyvsp[0].i_value)) & ~EX_PAREN;
+ }
+#line 2136 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 81:
+#line 528 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ ct_warn("|| operator");
+ (yyvsp[0].i_value) = next_label++;
+ snprintf (genstr, genlen, "B%d:", (yyvsp[0].i_value));
generate (genstr);
- ;
- break;}
-case 77:
-#line 449 "bc.y"
-{
+ }
+#line 2147 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 82:
+#line 535 "../../bc/bc.y" /* yacc.c:1646 */
+ {
int tmplab;
+ if (((yyvsp[-3].i_value) & EX_VOID) || ((yyvsp[0].i_value) & EX_VOID))
+ yyerror ("void expression with ||");
tmplab = next_label++;
- sprintf (genstr, "B%d:0J%d:N%d:1N%d:",
- yyvsp[-2].i_value, tmplab, yyvsp[-2].i_value, tmplab);
+ snprintf (genstr, genlen, "B%d:0J%d:N%d:1N%d:",
+ (yyvsp[-2].i_value), tmplab, (yyvsp[-2].i_value), tmplab);
generate (genstr);
- yyval.i_value = (yyvsp[-3].i_value | yyvsp[0].i_value) & ~4;
- ;
- break;}
-case 78:
-#line 458 "bc.y"
-{
- yyval.i_value = yyvsp[0].i_value & ~4;
- warn("! operator");
+ (yyval.i_value) = ((yyvsp[-3].i_value) | (yyvsp[0].i_value)) & ~EX_PAREN;
+ }
+#line 2162 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 83:
+#line 546 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].i_value) & EX_VOID)
+ yyerror ("void expression with !");
+ (yyval.i_value) = (yyvsp[0].i_value) & ~EX_PAREN;
+ ct_warn("! operator");
generate ("!");
- ;
- break;}
-case 79:
-#line 464 "bc.y"
-{
- yyval.i_value = 3;
- switch (*(yyvsp[-1].s_value))
+ }
+#line 2174 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 84:
+#line 554 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if (((yyvsp[-2].i_value) & EX_VOID) || ((yyvsp[0].i_value) & EX_VOID))
+ yyerror ("void expression with comparison");
+ (yyval.i_value) = EX_REG | EX_COMP;
+ switch (*((yyvsp[-1].s_value)))
{
case '=':
generate ("=");
@@ -1436,451 +2190,563 @@ case 79:
break;
case '<':
- if (yyvsp[-1].s_value[1] == '=')
+ if ((yyvsp[-1].s_value)[1] == '=')
generate ("{");
else
generate ("<");
break;
case '>':
- if (yyvsp[-1].s_value[1] == '=')
+ if ((yyvsp[-1].s_value)[1] == '=')
generate ("}");
else
generate (">");
break;
}
- ;
- break;}
-case 80:
-#line 492 "bc.y"
-{
+ free((yyvsp[-1].s_value));
+ }
+#line 2209 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 85:
+#line 585 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if (((yyvsp[-2].i_value) & EX_VOID) || ((yyvsp[0].i_value) & EX_VOID))
+ yyerror ("void expression with +");
generate ("+");
- yyval.i_value = (yyvsp[-2].i_value | yyvsp[0].i_value) & ~4;
- ;
- break;}
-case 81:
-#line 497 "bc.y"
-{
+ (yyval.i_value) = ((yyvsp[-2].i_value) | (yyvsp[0].i_value)) & ~EX_PAREN;
+ }
+#line 2220 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 86:
+#line 592 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if (((yyvsp[-2].i_value) & EX_VOID) || ((yyvsp[0].i_value) & EX_VOID))
+ yyerror ("void expression with -");
generate ("-");
- yyval.i_value = (yyvsp[-2].i_value | yyvsp[0].i_value) & ~4;
- ;
- break;}
-case 82:
-#line 502 "bc.y"
-{
+ (yyval.i_value) = ((yyvsp[-2].i_value) | (yyvsp[0].i_value)) & ~EX_PAREN;
+ }
+#line 2231 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 87:
+#line 599 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if (((yyvsp[-2].i_value) & EX_VOID) || ((yyvsp[0].i_value) & EX_VOID))
+ yyerror ("void expression with *");
generate ("*");
- yyval.i_value = (yyvsp[-2].i_value | yyvsp[0].i_value) & ~4;
- ;
- break;}
-case 83:
-#line 507 "bc.y"
-{
+ (yyval.i_value) = ((yyvsp[-2].i_value) | (yyvsp[0].i_value)) & ~EX_PAREN;
+ }
+#line 2242 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 88:
+#line 606 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if (((yyvsp[-2].i_value) & EX_VOID) || ((yyvsp[0].i_value) & EX_VOID))
+ yyerror ("void expression with /");
generate ("/");
- yyval.i_value = (yyvsp[-2].i_value | yyvsp[0].i_value) & ~4;
- ;
- break;}
-case 84:
-#line 512 "bc.y"
-{
+ (yyval.i_value) = ((yyvsp[-2].i_value) | (yyvsp[0].i_value)) & ~EX_PAREN;
+ }
+#line 2253 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 89:
+#line 613 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if (((yyvsp[-2].i_value) & EX_VOID) || ((yyvsp[0].i_value) & EX_VOID))
+ yyerror ("void expression with %");
generate ("%");
- yyval.i_value = (yyvsp[-2].i_value | yyvsp[0].i_value) & ~4;
- ;
- break;}
-case 85:
-#line 517 "bc.y"
-{
+ (yyval.i_value) = ((yyvsp[-2].i_value) | (yyvsp[0].i_value)) & ~EX_PAREN;
+ }
+#line 2264 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 90:
+#line 620 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if (((yyvsp[-2].i_value) & EX_VOID) || ((yyvsp[0].i_value) & EX_VOID))
+ yyerror ("void expression with ^");
generate ("^");
- yyval.i_value = (yyvsp[-2].i_value | yyvsp[0].i_value) & ~4;
- ;
- break;}
-case 86:
-#line 522 "bc.y"
-{
+ (yyval.i_value) = ((yyvsp[-2].i_value) | (yyvsp[0].i_value)) & ~EX_PAREN;
+ }
+#line 2275 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 91:
+#line 627 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[0].i_value) & EX_VOID)
+ yyerror ("void expression with unary -");
generate ("n");
- yyval.i_value = yyvsp[0].i_value & ~4;
- ;
- break;}
-case 87:
-#line 527 "bc.y"
-{
- yyval.i_value = 1;
- if (yyvsp[0].i_value < 0)
- sprintf (genstr, "L%d:", -yyvsp[0].i_value);
+ (yyval.i_value) = (yyvsp[0].i_value) & ~EX_PAREN;
+ }
+#line 2286 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 92:
+#line 634 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyval.i_value) = EX_REG;
+ if ((yyvsp[0].i_value) < 0)
+ snprintf (genstr, genlen, "L%d:", -(yyvsp[0].i_value));
else
- sprintf (genstr, "l%d:", yyvsp[0].i_value);
+ snprintf (genstr, genlen, "l%d:", (yyvsp[0].i_value));
generate (genstr);
- ;
- break;}
-case 88:
-#line 536 "bc.y"
-{
- int len = strlen(yyvsp[0].s_value);
- yyval.i_value = 1;
- if (len == 1 && *yyvsp[0].s_value == '0')
+ }
+#line 2299 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 93:
+#line 643 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ int len = strlen((yyvsp[0].s_value));
+ (yyval.i_value) = EX_REG;
+ if (len == 1 && *(yyvsp[0].s_value) == '0')
generate ("0");
- else if (len == 1 && *yyvsp[0].s_value == '1')
+ else if (len == 1 && *(yyvsp[0].s_value) == '1')
generate ("1");
else
{
generate ("K");
- generate (yyvsp[0].s_value);
+ generate ((yyvsp[0].s_value));
generate (":");
}
- free (yyvsp[0].s_value);
- ;
- break;}
-case 89:
-#line 552 "bc.y"
-{ yyval.i_value = yyvsp[-1].i_value | 5; ;
- break;}
-case 90:
-#line 554 "bc.y"
-{
- yyval.i_value = 1;
- if (yyvsp[-1].a_value != NULL)
- {
- sprintf (genstr, "C%d,%s:",
- lookup (yyvsp[-3].s_value,FUNCT),
- call_str (yyvsp[-1].a_value));
- free_args (yyvsp[-1].a_value);
+ free ((yyvsp[0].s_value));
+ }
+#line 2319 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 94:
+#line 659 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[-1].i_value) & EX_VOID)
+ yyerror ("void expression in parenthesis");
+ (yyval.i_value) = (yyvsp[-1].i_value) | EX_REG | EX_PAREN;
+ }
+#line 2329 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 95:
+#line 665 "../../bc/bc.y" /* yacc.c:1646 */
+ { int fn;
+ fn = lookup ((yyvsp[-3].s_value),FUNCT);
+ if (functions[fn].f_void)
+ (yyval.i_value) = EX_VOID;
+ else
+ (yyval.i_value) = EX_REG;
+ if ((yyvsp[-1].a_value) != NULL)
+ { char *params = call_str ((yyvsp[-1].a_value));
+ set_genstr_size (20 + strlen (params));
+ snprintf (genstr, genlen, "C%d,%s:", fn,
+ params);
+ free_args ((yyvsp[-1].a_value));
}
else
{
- sprintf (genstr, "C%d:", lookup (yyvsp[-3].s_value,FUNCT));
+ snprintf (genstr, genlen, "C%d:", fn);
}
generate (genstr);
- ;
- break;}
-case 91:
-#line 570 "bc.y"
-{
- yyval.i_value = 1;
- if (yyvsp[0].i_value < 0)
+ }
+#line 2353 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 96:
+#line 685 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyval.i_value) = EX_REG;
+ if ((yyvsp[0].i_value) < 0)
{
- if (yyvsp[-1].c_value == '+')
- sprintf (genstr, "DA%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value);
+ if ((yyvsp[-1].c_value) == '+')
+ snprintf (genstr, genlen, "DA%d:L%d:", -(yyvsp[0].i_value), -(yyvsp[0].i_value));
else
- sprintf (genstr, "DM%d:L%d:", -yyvsp[0].i_value, -yyvsp[0].i_value);
+ snprintf (genstr, genlen, "DM%d:L%d:", -(yyvsp[0].i_value), -(yyvsp[0].i_value));
}
else
{
- if (yyvsp[-1].c_value == '+')
- sprintf (genstr, "i%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value);
+ if ((yyvsp[-1].c_value) == '+')
+ snprintf (genstr, genlen, "i%d:l%d:", (yyvsp[0].i_value), (yyvsp[0].i_value));
else
- sprintf (genstr, "d%d:l%d:", yyvsp[0].i_value, yyvsp[0].i_value);
+ snprintf (genstr, genlen, "d%d:l%d:", (yyvsp[0].i_value), (yyvsp[0].i_value));
}
generate (genstr);
- ;
- break;}
-case 92:
-#line 589 "bc.y"
-{
- yyval.i_value = 1;
- if (yyvsp[-1].i_value < 0)
+ }
+#line 2376 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 97:
+#line 704 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ (yyval.i_value) = EX_REG;
+ if ((yyvsp[-1].i_value) < 0)
{
- sprintf (genstr, "DL%d:x", -yyvsp[-1].i_value);
+ snprintf (genstr, genlen, "DL%d:x", -(yyvsp[-1].i_value));
generate (genstr);
- if (yyvsp[0].c_value == '+')
- sprintf (genstr, "A%d:", -yyvsp[-1].i_value);
+ if ((yyvsp[0].c_value) == '+')
+ snprintf (genstr, genlen, "A%d:", -(yyvsp[-1].i_value));
else
- sprintf (genstr, "M%d:", -yyvsp[-1].i_value);
+ snprintf (genstr, genlen, "M%d:", -(yyvsp[-1].i_value));
}
else
{
- sprintf (genstr, "l%d:", yyvsp[-1].i_value);
+ snprintf (genstr, genlen, "l%d:", (yyvsp[-1].i_value));
generate (genstr);
- if (yyvsp[0].c_value == '+')
- sprintf (genstr, "i%d:", yyvsp[-1].i_value);
+ if ((yyvsp[0].c_value) == '+')
+ snprintf (genstr, genlen, "i%d:", (yyvsp[-1].i_value));
else
- sprintf (genstr, "d%d:", yyvsp[-1].i_value);
+ snprintf (genstr, genlen, "d%d:", (yyvsp[-1].i_value));
}
generate (genstr);
- ;
- break;}
-case 93:
-#line 612 "bc.y"
-{ generate ("cL"); yyval.i_value = 1;;
- break;}
-case 94:
-#line 614 "bc.y"
-{ generate ("cR"); yyval.i_value = 1;;
- break;}
-case 95:
-#line 616 "bc.y"
-{ generate ("cS"); yyval.i_value = 1;;
- break;}
-case 96:
-#line 618 "bc.y"
-{
- warn ("read function");
- generate ("cI"); yyval.i_value = 1;
- ;
- break;}
-case 97:
-#line 624 "bc.y"
-{ yyval.i_value = lookup(yyvsp[0].s_value,SIMPLE); ;
- break;}
-case 98:
-#line 626 "bc.y"
-{
- if (yyvsp[-1].i_value > 1) warn("comparison in subscript");
- yyval.i_value = lookup(yyvsp[-3].s_value,ARRAY);
- ;
- break;}
-case 99:
-#line 631 "bc.y"
-{ yyval.i_value = 0; ;
- break;}
-case 100:
-#line 633 "bc.y"
-{ yyval.i_value = 1; ;
- break;}
-case 101:
-#line 635 "bc.y"
-{ yyval.i_value = 2; ;
- break;}
-case 102:
-#line 637 "bc.y"
-{ yyval.i_value = 3;
- warn ("History variable");
- ;
- break;}
-case 103:
-#line 641 "bc.y"
-{ yyval.i_value = 4;
- warn ("Last variable");
- ;
- break;}
-case 104:
-#line 647 "bc.y"
-{ warn ("End of line required"); ;
- break;}
-case 106:
-#line 650 "bc.y"
-{ warn ("Too many end of lines"); ;
- break;}
-}
- /* the action file gets copied in in place of this dollarsign */
-#line 542 "/usr/gnu/share/bison.simple"
-
- yyvsp -= yylen;
- yyssp -= yylen;
-#ifdef YYLSP_NEEDED
- yylsp -= yylen;
-#endif
+ }
+#line 2403 "bc.c" /* yacc.c:1646 */
+ break;
-#if YYDEBUG != 0
- if (yydebug)
+ case 98:
+#line 727 "../../bc/bc.y" /* yacc.c:1646 */
{
- short *ssp1 = yyss - 1;
- fprintf (stderr, "state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
- }
-#endif
-
- *++yyvsp = yyval;
-
-#ifdef YYLSP_NEEDED
- yylsp++;
- if (yylen == 0)
+ if ((yyvsp[-1].i_value) & EX_VOID)
+ yyerror ("void expression in length()");
+ generate ("cL");
+ (yyval.i_value) = EX_REG;
+ }
+#line 2414 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 99:
+#line 734 "../../bc/bc.y" /* yacc.c:1646 */
{
- yylsp->first_line = yylloc.first_line;
- yylsp->first_column = yylloc.first_column;
- yylsp->last_line = (yylsp-1)->last_line;
- yylsp->last_column = (yylsp-1)->last_column;
- yylsp->text = 0;
- }
- else
+ if ((yyvsp[-1].i_value) & EX_VOID)
+ yyerror ("void expression in sqrt()");
+ generate ("cR");
+ (yyval.i_value) = EX_REG;
+ }
+#line 2425 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 100:
+#line 741 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[-1].i_value) & EX_VOID)
+ yyerror ("void expression in scale()");
+ generate ("cS");
+ (yyval.i_value) = EX_REG;
+ }
+#line 2436 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 101:
+#line 748 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ ct_warn ("read function");
+ generate ("cI");
+ (yyval.i_value) = EX_REG;
+ }
+#line 2446 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 102:
+#line 754 "../../bc/bc.y" /* yacc.c:1646 */
{
- yylsp->last_line = (yylsp+yylen-1)->last_line;
- yylsp->last_column = (yylsp+yylen-1)->last_column;
+ ct_warn ("random function");
+ generate ("cX");
+ (yyval.i_value) = EX_REG;
+ }
+#line 2456 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 103:
+#line 761 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = lookup((yyvsp[0].s_value),SIMPLE); }
+#line 2462 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 104:
+#line 763 "../../bc/bc.y" /* yacc.c:1646 */
+ {
+ if ((yyvsp[-1].i_value) & EX_VOID)
+ yyerror("void expression as subscript");
+ if ((yyvsp[-1].i_value) & EX_COMP)
+ ct_warn("comparison in subscript");
+ (yyval.i_value) = lookup((yyvsp[-3].s_value),ARRAY);
+ }
+#line 2474 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 105:
+#line 771 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = 0; }
+#line 2480 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 106:
+#line 773 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = 1; }
+#line 2486 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 107:
+#line 775 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = 2; }
+#line 2492 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 108:
+#line 777 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = 3;
+ ct_warn ("History variable");
+ }
+#line 2500 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 109:
+#line 781 "../../bc/bc.y" /* yacc.c:1646 */
+ { (yyval.i_value) = 4;
+ ct_warn ("Last variable");
+ }
+#line 2508 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 110:
+#line 787 "../../bc/bc.y" /* yacc.c:1646 */
+ { ct_warn ("End of line required"); }
+#line 2514 "bc.c" /* yacc.c:1646 */
+ break;
+
+ case 112:
+#line 790 "../../bc/bc.y" /* yacc.c:1646 */
+ { ct_warn ("Too many end of lines"); }
+#line 2520 "bc.c" /* yacc.c:1646 */
+ break;
+
+
+#line 2524 "bc.c" /* yacc.c:1646 */
+ default: break;
}
-#endif
+ /* User semantic actions sometimes alter yychar, and that requires
+ that yytoken be updated with the new translation. We take the
+ approach of translating immediately before every use of yytoken.
+ One alternative is translating here after every semantic action,
+ but that translation would be missed if the semantic action invokes
+ YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
+ if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
+ incorrect destructor might then be invoked immediately. In the
+ case of YYERROR or YYBACKUP, subsequent parser actions might lead
+ to an incorrect destructor call or verbose syntax error message
+ before the lookahead is translated. */
+ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
+
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
- /* Now "shift" the result of the reduction.
- Determine what state that goes to,
- based on the state we popped back to
- and the rule number reduced by. */
+ /* Now 'shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
yyn = yyr1[yyn];
- yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
- if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
- yystate = yydefgoto[yyn - YYNTBASE];
+ yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
-yyerrlab: /* here on detecting error */
- if (! yyerrstatus)
- /* If not already recovering from an error, report this error. */
+/*--------------------------------------.
+| yyerrlab -- here on detecting error. |
+`--------------------------------------*/
+yyerrlab:
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
+
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
{
++yynerrs;
-
-#ifdef YYERROR_VERBOSE
- yyn = yypact[yystate];
-
- if (yyn > YYFLAG && yyn < YYLAST)
- {
- int size = 0;
- char *msg;
- int x, count;
-
- count = 0;
- /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- size += strlen(yytname[x]) + 15, count++;
- msg = (char *) malloc(size + 15);
- if (msg != 0)
- {
- strcpy(msg, "parse error");
-
- if (count < 5)
- {
- count = 0;
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- {
- strcat(msg, count == 0 ? ", expecting `" : " or `");
- strcat(msg, yytname[x]);
- strcat(msg, "'");
- count++;
- }
- }
- yyerror(msg);
- free(msg);
- }
- else
- yyerror ("parse error; also virtual memory exceeded");
- }
- else
-#endif /* YYERROR_VERBOSE */
- yyerror("parse error");
+#if ! YYERROR_VERBOSE
+ yyerror (YY_("syntax error"));
+#else
+# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
+ yyssp, yytoken)
+ {
+ char const *yymsgp = YY_("syntax error");
+ int yysyntax_error_status;
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ if (yysyntax_error_status == 0)
+ yymsgp = yymsg;
+ else if (yysyntax_error_status == 1)
+ {
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+ yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
+ if (!yymsg)
+ {
+ yymsg = yymsgbuf;
+ yymsg_alloc = sizeof yymsgbuf;
+ yysyntax_error_status = 2;
+ }
+ else
+ {
+ yysyntax_error_status = YYSYNTAX_ERROR;
+ yymsgp = yymsg;
+ }
+ }
+ yyerror (yymsgp);
+ if (yysyntax_error_status == 2)
+ goto yyexhaustedlab;
+ }
+# undef YYSYNTAX_ERROR
+#endif
}
- goto yyerrlab1;
-yyerrlab1: /* here on error raised explicitly by an action */
+
if (yyerrstatus == 3)
{
- /* if just tried and failed to reuse lookahead token after an error, discard it. */
-
- /* return failure if at end of input */
- if (yychar == YYEOF)
- YYABORT;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
-#endif
-
- yychar = YYEMPTY;
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ if (yychar <= YYEOF)
+ {
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ YYABORT;
+ }
+ else
+ {
+ yydestruct ("Error: discarding",
+ yytoken, &yylval);
+ yychar = YYEMPTY;
+ }
}
- /* Else will try to reuse lookahead token
- after shifting the error token. */
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
- yyerrstatus = 3; /* Each real token shifted decrements this */
- goto yyerrhandle;
+/*---------------------------------------------------.
+| yyerrorlab -- error raised explicitly by YYERROR. |
+`---------------------------------------------------*/
+yyerrorlab:
-yyerrdefault: /* current state does not do anything special for the error token. */
+ /* Pacify compilers like GCC when the user code never invokes
+ YYERROR and the label yyerrorlab therefore never appears in user
+ code. */
+ if (/*CONSTCOND*/ 0)
+ goto yyerrorlab;
-#if 0
- /* This is wrong; only states that explicitly want error tokens
- should shift them. */
- yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
- if (yyn) goto yydefault;
-#endif
+ /* Do not reclaim the symbols of the rule whose action triggered
+ this YYERROR. */
+ YYPOPSTACK (yylen);
+ yylen = 0;
+ YY_STACK_PRINT (yyss, yyssp);
+ yystate = *yyssp;
+ goto yyerrlab1;
-yyerrpop: /* pop the current state because it cannot handle the error token */
- if (yyssp == yyss) YYABORT;
- yyvsp--;
- yystate = *--yyssp;
-#ifdef YYLSP_NEEDED
- yylsp--;
-#endif
+/*-------------------------------------------------------------.
+| yyerrlab1 -- common code for both syntax error and YYERROR. |
+`-------------------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
-#if YYDEBUG != 0
- if (yydebug)
+ for (;;)
{
- short *ssp1 = yyss - 1;
- fprintf (stderr, "Error: state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
+ yyn = yypact[yystate];
+ if (!yypact_value_is_default (yyn))
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+
+ yydestruct ("Error: popping",
+ yystos[yystate], yyvsp);
+ YYPOPSTACK (1);
+ yystate = *yyssp;
+ YY_STACK_PRINT (yyss, yyssp);
}
-#endif
-yyerrhandle:
+ YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+ *++yyvsp = yylval;
+ YY_IGNORE_MAYBE_UNINITIALIZED_END
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yyerrdefault;
- yyn += YYTERROR;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
- goto yyerrdefault;
+ /* Shift the error token. */
+ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
- yyn = yytable[yyn];
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrpop;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrpop;
-
- if (yyn == YYFINAL)
- YYACCEPT;
+ yystate = yyn;
+ goto yynewstate;
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting error token, ");
-#endif
- *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#if !defined yyoverflow || YYERROR_VERBOSE
+/*-------------------------------------------------.
+| yyexhaustedlab -- memory exhaustion comes here. |
+`-------------------------------------------------*/
+yyexhaustedlab:
+ yyerror (YY_("memory exhausted"));
+ yyresult = 2;
+ /* Fall through. */
#endif
- yystate = yyn;
- goto yynewstate;
-
- yyacceptlab:
- /* YYACCEPT comes here. */
- if (yyfree_stacks)
+yyreturn:
+ if (yychar != YYEMPTY)
{
- free (yyss);
- free (yyvs);
-#ifdef YYLSP_NEEDED
- free (yyls);
-#endif
+ /* Make sure we have latest lookahead translation. See comments at
+ user semantic actions for why this is necessary. */
+ yytoken = YYTRANSLATE (yychar);
+ yydestruct ("Cleanup: discarding lookahead",
+ yytoken, &yylval);
}
- return 0;
-
- yyabortlab:
- /* YYABORT comes here. */
- if (yyfree_stacks)
+ /* Do not reclaim the symbols of the rule whose action triggered
+ this YYABORT or YYACCEPT. */
+ YYPOPSTACK (yylen);
+ YY_STACK_PRINT (yyss, yyssp);
+ while (yyssp != yyss)
{
- free (yyss);
- free (yyvs);
-#ifdef YYLSP_NEEDED
- free (yyls);
-#endif
+ yydestruct ("Cleanup: popping",
+ yystos[*yyssp], yyvsp);
+ YYPOPSTACK (1);
}
- return 1;
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+#if YYERROR_VERBOSE
+ if (yymsg != yymsgbuf)
+ YYSTACK_FREE (yymsg);
+#endif
+ return yyresult;
}
-#line 653 "bc.y"
-
+#line 793 "../../bc/bc.y" /* yacc.c:1906 */
diff --git a/bc/bc.h b/bc/bc.h
index 4a1f59e..fb3eca2 100644
--- a/bc/bc.h
+++ b/bc/bc.h
@@ -1,42 +1,146 @@
-typedef union {
+/* A Bison parser, made by GNU Bison 3.0.2. */
+
+/* Bison interface for Yacc-like parsers in C
+
+ Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+
+ This program 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* As a special exception, you may create a larger work that contains
+ part or all of the Bison parser skeleton and distribute that work
+ under terms of your choice, so long as that work isn't itself a
+ parser generator using the skeleton or a modified version thereof
+ as a parser skeleton. Alternatively, if you modify or redistribute
+ the parser skeleton itself, you may (at your option) remove this
+ special exception, which will cause the skeleton and the resulting
+ Bison output files to be licensed under the GNU General Public
+ License without this special exception.
+
+ This special exception was added by the Free Software Foundation in
+ version 2.2 of Bison. */
+
+#ifndef YY_YY_BC_H_INCLUDED
+# define YY_YY_BC_H_INCLUDED
+/* Debug traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 0
+#endif
+#if YYDEBUG
+extern int yydebug;
+#endif
+
+/* Token type. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ enum yytokentype
+ {
+ ENDOFLINE = 258,
+ AND = 259,
+ OR = 260,
+ NOT = 261,
+ STRING = 262,
+ NAME = 263,
+ NUMBER = 264,
+ ASSIGN_OP = 265,
+ REL_OP = 266,
+ INCR_DECR = 267,
+ Define = 268,
+ Break = 269,
+ Quit = 270,
+ Length = 271,
+ Return = 272,
+ For = 273,
+ If = 274,
+ While = 275,
+ Sqrt = 276,
+ Else = 277,
+ Scale = 278,
+ Ibase = 279,
+ Obase = 280,
+ Auto = 281,
+ Read = 282,
+ Random = 283,
+ Warranty = 284,
+ Halt = 285,
+ Last = 286,
+ Continue = 287,
+ Print = 288,
+ Limits = 289,
+ UNARY_MINUS = 290,
+ HistoryVar = 291,
+ Void = 292
+ };
+#endif
+/* Tokens. */
+#define ENDOFLINE 258
+#define AND 259
+#define OR 260
+#define NOT 261
+#define STRING 262
+#define NAME 263
+#define NUMBER 264
+#define ASSIGN_OP 265
+#define REL_OP 266
+#define INCR_DECR 267
+#define Define 268
+#define Break 269
+#define Quit 270
+#define Length 271
+#define Return 272
+#define For 273
+#define If 274
+#define While 275
+#define Sqrt 276
+#define Else 277
+#define Scale 278
+#define Ibase 279
+#define Obase 280
+#define Auto 281
+#define Read 282
+#define Random 283
+#define Warranty 284
+#define Halt 285
+#define Last 286
+#define Continue 287
+#define Print 288
+#define Limits 289
+#define UNARY_MINUS 290
+#define HistoryVar 291
+#define Void 292
+
+/* Value type. */
+#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
+typedef union YYSTYPE YYSTYPE;
+union YYSTYPE
+{
+#line 52 "../../bc/bc.y" /* yacc.c:1909 */
+
char *s_value;
char c_value;
int i_value;
arg_list *a_value;
- } YYSTYPE;
-#define ENDOFLINE 257
-#define AND 258
-#define OR 259
-#define NOT 260
-#define STRING 261
-#define NAME 262
-#define NUMBER 263
-#define ASSIGN_OP 264
-#define REL_OP 265
-#define INCR_DECR 266
-#define Define 267
-#define Break 268
-#define Quit 269
-#define Length 270
-#define Return 271
-#define For 272
-#define If 273
-#define While 274
-#define Sqrt 275
-#define Else 276
-#define Scale 277
-#define Ibase 278
-#define Obase 279
-#define Auto 280
-#define Read 281
-#define Warranty 282
-#define Halt 283
-#define Last 284
-#define Continue 285
-#define Print 286
-#define Limits 287
-#define UNARY_MINUS 288
-#define HistoryVar 289
+
+
+#line 136 "bc.h" /* yacc.c:1909 */
+};
+# define YYSTYPE_IS_TRIVIAL 1
+# define YYSTYPE_IS_DECLARED 1
+#endif
extern YYSTYPE yylval;
+
+int yyparse (void);
+
+#endif /* !YY_YY_BC_H_INCLUDED */
diff --git a/bc/bc.y b/bc/bc.y
index 403e326..6e627a4 100644
--- a/bc/bc.y
+++ b/bc/bc.y
@@ -1,13 +1,10 @@
-%{
-/* bc.y: The grammar for a POSIX compatable bc processor with some
- extensions to the language. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -16,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to:
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -30,9 +25,26 @@
*************************************************************************/
+/* bc.y: The grammar for a POSIX compatable bc processor with some
+ extensions to the language. */
+
+%{
+
#include "bcdefs.h"
#include "global.h"
#include "proto.h"
+
+/* current function number. */
+int cur_func = -1;
+
+/* Expression encoded information -- See comment at expression rules. */
+#define EX_ASSGN 0
+#define EX_REG 1
+#define EX_COMP 2
+#define EX_PAREN 4
+#define EX_VOID 8
+#define EX_EMPTY 16
+
%}
%start program
@@ -60,7 +72,8 @@
h) optional expressions in the for loop.
i) print statement to print multiple numbers per line.
j) warranty statement to print an extended warranty notice.
- j) limits statement to print the processor's limits.
+ k) limits statement to print the processor's limits.
+ l) void functions.
*/
%token <i_value> ENDOFLINE AND OR NOT
@@ -76,12 +89,13 @@
%token <i_value> Define Break Quit Length
/* 'return', 'for', 'if', 'while', 'sqrt', 'else' */
%token <i_value> Return For If While Sqrt Else
-/* 'scale', 'ibase', 'obase', 'auto', 'read' */
-%token <i_value> Scale Ibase Obase Auto Read
+/* 'scale', 'ibase', 'obase', 'auto', 'read', 'random' */
+%token <i_value> Scale Ibase Obase Auto Read Random
/* 'warranty', 'halt', 'last', 'continue', 'print', 'limits' */
-%token <i_value> Warranty, Halt, Last, Continue, Print, Limits
-/* 'history' */
-%token <i_value> UNARY_MINUS HistoryVar
+%token <i_value> Warranty Halt Last Continue Print Limits
+/* 'history', 'void' */
+%token <i_value> UNARY_MINUS HistoryVar Void
+
/* Types of all other things. */
%type <i_value> expression return_expression named_expression opt_expression
@@ -90,6 +104,7 @@
%type <a_value> opt_argument_list argument_list
%type <i_value> program input_item semicolon_list statement_list
%type <i_value> statement function statement_or_error required_eol
+%type <i_value> opt_void
/* precedence */
%left OR
@@ -127,7 +142,7 @@ input_item : semicolon_list ENDOFLINE
;
opt_newline : /* empty */
| ENDOFLINE
- { warn ("newline not allowed"); }
+ { ct_warn ("newline not allowed"); }
;
semicolon_list : /* empty */
{ $$ = 0; }
@@ -153,9 +168,9 @@ statement : Warranty
{ limits (); }
| expression
{
- if ($1 & 2)
- warn ("comparison in expression");
- if ($1 & 1)
+ if ($1 & EX_COMP)
+ ct_warn ("comparison in expression");
+ if ($1 & EX_REG)
generate ("W");
else
generate ("p");
@@ -173,23 +188,25 @@ statement : Warranty
yyerror ("Break outside a for/while");
else
{
- sprintf (genstr, "J%1d:", break_label);
+ snprintf (genstr, genlen, "J%1d:",
+ break_label);
generate (genstr);
}
}
| Continue
{
- warn ("Continue statement");
+ ct_warn ("Continue statement");
if (continue_label == 0)
yyerror ("Continue outside a for");
else
{
- sprintf (genstr, "J%1d:", continue_label);
+ snprintf (genstr, genlen, "J%1d:",
+ continue_label);
generate (genstr);
}
}
| Quit
- { exit (0); }
+ { bc_exit (0); }
| Halt
{ generate ("h"); }
| Return return_expression
@@ -201,38 +218,46 @@ statement : Warranty
}
'(' opt_expression ';'
{
- if ($4 & 2)
- warn ("Comparison in first for expression");
- if ($4 >= 0)
+ if ($4 & EX_COMP)
+ ct_warn ("Comparison in first for expression");
+ if ($4 & EX_VOID)
+ yyerror ("first expression is void");
+ if (!($4 & EX_EMPTY))
generate ("p");
$4 = next_label++;
- sprintf (genstr, "N%1d:", $4);
+ snprintf (genstr, genlen, "N%1d:", $4);
generate (genstr);
}
opt_expression ';'
{
- if ($7 < 0) generate ("1");
+ if ($7 & EX_VOID)
+ yyerror ("second expression is void");
+ if ($7 & EX_EMPTY ) generate ("1");
$7 = next_label++;
- sprintf (genstr, "B%1d:J%1d:", $7, break_label);
+ snprintf (genstr, genlen, "B%1d:J%1d:", $7,
+ break_label);
generate (genstr);
$<i_value>$ = continue_label;
continue_label = next_label++;
- sprintf (genstr, "N%1d:", continue_label);
+ snprintf (genstr, genlen, "N%1d:",
+ continue_label);
generate (genstr);
}
opt_expression ')'
{
- if ($10 & 2 )
- warn ("Comparison in third for expression");
- if ($10 & 16)
- sprintf (genstr, "J%1d:N%1d:", $4, $7);
+ if ($10 & EX_COMP)
+ ct_warn ("Comparison in third for expression");
+ if ($10 & EX_VOID)
+ yyerror ("third expression is void");
+ if ($10 & EX_EMPTY)
+ snprintf (genstr, genlen, "J%1d:N%1d:", $4, $7);
else
- sprintf (genstr, "pJ%1d:N%1d:", $4, $7);
+ snprintf (genstr, genlen, "pJ%1d:N%1d:", $4, $7);
generate (genstr);
}
opt_newline statement
{
- sprintf (genstr, "J%1d:N%1d:",
+ snprintf (genstr, genlen, "J%1d:N%1d:",
continue_label, break_label);
generate (genstr);
break_label = $1;
@@ -240,40 +265,48 @@ statement : Warranty
}
| If '(' expression ')'
{
+ if ($3 & EX_VOID)
+ yyerror ("void expression");
$3 = if_label;
if_label = next_label++;
- sprintf (genstr, "Z%1d:", if_label);
+ snprintf (genstr, genlen, "Z%1d:", if_label);
generate (genstr);
}
opt_newline statement opt_else
{
- sprintf (genstr, "N%1d:", if_label);
+ snprintf (genstr, genlen, "N%1d:", if_label);
generate (genstr);
if_label = $3;
}
| While
{
- $1 = next_label++;
- sprintf (genstr, "N%1d:", $1);
+ $1 = continue_label;
+ continue_label = next_label++;
+ snprintf (genstr, genlen, "N%1d:",
+ continue_label);
generate (genstr);
}
'(' expression
{
+ if ($4 & EX_VOID)
+ yyerror ("void expression");
$4 = break_label;
break_label = next_label++;
- sprintf (genstr, "Z%1d:", break_label);
+ snprintf (genstr, genlen, "Z%1d:", break_label);
generate (genstr);
}
')' opt_newline statement
{
- sprintf (genstr, "J%1d:N%1d:", $1, break_label);
+ snprintf (genstr, genlen, "J%1d:N%1d:",
+ continue_label, break_label);
generate (genstr);
break_label = $4;
+ continue_label = $1;
}
| '{' statement_list '}'
{ $$ = 0; }
| Print
- { warn ("print statement"); }
+ { ct_warn ("print statement"); }
print_list
;
print_list : print_element
@@ -286,29 +319,40 @@ print_element : STRING
free ($1);
}
| expression
- { generate ("P"); }
+ {
+ if ($1 & EX_VOID)
+ yyerror ("void expression in print");
+ generate ("P");
+ }
;
opt_else : /* nothing */
| Else
{
- warn ("else clause in if statement");
+ ct_warn ("else clause in if statement");
$1 = next_label++;
- sprintf (genstr, "J%d:N%1d:", $1, if_label);
+ snprintf (genstr, genlen, "J%d:N%1d:", $1,
+ if_label);
generate (genstr);
if_label = $1;
}
opt_newline statement
-function : Define NAME '(' opt_parameter_list ')' opt_newline
+ ;
+function : Define opt_void NAME '(' opt_parameter_list ')' opt_newline
'{' required_eol opt_auto_define_list
- {
+ { char *params, *autos;
/* Check auto list against parameter list? */
- check_params ($4,$9);
- sprintf (genstr, "F%d,%s.%s[",
- lookup($2,FUNCTDEF),
- arg_str ($4), arg_str ($9));
+ check_params ($5,$10);
+ params = arg_str ($5);
+ autos = arg_str ($10);
+ set_genstr_size (30 + strlen (params)
+ + strlen (autos));
+ cur_func = lookup($3,FUNCTDEF);
+ snprintf (genstr, genlen, "F%d,%s.%s[", cur_func,
+ params, autos);
generate (genstr);
- free_args ($4);
- free_args ($9);
+ functions[cur_func].f_void = $2;
+ free_args ($5);
+ free_args ($10);
$1 = next_label;
next_label = 1;
}
@@ -316,6 +360,15 @@ function : Define NAME '(' opt_parameter_list ')' opt_newline
{
generate ("0R]");
next_label = $1;
+ cur_func = -1;
+ }
+ ;
+opt_void : /* empty */
+ { $$ = 0; }
+ | Void
+ {
+ $$ = 1;
+ ct_warn ("void functions");
}
;
opt_parameter_list : /* empty */
@@ -334,13 +387,25 @@ define_list : NAME
| NAME '[' ']'
{ $$ = nextarg (NULL, lookup ($1,ARRAY), FALSE); }
| '*' NAME '[' ']'
- { $$ = nextarg (NULL, lookup ($2,ARRAY), TRUE); }
+ { $$ = nextarg (NULL, lookup ($2,ARRAY), TRUE);
+ ct_warn ("Call by variable arrays");
+ }
+ | '&' NAME '[' ']'
+ { $$ = nextarg (NULL, lookup ($2,ARRAY), TRUE);
+ ct_warn ("Call by variable arrays");
+ }
| define_list ',' NAME
{ $$ = nextarg ($1, lookup ($3,SIMPLE), FALSE); }
| define_list ',' NAME '[' ']'
{ $$ = nextarg ($1, lookup ($3,ARRAY), FALSE); }
| define_list ',' '*' NAME '[' ']'
- { $$ = nextarg ($1, lookup ($4,ARRAY), TRUE); }
+ { $$ = nextarg ($1, lookup ($4,ARRAY), TRUE);
+ ct_warn ("Call by variable arrays");
+ }
+ | define_list ',' '&' NAME '[' ']'
+ { $$ = nextarg ($1, lookup ($4,ARRAY), TRUE);
+ ct_warn ("Call by variable arrays");
+ }
;
opt_argument_list : /* empty */
{ $$ = NULL; }
@@ -348,40 +413,49 @@ opt_argument_list : /* empty */
;
argument_list : expression
{
- if ($1 & 2) warn ("comparison in argument");
+ if ($1 & EX_COMP)
+ ct_warn ("comparison in argument");
+ if ($1 & EX_VOID)
+ yyerror ("void argument");
$$ = nextarg (NULL,0,FALSE);
}
| NAME '[' ']'
{
- sprintf (genstr, "K%d:", -lookup ($1,ARRAY));
+ snprintf (genstr, genlen, "K%d:",
+ -lookup ($1,ARRAY));
generate (genstr);
$$ = nextarg (NULL,1,FALSE);
}
| argument_list ',' expression
{
- if ($3 & 2) warn ("comparison in argument");
+ if ($3 & EX_COMP)
+ ct_warn ("comparison in argument");
+ if ($3 & EX_VOID)
+ yyerror ("void argument");
$$ = nextarg ($1,0,FALSE);
}
| argument_list ',' NAME '[' ']'
{
- sprintf (genstr, "K%d:", -lookup ($3,ARRAY));
+ snprintf (genstr, genlen, "K%d:",
+ -lookup ($3,ARRAY));
generate (genstr);
$$ = nextarg ($1,1,FALSE);
}
;
-/* Expression lval meanings! (Bits mean something!)
+/* Expression lval meanings! (Bits mean something!) (See defines above)
* 0 => Top op is assignment.
* 1 => Top op is not assignment.
* 2 => Comparison is somewhere in expression.
* 4 => Expression is in parenthesis.
+ * 8 => Expression is void!
* 16 => Empty optional expression.
*/
opt_expression : /* empty */
{
- $$ = 16;
- warn ("Missing expression in for statement");
+ $$ = EX_EMPTY;
+ ct_warn ("Missing expression in for statement");
}
| expression
;
@@ -389,13 +463,21 @@ return_expression : /* empty */
{
$$ = 0;
generate ("0");
+ if (cur_func == -1)
+ yyerror("Return outside of a function.");
}
| expression
{
- if ($1 & 2)
- warn ("comparison in return expresion");
- if (!($1 & 4))
- warn ("return expression requires parenthesis");
+ if ($1 & EX_COMP)
+ ct_warn ("comparison in return expresion");
+ if (!($1 & EX_PAREN))
+ ct_warn ("return expression requires parenthesis");
+ if ($1 & EX_VOID)
+ yyerror("return requires non-void expression");
+ if (cur_func == -1)
+ yyerror("Return outside of a function.");
+ else if (functions[cur_func].f_void)
+ yyerror("Return expression in a void function.");
}
;
expression : named_expression ASSIGN_OP
@@ -403,66 +485,76 @@ expression : named_expression ASSIGN_OP
if ($2 != '=')
{
if ($1 < 0)
- sprintf (genstr, "DL%d:", -$1);
+ snprintf (genstr, genlen, "DL%d:", -$1);
else
- sprintf (genstr, "l%d:", $1);
+ snprintf (genstr, genlen, "l%d:", $1);
generate (genstr);
}
}
expression
{
- if ($4 & 2) warn("comparison in assignment");
+ if ($4 & EX_ASSGN)
+ ct_warn("comparison in assignment");
+ if ($4 & EX_VOID)
+ yyerror("Assignment of a void expression");
if ($2 != '=')
{
- sprintf (genstr, "%c", $2);
+ snprintf (genstr, genlen, "%c", $2);
generate (genstr);
}
if ($1 < 0)
- sprintf (genstr, "S%d:", -$1);
+ snprintf (genstr, genlen, "S%d:", -$1);
else
- sprintf (genstr, "s%d:", $1);
+ snprintf (genstr, genlen, "s%d:", $1);
generate (genstr);
- $$ = 0;
+ $$ = EX_ASSGN;
}
- ;
| expression AND
{
- warn("&& operator");
+ ct_warn("&& operator");
$2 = next_label++;
- sprintf (genstr, "DZ%d:p", $2);
+ snprintf (genstr, genlen, "DZ%d:p", $2);
generate (genstr);
}
expression
{
- sprintf (genstr, "DZ%d:p1N%d:", $2, $2);
+ if (($1 & EX_VOID) || ($4 & EX_VOID))
+ yyerror ("void expression with &&");
+ snprintf (genstr, genlen, "DZ%d:p1N%d:", $2, $2);
generate (genstr);
- $$ = ($1 | $4) & ~4;
+ $$ = ($1 | $4) & ~EX_PAREN;
}
| expression OR
{
- warn("|| operator");
+ ct_warn("|| operator");
$2 = next_label++;
- sprintf (genstr, "B%d:", $2);
+ snprintf (genstr, genlen, "B%d:", $2);
generate (genstr);
}
expression
{
int tmplab;
+ if (($1 & EX_VOID) || ($4 & EX_VOID))
+ yyerror ("void expression with ||");
tmplab = next_label++;
- sprintf (genstr, "B%d:0J%d:N%d:1N%d:",
+ snprintf (genstr, genlen, "B%d:0J%d:N%d:1N%d:",
$2, tmplab, $2, tmplab);
generate (genstr);
- $$ = ($1 | $4) & ~4;
+ $$ = ($1 | $4) & ~EX_PAREN;
}
| NOT expression
{
- $$ = $2 & ~4;
- warn("! operator");
+ if ($2 & EX_VOID)
+ yyerror ("void expression with !");
+ $$ = $2 & ~EX_PAREN;
+ ct_warn("! operator");
generate ("!");
}
| expression REL_OP expression
{
- $$ = 3;
+ if (($1 & EX_VOID) || ($3 & EX_VOID))
+ yyerror ("void expression with comparison");
+ $$ = EX_REG | EX_COMP;
switch (*($2))
{
case '=':
@@ -487,55 +579,70 @@ expression : named_expression ASSIGN_OP
generate (">");
break;
}
+ free($2);
}
| expression '+' expression
{
+ if (($1 & EX_VOID) || ($3 & EX_VOID))
+ yyerror ("void expression with +");
generate ("+");
- $$ = ($1 | $3) & ~4;
+ $$ = ($1 | $3) & ~EX_PAREN;
}
| expression '-' expression
{
+ if (($1 & EX_VOID) || ($3 & EX_VOID))
+ yyerror ("void expression with -");
generate ("-");
- $$ = ($1 | $3) & ~4;
+ $$ = ($1 | $3) & ~EX_PAREN;
}
| expression '*' expression
{
+ if (($1 & EX_VOID) || ($3 & EX_VOID))
+ yyerror ("void expression with *");
generate ("*");
- $$ = ($1 | $3) & ~4;
+ $$ = ($1 | $3) & ~EX_PAREN;
}
| expression '/' expression
{
+ if (($1 & EX_VOID) || ($3 & EX_VOID))
+ yyerror ("void expression with /");
generate ("/");
- $$ = ($1 | $3) & ~4;
+ $$ = ($1 | $3) & ~EX_PAREN;
}
| expression '%' expression
{
+ if (($1 & EX_VOID) || ($3 & EX_VOID))
+ yyerror ("void expression with %");
generate ("%");
- $$ = ($1 | $3) & ~4;
+ $$ = ($1 | $3) & ~EX_PAREN;
}
| expression '^' expression
{
+ if (($1 & EX_VOID) || ($3 & EX_VOID))
+ yyerror ("void expression with ^");
generate ("^");
- $$ = ($1 | $3) & ~4;
+ $$ = ($1 | $3) & ~EX_PAREN;
}
| '-' expression %prec UNARY_MINUS
{
+ if ($2 & EX_VOID)
+ yyerror ("void expression with unary -");
generate ("n");
- $$ = $2 & ~4;
+ $$ = $2 & ~EX_PAREN;
}
| named_expression
{
- $$ = 1;
+ $$ = EX_REG;
if ($1 < 0)
- sprintf (genstr, "L%d:", -$1);
+ snprintf (genstr, genlen, "L%d:", -$1);
else
- sprintf (genstr, "l%d:", $1);
+ snprintf (genstr, genlen, "l%d:", $1);
generate (genstr);
}
| NUMBER
{
int len = strlen($1);
- $$ = 1;
+ $$ = EX_REG;
if (len == 1 && *$1 == '0')
generate ("0");
else if (len == 1 && *$1 == '1')
@@ -549,82 +656,115 @@ expression : named_expression ASSIGN_OP
free ($1);
}
| '(' expression ')'
- { $$ = $2 | 5; }
+ {
+ if ($2 & EX_VOID)
+ yyerror ("void expression in parenthesis");
+ $$ = $2 | EX_REG | EX_PAREN;
+ }
| NAME '(' opt_argument_list ')'
- {
- $$ = 1;
+ { int fn;
+ fn = lookup ($1,FUNCT);
+ if (functions[fn].f_void)
+ $$ = EX_VOID;
+ else
+ $$ = EX_REG;
if ($3 != NULL)
- {
- sprintf (genstr, "C%d,%s:",
- lookup ($1,FUNCT),
- call_str ($3));
+ { char *params = call_str ($3);
+ set_genstr_size (20 + strlen (params));
+ snprintf (genstr, genlen, "C%d,%s:", fn,
+ params);
free_args ($3);
}
else
{
- sprintf (genstr, "C%d:", lookup ($1,FUNCT));
+ snprintf (genstr, genlen, "C%d:", fn);
}
generate (genstr);
}
| INCR_DECR named_expression
{
- $$ = 1;
+ $$ = EX_REG;
if ($2 < 0)
{
if ($1 == '+')
- sprintf (genstr, "DA%d:L%d:", -$2, -$2);
+ snprintf (genstr, genlen, "DA%d:L%d:", -$2, -$2);
else
- sprintf (genstr, "DM%d:L%d:", -$2, -$2);
+ snprintf (genstr, genlen, "DM%d:L%d:", -$2, -$2);
}
else
{
if ($1 == '+')
- sprintf (genstr, "i%d:l%d:", $2, $2);
+ snprintf (genstr, genlen, "i%d:l%d:", $2, $2);
else
- sprintf (genstr, "d%d:l%d:", $2, $2);
+ snprintf (genstr, genlen, "d%d:l%d:", $2, $2);
}
generate (genstr);
}
| named_expression INCR_DECR
{
- $$ = 1;
+ $$ = EX_REG;
if ($1 < 0)
{
- sprintf (genstr, "DL%d:x", -$1);
+ snprintf (genstr, genlen, "DL%d:x", -$1);
generate (genstr);
if ($2 == '+')
- sprintf (genstr, "A%d:", -$1);
+ snprintf (genstr, genlen, "A%d:", -$1);
else
- sprintf (genstr, "M%d:", -$1);
+ snprintf (genstr, genlen, "M%d:", -$1);
}
else
{
- sprintf (genstr, "l%d:", $1);
+ snprintf (genstr, genlen, "l%d:", $1);
generate (genstr);
if ($2 == '+')
- sprintf (genstr, "i%d:", $1);
+ snprintf (genstr, genlen, "i%d:", $1);
else
- sprintf (genstr, "d%d:", $1);
+ snprintf (genstr, genlen, "d%d:", $1);
}
generate (genstr);
}
| Length '(' expression ')'
- { generate ("cL"); $$ = 1;}
+ {
+ if ($3 & EX_VOID)
+ yyerror ("void expression in length()");
+ generate ("cL");
+ $$ = EX_REG;
+ }
| Sqrt '(' expression ')'
- { generate ("cR"); $$ = 1;}
+ {
+ if ($3 & EX_VOID)
+ yyerror ("void expression in sqrt()");
+ generate ("cR");
+ $$ = EX_REG;
+ }
| Scale '(' expression ')'
- { generate ("cS"); $$ = 1;}
+ {
+ if ($3 & EX_VOID)
+ yyerror ("void expression in scale()");
+ generate ("cS");
+ $$ = EX_REG;
+ }
| Read '(' ')'
{
- warn ("read function");
- generate ("cI"); $$ = 1;
+ ct_warn ("read function");
+ generate ("cI");
+ $$ = EX_REG;
+ }
+ | Random '(' ')'
+ {
+ ct_warn ("random function");
+ generate ("cX");
+ $$ = EX_REG;
}
;
named_expression : NAME
{ $$ = lookup($1,SIMPLE); }
| NAME '[' expression ']'
{
- if ($3 > 1) warn("comparison in subscript");
+ if ($3 & EX_VOID)
+ yyerror("void expression as subscript");
+ if ($3 & EX_COMP)
+ ct_warn("comparison in subscript");
$$ = lookup($1,ARRAY);
}
| Ibase
@@ -635,20 +775,19 @@ named_expression : NAME
{ $$ = 2; }
| HistoryVar
{ $$ = 3;
- warn ("History variable");
+ ct_warn ("History variable");
}
| Last
{ $$ = 4;
- warn ("Last variable");
+ ct_warn ("Last variable");
}
;
-required_eol : { warn ("End of line required"); }
+required_eol : { ct_warn ("End of line required"); }
| ENDOFLINE
| required_eol ENDOFLINE
- { warn ("Too many end of lines"); }
+ { ct_warn ("Too many end of lines"); }
;
%%
-
diff --git a/bc/bcdefs.h b/bc/bcdefs.h
index 260cd12..ccfc53a 100644
--- a/bc/bcdefs.h
+++ b/bc/bcdefs.h
@@ -1,11 +1,10 @@
-/* bcdefs.h: The single file to include all constants and type definitions. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,6 +25,8 @@
*************************************************************************/
+/* bcdefs.h: The single file to include all constants and type definitions. */
+
/* Include the configuration file. */
#include "config.h"
@@ -35,10 +34,10 @@
#include <stdio.h>
#include <sys/types.h>
#include <ctype.h>
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#else
+#ifdef HAVE_STRING_H
#include <string.h>
+#else
+#include <strings.h>
#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
@@ -53,6 +52,15 @@
#include <readline/history.h>
#endif
+/* Initialization magic ... */
+#ifdef _GLOBAL_C
+#define EXTERN
+#define INIT(x) = x
+#else
+#define EXTERN extern
+#define INIT(x)
+#endif
+
/* Include the other definitions. */
#include "const.h"
#include "number.h"
@@ -70,7 +78,7 @@
typedef struct bc_label_group
{
- long l_adrs [ BC_LABEL_GROUP ];
+ unsigned long l_adrs [ BC_LABEL_GROUP ];
struct bc_label_group *l_next;
} bc_label_group;
@@ -90,9 +98,10 @@ typedef struct arg_list
typedef struct
{
char f_defined; /* Is this function defined yet. */
+ char f_void; /* Is this function a void function. */
char *f_body;
- int f_body_size; /* Size of body. Power of 2. */
- int f_code_size;
+ size_t f_body_size; /* Size of body. Power of 2. */
+ size_t f_code_size;
bc_label_group *f_label;
arg_list *f_params;
arg_list *f_autos;
@@ -100,8 +109,8 @@ typedef struct
/* Code addresses. */
typedef struct {
- int pc_func;
- int pc_addr;
+ unsigned int pc_func;
+ unsigned int pc_addr;
} program_counter;
@@ -186,3 +195,6 @@ typedef struct file_node {
#define HISTORY_SIZE(n) stifle_history(n)
#define UNLIMIT_HISTORY unstifle_history()
#endif
+
+/* Now the global variable declarations. */
+#include "global.h"
diff --git a/bc/const.h b/bc/const.h
index 1a7c5b8..2147086 100644
--- a/bc/const.h
+++ b/bc/const.h
@@ -1,11 +1,10 @@
-/* const.h: Constants for bc. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,6 +25,7 @@
*************************************************************************/
+/* const.h: Constants for bc. */
/* Define INT_MAX and LONG_MAX if not defined. Assuming 32 bits... */
@@ -57,11 +55,11 @@
/* Definitions for arrays. */
-#define BC_DIM_MAX 65535 /* this should be NODE_SIZE^NODE_DEPTH-1 */
+#define BC_DIM_MAX 16777215 /* this should be NODE_SIZE^NODE_DEPTH-1 */
-#define NODE_SIZE 16 /* Must be a power of 2. */
-#define NODE_MASK 0xf /* Must be NODE_SIZE-1. */
-#define NODE_SHIFT 4 /* Number of 1 bits in NODE_MASK. */
+#define NODE_SIZE 64 /* Must be a power of 2. */
+#define NODE_MASK 0x3f /* Must be NODE_SIZE-1. */
+#define NODE_SHIFT 6 /* Number of 1 bits in NODE_MASK. */
#define NODE_DEPTH 4
@@ -88,7 +86,6 @@
#define FUNCT 2
#define FUNCTDEF 3
-#define EXTERN extern
#ifdef __STDC__
#define CONST const
#define VOID void
diff --git a/bc/execute.c b/bc/execute.c
index d2864d1..256e4b7 100644
--- a/bc/execute.c
+++ b/bc/execute.c
@@ -1,11 +1,10 @@
-/* execute.c - run a bc program. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991-1994, 1997, 2000 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -27,10 +24,10 @@
Bellingham, WA 98226-9062
*************************************************************************/
+/* execute.c - run a bc program. */
#include "bcdefs.h"
#include <signal.h>
-#include "global.h"
#include "proto.h"
@@ -39,38 +36,34 @@
int had_sigint;
void
-stop_execution (sig)
- int sig;
+stop_execution ( int sig )
{
had_sigint = TRUE;
- printf ("\n");
- rt_error ("interrupted execution");
}
/* Get the current byte and advance the PC counter. */
unsigned char
-byte (pc)
- program_counter *pc;
+byte ( program_counter *p )
{
- return (functions[pc->pc_func].f_body[pc->pc_addr++]);
+ return (functions[p->pc_func].f_body[p->pc_addr++]);
}
/* The routine that actually runs the machine. */
void
-execute ()
+execute (void)
{
- int label_num, l_gp, l_off;
+ unsigned long label_num, l_gp, l_off;
bc_label_group *gp;
char inst, ch;
- int new_func;
- int var_name;
+ long new_func;
+ long var_name;
- int const_base;
+ long const_base;
bc_num temp_num;
arg_list *auto_list;
@@ -85,10 +78,11 @@ execute ()
if (interactive)
{
signal (SIGINT, stop_execution);
- had_sigint = FALSE;
}
- while (pc.pc_addr < functions[pc.pc_func].f_code_size && !runtime_error)
+ had_sigint = FALSE;
+ while (pc.pc_addr < functions[pc.pc_func].f_code_size
+ && !runtime_error && !had_sigint)
{
inst = byte(&pc);
@@ -127,6 +121,7 @@ execute ()
case 'Z' : /* Branch to a label if TOS == 0. Remove value on TOS. */
c_code = !bc_is_zero (ex_stack->s_num);
pop ();
+ /*FALLTHROUGH*/ /* common branch and jump code */
case 'J' : /* Jump to a label. */
label_num = byte(&pc); /* Low order bits first. */
label_num += byte(&pc) << 8;
@@ -136,7 +131,12 @@ execute ()
l_gp = label_num >> BC_LABEL_LOG;
l_off = label_num % BC_LABEL_GROUP;
while (l_gp-- > 0) gp = gp->l_next;
- pc.pc_addr = gp->l_adrs[l_off];
+ if (gp)
+ pc.pc_addr = gp->l_adrs[l_off];
+ else {
+ rt_error ("Internal error.");
+ break;
+ }
}
break;
@@ -290,6 +290,11 @@ execute ()
case 'I': /* Read function. */
push_constant (input_char, i_base);
break;
+
+ case 'X': /* Random function. */
+ push_copy (_zero_);
+ bc_int2num (&ex_stack->s_num, random());
+ break;
}
break;
@@ -301,7 +306,9 @@ execute ()
break;
case 'h' : /* Halt the machine. */
- exit (0);
+ bc_exit (0);
+ /* NOTREACHED */
+ break;
case 'i' : /* increment number */
var_name = byte(&pc);
@@ -349,7 +356,7 @@ execute ()
push_copy (_zero_);
break;
- case '1' : /* Load Constant 0. */
+ case '1' : /* Load Constant 1. */
push_copy (_one_);
break;
@@ -542,7 +549,7 @@ execute ()
{
signal (SIGINT, use_quit);
if (had_sigint)
- printf ("Interruption completed.\n");
+ printf ("\ninterrupted execution.\n");
}
}
@@ -550,20 +557,20 @@ execute ()
/* Prog_char gets another byte from the program. It is used for
conversion of text constants in the code to numbers. */
-char
-prog_char ()
+int
+prog_char (void)
{
- return byte(&pc);
+ return (int) byte(&pc);
}
/* Read a character from the standard input. This function is used
by the "read" function. */
-char
-input_char ()
+int
+input_char (void)
{
- char in_ch;
+ int in_ch;
/* Get a character from the standard input for the read function. */
in_ch = getchar();
@@ -572,21 +579,25 @@ input_char ()
if (in_ch == '\\')
{
in_ch = getchar();
- if (in_ch == '\n')
- in_ch = getchar();
+ if (in_ch == '\n') {
+ in_ch = getchar();
+ out_col = 0; /* Saw a new line */
+ }
}
/* Classify and preprocess the input character. */
- if (isdigit((int)in_ch))
+ if (isdigit(in_ch))
return (in_ch - '0');
- if (in_ch >= 'A' && in_ch <= 'F')
+ if (in_ch >= 'A' && in_ch <= 'Z')
return (in_ch + 10 - 'A');
- if (in_ch >= 'a' && in_ch <= 'f')
+ if (in_ch >= 'a' && in_ch <= 'z')
return (in_ch + 10 - 'a');
if (in_ch == '.' || in_ch == '+' || in_ch == '-')
return (in_ch);
+ if (in_ch == '~')
+ return (':');
if (in_ch <= ' ')
- return (' ');
+ return ('~');
return (':');
}
@@ -597,13 +608,11 @@ input_char ()
stack. The number is converted as a number in base CONV_BASE. */
void
-push_constant (in_char, conv_base)
- char (*in_char)(VOID);
- int conv_base;
+push_constant (int (*in_char)(VOID), int conv_base)
{
int digits;
bc_num build, temp, result, mult, divisor;
- char in_ch, first_ch;
+ int in_ch, first_ch;
char negative;
/* Initialize all bc numbers */
@@ -618,7 +627,8 @@ push_constant (in_char, conv_base)
/* Get things ready. */
in_ch = in_char();
- while (in_ch == ' ')
+ /* ~ is space returned by input_char(), prog_char does not return spaces. */
+ while (in_ch == '~')
in_ch = in_char();
if (in_ch == '+')
@@ -631,19 +641,19 @@ push_constant (in_char, conv_base)
}
/* Check for the special case of a single digit. */
- if (in_ch < 16)
+ if (in_ch < 36)
{
first_ch = in_ch;
in_ch = in_char();
- if (in_ch < 16 && first_ch >= conv_base)
+ if (in_ch < 36 && first_ch >= conv_base)
first_ch = conv_base - 1;
bc_int2num (&build, (int) first_ch);
}
/* Convert the integer part. */
- while (in_ch < 16)
+ while (in_ch < 36)
{
- if (in_ch < 16 && in_ch >= conv_base) in_ch = conv_base-1;
+ if (in_ch < 36 && in_ch >= conv_base) in_ch = conv_base-1;
bc_multiply (build, mult, &result, 0);
bc_int2num (&temp, (int) in_ch);
bc_add (result, temp, &build, 0);
@@ -658,7 +668,7 @@ push_constant (in_char, conv_base)
divisor = bc_copy_num (_one_);
result = bc_copy_num (_zero_);
digits = 0;
- while (in_ch < 16)
+ while (in_ch < 36)
{
bc_multiply (result, mult, &result, 0);
bc_int2num (&temp, (int) in_ch);
@@ -666,7 +676,7 @@ push_constant (in_char, conv_base)
bc_multiply (divisor, mult, &divisor, 0);
digits++;
in_ch = in_char();
- if (in_ch < 16 && in_ch >= conv_base) in_ch = conv_base-1;
+ if (in_ch < 36 && in_ch >= conv_base) in_ch = conv_base-1;
}
bc_divide (result, divisor, &result, digits);
bc_add (build, result, &build, 0);
@@ -689,17 +699,16 @@ push_constant (in_char, conv_base)
the constant. */
void
-push_b10_const (pc)
- program_counter *pc;
+push_b10_const (program_counter *progctr)
{
bc_num build;
program_counter look_pc;
int kdigits, kscale;
- char inchar;
+ unsigned char inchar;
char *ptr;
/* Count the digits and get things ready. */
- look_pc = *pc;
+ look_pc = *progctr;
kdigits = 0;
kscale = 0;
inchar = byte (&look_pc);
@@ -718,8 +727,8 @@ push_b10_const (pc)
}
}
- /* Get the first character again and move the pc. */
- inchar = byte(pc);
+ /* Get the first character again and move the progctr. */
+ inchar = byte(progctr);
/* Secial cases of 0, 1, and A-F single inputs. */
if (kdigits == 1 && kscale == 0)
@@ -727,12 +736,12 @@ push_b10_const (pc)
if (inchar == 0)
{
push_copy (_zero_);
- inchar = byte(pc);
+ inchar = byte(progctr);
return;
}
if (inchar == 1) {
push_copy (_one_);
- inchar = byte(pc);
+ inchar = byte(progctr);
return;
}
if (inchar > 9)
@@ -740,7 +749,7 @@ push_b10_const (pc)
bc_init_num (&build);
bc_int2num (&build, inchar);
push_num (build);
- inchar = byte(pc);
+ inchar = byte(progctr);
return;
}
}
@@ -767,7 +776,7 @@ push_b10_const (pc)
else
*ptr++ = inchar;
}
- inchar = byte(pc);
+ inchar = byte(progctr);
}
push_num (build);
}
@@ -776,13 +785,11 @@ push_b10_const (pc)
/* Put the correct value on the stack for C_CODE. Frees TOS num. */
void
-assign (c_code)
- char c_code;
+assign (char code)
{
bc_free_num (&ex_stack->s_num);
- if (c_code)
+ if (code)
ex_stack->s_num = bc_copy_num (_one_);
else
ex_stack->s_num = bc_copy_num (_zero_);
}
-
diff --git a/bc/global.c b/bc/global.c
index 5d1205c..ebd6bcf 100644
--- a/bc/global.c
+++ b/bc/global.c
@@ -1,11 +1,10 @@
-/* global.c: This defines the global variables. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991-1994, 1997, 2000 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,14 +25,13 @@
*************************************************************************/
-#include "bcdefs.h"
+/* global.c: This defines the global variables. */
+
+/* We are global.c ... so define and initialize variables here. */
-/* Since we want to define them here, we use the following define. */
-#undef EXTERN
-#define EXTERN
+#define _GLOBAL_C
-/* Define all the global variables for bc. */
-#include "global.h"
+#include "bcdefs.h"
CONST char *libmath[] =
#include "libmath.h"
diff --git a/bc/global.h b/bc/global.h
index cf6945c..22fe248 100644
--- a/bc/global.h
+++ b/bc/global.h
@@ -1,11 +1,10 @@
-/* global.h: The global variables for bc. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,8 +25,9 @@
*************************************************************************/
+/* global.h: The global variables for bc. */
-/* The current break level's lable. */
+/* The current break level's label. */
EXTERN int break_label;
/* The current if statement's else label or label after else. */
@@ -42,7 +40,8 @@ EXTERN int continue_label;
EXTERN int next_label;
/* Byte code character storage. Used in many places for generation of code. */
-EXTERN char genstr[80];
+EXTERN char *genstr INIT(NULL);
+EXTERN int genlen INIT(0);
/* Count of characters printed to the output in compile_only mode. */
EXTERN int out_count;
@@ -52,25 +51,25 @@ EXTERN int out_count;
EXTERN char did_gen;
/* Is this run an interactive execution. (Is stdin a terminal?) */
-EXTERN char interactive;
+EXTERN char interactive INIT(FALSE);
/* Just generate the byte code. -c flag. */
-EXTERN int compile_only;
+EXTERN int compile_only INIT(FALSE);
/* Load the standard math functions. -l flag. */
-EXTERN int use_math;
+EXTERN int use_math INIT(FALSE);
/* Give a warning on use of any non-standard feature (non-POSIX). -w flag. */
-EXTERN int warn_not_std;
+EXTERN int warn_not_std INIT(FALSE);
/* Accept POSIX bc only! -s flag. */
-EXTERN int std_only;
+EXTERN int std_only INIT(FALSE);
/* Don't print the banner at start up. -q flag. */
-EXTERN int quiet;
+EXTERN int quiet INIT(FALSE);
/* The list of file names to process. */
-EXTERN file_node *file_names;
+EXTERN file_node *file_names INIT(NULL);
/* The name of the current file being processed. */
EXTERN char *file_name;
@@ -113,7 +112,7 @@ EXTERN int n_history;
#if defined(LIBEDIT)
/* LIBEDIT data */
-EditLine *edit;
+EditLine *edit INIT(NULL);
History *hist;
HistEvent histev;
#endif
@@ -152,3 +151,6 @@ extern int optind;
/* Access to the yy input file. Defined in scan.c. */
extern FILE *yyin;
+
+/* Access to libmath */
+extern CONST char *libmath[];
diff --git a/bc/libmath.b b/bc/libmath.b
index 7bb6405..a353158 100644
--- a/bc/libmath.b
+++ b/bc/libmath.b
@@ -1,11 +1,10 @@
-/* libmath.b for GNU bc. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991, 1992, 1993, 1997 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,6 +25,7 @@
*************************************************************************/
+/* libmath.b for bc. */
scale = 20
@@ -37,7 +35,7 @@ scale = 20
*/
define e(x) {
- auto a, d, e, f, i, m, n, v, z
+ auto a, b, d, e, f, i, m, n, v, z
/* a - holds x^y of x^y/y! */
/* d - holds y! */
@@ -48,6 +46,16 @@ define e(x) {
/* i - iteration count. */
/* n - the scale to compute the sum. */
/* z - orignal scale. */
+ /* b - holds the original ibase. */
+
+ /* Non base 10 ibase? */
+ if (ibase != A) {
+ b = ibase;
+ ibase = A;
+ v = e(x);
+ ibase = b;
+ return (v);
+ }
/* Check the sign of x. */
if (x<0) {
@@ -89,7 +97,16 @@ define e(x) {
*/
define l(x) {
- auto e, f, i, m, n, v, z
+ auto b, e, f, i, m, n, v, z
+
+ /* Non base 10 ibase? */
+ if (ibase != A) {
+ b = ibase;
+ ibase = A;
+ v = l(x);
+ ibase = b;
+ return (v);
+ }
/* return something for the special case. */
if (x <= 0) return ((1 - 10^scale)/1)
@@ -128,7 +145,16 @@ define l(x) {
sin(x) = x - x^3/3! + x^5/5! - x^7/7! ... */
define s(x) {
- auto e, i, m, n, s, v, z
+ auto b, e, i, m, n, s, v, z
+
+ /* Non base 10 ibase? */
+ if (ibase != A) {
+ b = ibase;
+ ibase = A;
+ v = s(x);
+ ibase = b;
+ return (v);
+ }
/* precondition x. */
z = scale
@@ -160,7 +186,17 @@ define s(x) {
/* Cosine : cos(x) = sin(x+pi/2) */
define c(x) {
- auto v, z;
+ auto b, v, z;
+
+ /* Non base 10 ibase? */
+ if (ibase != A) {
+ b = ibase;
+ ibase = A;
+ v = c(x);
+ ibase = b;
+ return (v);
+ }
+
z = scale;
scale = scale*1.2;
v = s(x+a(1)*2);
@@ -174,7 +210,7 @@ define c(x) {
atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... */
define a(x) {
- auto a, e, f, i, m, n, s, v, z
+ auto a, b, e, f, i, m, n, s, v, z
/* a is the value of a(.2) if it is needed. */
/* f is the value to multiply by a in the return. */
@@ -186,6 +222,15 @@ define a(x) {
/* s is -x*x. */
/* z is the saved user's scale. */
+ /* Non base 10 ibase? */
+ if (ibase != A) {
+ b = ibase;
+ ibase = A;
+ v = a(x);
+ ibase = b;
+ return (v);
+ }
+
/* Negative x? */
m = 1;
if (x<0) {
@@ -249,6 +294,15 @@ define a(x) {
define j(n,x) {
auto a, b, d, e, f, i, m, s, v, z
+ /* Non base 10 ibase? */
+ if (ibase != A) {
+ b = ibase;
+ ibase = A;
+ v = j(n,x);
+ ibase = b;
+ return (v);
+ }
+
/* Make n an integer and check for negative n. */
z = scale;
scale = 0;
@@ -258,10 +312,6 @@ define j(n,x) {
if (n%2 == 1) m = 1;
}
- /* save ibase */
- b = ibase;
- ibase = A;
-
/* Compute the factor of x^n/(2^n*n!) */
f = 1;
for (i=2; i<=n; i++) f = f*i;
@@ -277,7 +327,6 @@ define j(n,x) {
for (i=1; 1; i++) {
e = e * s / i / (n+i);
if (e == 0) {
- ibase = b;
scale = z
if (m) return (-f*v/1);
return (f*v/1);
diff --git a/bc/libmath.h b/bc/libmath.h
deleted file mode 100644
index bf48f4b..0000000
--- a/bc/libmath.h
+++ /dev/null
@@ -1,40 +0,0 @@
-{"@iK20:s2:p@r",
-"@iF1,5.6,7,8,9,10,11,12,13,14[l5:0<Z1:1s11:pl5:ns5:pN1:l2:s14:",
-"pK6:l14:+K.44:l5:*+s12:pl5:cS1+s2:pN2:l5:1>Z3:l9:1+s9:pl5:K2:",
-"/s5:pl2:1+s2:pJ2:N3:l12:s2:p1l5:+s13:pl5:s6:p1s7:pK2:s10:pN5:",
-"1B6:J4:N7:l10:i10:pJ5:N6:l6:l5:*s6:l7:l10:*s7:/s8:pl8:0=Z8:l9:",
-"0>Z9:N10:l9:d9:Z11:l13:l13:*s13:pJ10:N11:N9:l14:s2:pl11:Z12:1",
-"l13:/RN12:l13:1/RN8:l13:l8:+s13:pJ7:N4:0R]@r",
-"@iF2,5.8,9,10,11,12,13,14[l5:0{Z1:1K10:l2:^-1/RN1:l2:s14:pK6:",
-"l2:+s2:pK2:s9:p0s10:pN2:l5:K2:}Z3:l9:K2:*s9:pl5:cRs5:pJ2:N3:N4:",
-"l5:K.5:{Z5:l9:K2:*s9:pl5:cRs5:pJ4:N5:l5:1-l5:1+/s12:s13:pl12:",
-"l12:*s11:pK3:s10:pN7:1B8:J6:N9:l10:K2:+s10:pJ7:N8:l12:l11:*s12:",
-"l10:/s8:pl8:0=Z10:l9:l13:*s13:pl14:s2:pl13:1/RN10:l13:l8:+s13:",
-"pJ9:N6:0R]@r",
-"@iF3,5.8,10,11,12,15,13,14[l2:s14:pK1.1:l14:*K2:+s2:p1C4,0:s13:",
-"pl5:0<Z1:1s11:pl5:ns5:pN1:0s2:pl5:l13:/K2:+K4:/s12:pl5:K4:l12:",
-"*l13:*-s5:pl12:K2:%Z2:l5:ns5:pN2:l14:K2:+s2:pl5:s8:s13:pl5:nl5:",
-"*s15:pK3:s10:pN4:1B5:J3:N6:l10:K2:+s10:pJ4:N5:l8:l15:l10:l10:",
-"1-*/*s8:pl8:0=Z7:l14:s2:pl11:Z8:l13:n1/RN8:l13:1/RN7:l13:l8:+",
-"s13:pJ6:N3:0R]@r",
-"@iF5,5.13,14[l2:s14:pl2:K1.2:*s2:pl5:1C4,0:K2:*+C3,0:s13:pl14:",
-"s2:pl13:1/R0R]@r",
-"@iF4,5.6,8,9,10,11,12,15,13,14[1s11:pl5:0<Z1:1ns11:pl5:ns5:pN1:",
-"l5:1=Z2:l2:K25:{Z3:K.7853981633974483096156608:l11:/RN3:l2:K40",
-":{Z4:K.7853981633974483096156608458198757210492:l11:/RN4:l2:K",
-"60:{Z5:K.785398163397448309615660845819875721049292349843776455243736",
-":l11:/RN5:N2:l5:K.2:=Z6:l2:K25:{Z7:K.1973955598498807583700497",
-":l11:/RN7:l2:K40:{Z8:K.1973955598498807583700497651947902934475",
-":l11:/RN8:l2:K60:{Z9:K.197395559849880758370049765194790293447585103787852101517688",
-":l11:/RN9:N6:l2:s14:pl5:K.2:>Z10:l14:K5:+s2:pK.2:C4,0:s6:pN10:",
-"l14:K3:+s2:pN11:l5:K.2:>Z12:l9:1+s9:pl5:K.2:-1l5:K.2:*+/s5:pJ11:N12:",
-"l5:s12:s13:pl5:nl5:*s15:pK3:s10:pN14:1B15:J13:N16:l10:K2:+s10:",
-"pJ14:N15:l12:l15:*s12:l10:/s8:pl8:0=Z17:l14:s2:pl9:l6:*l13:+l11:",
-"/RN17:l13:l8:+s13:pJ16:N13:0R]@r",
-"@iF6,12,5.6,16,7,8,9,10,11,15,13,14[l2:s14:p0s2:pl12:1/s12:pl12:",
-"0<Z1:l12:ns12:pl12:K2:%1=Z2:1s11:pN2:N1:l0:s16:pKA:s0:p1s9:pK",
-"2:s10:pN4:l10:l12:{B5:J3:N6:l10:i10:pJ4:N5:l9:l10:*s9:pJ6:N3:",
-"K1.5:l14:*s2:pl5:l12:^K2:l12:^/l9:/s9:p1s8:s13:pl5:nl5:*K4:/s15:",
-"pK1.5:l14:*l9:cL+l9:cS-s2:p1s10:pN8:1B9:J7:N10:l10:i10:pJ8:N9:",
-"l8:l15:*l10:/l12:l10:+/s8:pl8:0=Z11:l16:s0:pl14:s2:pl11:Z12:l9:",
-"nl13:*1/RN12:l9:l13:*1/RN11:l13:l8:+s13:pJ10:N7:0R]@r",0}
diff --git a/bc/load.c b/bc/load.c
index 40b8051..7362e3f 100644
--- a/bc/load.c
+++ b/bc/load.c
@@ -1,11 +1,10 @@
-/* load.c: This code "loads" code into the code segments. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991-1994, 1997, 2000 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,8 +25,9 @@
*************************************************************************/
+/* load.c: This code "loads" code into the code segments. */
+
#include "bcdefs.h"
-#include "global.h"
#include "proto.h"
/* Load variables. */
@@ -40,7 +38,7 @@ char load_const;
/* Initialize the load sequence. */
void
-init_load ()
+init_load (void)
{
clear_func(0);
load_adr.pc_func = 0;
@@ -51,10 +49,9 @@ init_load ()
/* addbyte adds one BYTE to the current code segment. */
void
-addbyte (byte)
- char byte;
+addbyte (unsigned char thebyte)
{
- int pc;
+ unsigned long prog_addr;
bc_function *f;
char *new_body;
@@ -62,20 +59,20 @@ addbyte (byte)
if (had_error) return;
/* Calculate the segment and offset. */
- pc = load_adr.pc_addr++;
+ prog_addr = load_adr.pc_addr++;
f = &functions[load_adr.pc_func];
- if (pc >= f->f_body_size)
+ if (prog_addr >= f->f_body_size)
{
f->f_body_size *= 2;
- new_body = (char *) bc_malloc (f->f_body_size);
+ new_body = bc_malloc (f->f_body_size);
memcpy(new_body, f->f_body, f->f_body_size/2);
free (f->f_body);
f->f_body = new_body;
}
- /* Store the byte. */
- f->f_body[pc] = byte;
+ /* Store the thebyte. */
+ f->f_body[prog_addr] = (char) (thebyte & 0xff);
f->f_code_size++;
}
@@ -83,11 +80,10 @@ addbyte (byte)
/* Define a label LAB to be the current program counter. */
void
-def_label (lab)
- long lab;
+def_label (unsigned long lab)
{
bc_label_group *temp;
- int group, offset, func;
+ unsigned long group, offset, func;
/* Get things ready. */
group = lab >> BC_LABEL_LOG;
@@ -97,8 +93,7 @@ def_label (lab)
/* Make sure there is at least one label group. */
if (functions[func].f_label == NULL)
{
- functions[func].f_label =
- (bc_label_group *) bc_malloc (sizeof(bc_label_group));
+ functions[func].f_label = bc_malloc (sizeof(bc_label_group));
functions[func].f_label->l_next = NULL;
}
@@ -108,7 +103,7 @@ def_label (lab)
{
if (temp->l_next == NULL)
{
- temp->l_next = (bc_label_group *) bc_malloc (sizeof(bc_label_group));
+ temp->l_next = bc_malloc (sizeof(bc_label_group));
temp->l_next->l_next = NULL;
}
temp = temp->l_next;
@@ -125,8 +120,7 @@ def_label (lab)
must be moved to the last non-digit character. */
long
-long_val (str)
- char **str;
+long_val (const char **str)
{ int val = 0;
char neg = FALSE;
@@ -148,15 +142,14 @@ long_val (str)
/* load_code loads the CODE into the machine. */
void
-load_code (code)
- char *code;
+load_code (const char *code)
{
- char *str;
- long ap_name; /* auto or parameter name. */
- long label_no;
- long vaf_name; /* variable, array or function number. */
- long func;
- program_counter save_adr;
+ const char *str;
+ unsigned long ap_name; /* auto or parameter name. */
+ unsigned long label_no;
+ unsigned long vaf_name; /* variable, array or function number. */
+ unsigned long func;
+ static program_counter save_adr;
/* Initialize. */
str = code;
@@ -188,10 +181,19 @@ load_code (code)
if (*str == '.')
addbyte (*str++);
else
- if (*str >= 'A')
- addbyte (*str++ + 10 - 'A');
- else
- addbyte (*str++ - '0');
+ {
+ if (*str > 'F' && (warn_not_std || std_only))
+ {
+ if (std_only)
+ yyerror ("Error in numeric constant");
+ else
+ ct_warn ("Non-standard base in numeric constant");
+ }
+ if (*str >= 'A')
+ addbyte (*str++ + 10 - 'A');
+ else
+ addbyte (*str++ - '0');
+ }
}
}
else
@@ -217,7 +219,7 @@ load_code (code)
if (label_no > 65535L)
{ /* Better message? */
fprintf (stderr,"Program too big.\n");
- exit(1);
+ bc_exit(1);
}
addbyte ( (char) (label_no & 0xFF));
addbyte ( (char) (label_no >> 8));
diff --git a/bc/main.c b/bc/main.c
index 1b9f6d2..012075c 100644
--- a/bc/main.c
+++ b/bc/main.c
@@ -1,11 +1,10 @@
-/* main.c: The main program for bc. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,9 +25,11 @@
*************************************************************************/
+/* main.c: The main program for bc. */
+
#include "bcdefs.h"
#include <signal.h>
-#include "global.h"
+#include <errno.h>
#include "proto.h"
#include "getopt.h"
@@ -41,29 +40,36 @@ static char first_file;
/* Points to the last node in the file name list for easy adding. */
static file_node *last = NULL;
+#if defined(LIBEDIT)
+/* The prompt for libedit. */
+char el_pmtchars[] = "";
+static char *el_pmtfunc(void);
+static char *el_pmtfunc(void) { return el_pmtchars; }
+#endif
+
/* long option support */
static struct option long_options[] =
{
- {"compile", 0, &compile_only, TRUE},
- {"help", 0, 0, 'h'},
- {"interactive", 0, 0, 'i'},
- {"mathlib", 0, &use_math, TRUE},
- {"quiet", 0, &quiet, TRUE},
- {"standard", 0, &std_only, TRUE},
- {"version", 0, 0, 'v'},
- {"warn", 0, &warn_not_std, TRUE},
+ {"compile", 0, &compile_only, TRUE},
+ {"help", 0, 0, 'h'},
+ {"interactive", 0, 0, 'i'},
+ {"mathlib", 0, &use_math, TRUE},
+ {"quiet", 0, &quiet, TRUE},
+ {"standard", 0, &std_only, TRUE},
+ {"version", 0, 0, 'v'},
+ {"warn", 0, &warn_not_std, TRUE},
{0, 0, 0, 0}
};
-void
-usage (char *progname)
+static void
+usage (const char *progname)
{
printf ("usage: %s [options] [file ...]\n%s%s%s%s%s%s%s", progname,
" -h --help print this usage and exit\n",
" -i --interactive force interactive mode\n",
- " -l --mathlib use the predefine math routnes\n",
+ " -l --mathlib use the predefined math routines\n",
" -q --quiet don't print initial banner\n",
" -s --standard non-standard bc constructs are errors\n",
" -w --warn warn about non-standard bc constructs\n",
@@ -71,10 +77,8 @@ usage (char *progname)
}
-void
-parse_args (argc, argv)
- int argc;
- char **argv;
+static void
+parse_args (int argc, char **argv)
{
int optch;
int long_index;
@@ -93,13 +97,16 @@ parse_args (argc, argv)
switch (optch)
{
+ case 0: /* Long option setting a var. */
+ break;
+
case 'c': /* compile only */
compile_only = TRUE;
break;
case 'h': /* help */
usage(argv[0]);
- exit (0);
+ bc_exit (0);
break;
case 'i': /* force interactive */
@@ -120,7 +127,7 @@ parse_args (argc, argv)
case 'v': /* Print the version. */
show_bc_version ();
- exit (0);
+ bc_exit (0);
break;
case 'w': /* Non standard features give warnings. */
@@ -129,14 +136,18 @@ parse_args (argc, argv)
default:
usage(argv[0]);
- exit (1);
+ bc_exit (1);
}
}
+#ifdef QUIET
+ quiet = TRUE;
+#endif
+
/* Add file names to a list of files to process. */
while (optind < argc)
{
- temp = (file_node *) bc_malloc(sizeof(file_node));
+ temp = bc_malloc(sizeof(file_node));
temp->name = argv[optind];
temp->next = NULL;
if (last == NULL)
@@ -150,25 +161,15 @@ parse_args (argc, argv)
/* The main program for bc. */
int
-main (argc, argv)
- int argc;
- char *argv[];
+main (int argc, char **argv)
{
char *env_value;
char *env_argv[30];
int env_argc;
- /* Initialize many variables. */
- compile_only = FALSE;
- use_math = FALSE;
- warn_not_std = FALSE;
- std_only = FALSE;
+ /* Interactive? */
if (isatty(0) && isatty(1))
interactive = TRUE;
- else
- interactive = FALSE;
- quiet = FALSE;
- file_names = NULL;
#ifdef HAVE_SETVBUF
/* attempt to simplify interaction with applications such as emacs */
@@ -180,7 +181,7 @@ main (argc, argv)
if (env_value != NULL)
{
env_argc = 1;
- env_argv[0] = "BC_ENV_ARGS";
+ env_argv[0] = strdup("BC_ENV_ARGS");
while (*env_value != 0)
{
if (*env_value != ' ')
@@ -211,7 +212,7 @@ main (argc, argv)
if (env_value != NULL)
{
line_size = atoi (env_value);
- if (line_size < 2)
+ if (line_size < 3 && line_size != 0)
line_size = 70;
}
else
@@ -231,7 +232,7 @@ main (argc, argv)
is_std_in = FALSE;
first_file = TRUE;
if (!open_new_file ())
- exit (1);
+ bc_exit (1);
#if defined(LIBEDIT)
if (interactive) {
@@ -240,7 +241,7 @@ main (argc, argv)
hist = history_init();
el_set (edit, EL_EDITOR, "emacs");
el_set (edit, EL_HIST, history, hist);
- el_set (edit, EL_PROMPT, null_prompt);
+ el_set (edit, EL_PROMPT, el_pmtfunc);
el_source (edit, NULL);
history (hist, &histev, H_SETSIZE, INT_MAX);
}
@@ -262,7 +263,8 @@ main (argc, argv)
if (compile_only)
printf ("\n");
- exit (0);
+ bc_exit (0);
+ return 0; // to keep the compiler from complaining
}
@@ -271,7 +273,7 @@ main (argc, argv)
it returns FALSE. */
int
-open_new_file ()
+open_new_file (void)
{
FILE *new_file;
file_node *temp;
@@ -286,18 +288,17 @@ open_new_file ()
if (use_math && first_file)
{
/* Load the code from a precompiled version of the math libarary. */
- extern char *libmath[];
- char **mstr;
- char tmp;
+ CONST char **mstr;
+
/* These MUST be in the order of first mention of each function.
That is why "a" comes before "c" even though "a" is defined after
after "c". "a" is used in "s"! */
- tmp = lookup ("e", FUNCT);
- tmp = lookup ("l", FUNCT);
- tmp = lookup ("s", FUNCT);
- tmp = lookup ("a", FUNCT);
- tmp = lookup ("c", FUNCT);
- tmp = lookup ("j", FUNCT);
+ (void) lookup (strdup("e"), FUNCT);
+ (void) lookup (strdup("l"), FUNCT);
+ (void) lookup (strdup("s"), FUNCT);
+ (void) lookup (strdup("a"), FUNCT);
+ (void) lookup (strdup("c"), FUNCT);
+ (void) lookup (strdup("j"), FUNCT);
mstr = libmath;
while (*mstr) {
load_code (*mstr);
@@ -319,7 +320,7 @@ open_new_file ()
return TRUE;
}
fprintf (stderr, "File %s is unavailable.\n", file_names->name);
- exit (1);
+ bc_exit (1);
}
/* If we fall through to here, we should return stdin. */
@@ -332,8 +333,7 @@ open_new_file ()
/* Set yyin to the new file. */
void
-new_yy_file (file)
- FILE *file;
+new_yy_file (FILE *file)
{
if (!first_file) fclose (yyin);
yyin = file;
@@ -344,9 +344,15 @@ new_yy_file (file)
/* Message to use quit. */
void
-use_quit (sig)
- int sig;
+use_quit (int sig)
{
- printf ("\n(interrupt) use quit to exit.\n");
+#ifdef DONTEXIT
+ int save = errno;
+ write (1, "\n(interrupt) use quit to exit.\n", 31);
signal (SIGINT, use_quit);
+ errno = save;
+#else
+ write (1, "\n(interrupt) Exiting bc.\n", 26);
+ bc_exit(0);
+#endif
}
diff --git a/bc/proto.h b/bc/proto.h
index 1e7311f..189c68c 100644
--- a/bc/proto.h
+++ b/bc/proto.h
@@ -1,11 +1,10 @@
-/* proto.h: Prototype function definitions for "external" functions. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991-1994, 1997, 2000 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,6 +25,8 @@
*************************************************************************/
+/* proto.h: Prototype function definitions for "external" functions. */
+
/* For the pc version using k&r ACK. (minix1.5 and earlier.) */
#ifdef SHORTNAMES
#define init_numbers i_numbers
@@ -47,102 +46,94 @@
#include <stdlib.h>
#endif
-/* Define the _PROTOTYPE macro if it is needed. */
-
-#ifndef _PROTOTYPE
-#ifdef __STDC__
-#define _PROTOTYPE(func, args) func args
-#else
-#define _PROTOTYPE(func, args) func()
-#endif
-#endif
-
/* From execute.c */
-_PROTOTYPE(void stop_execution, (int));
-_PROTOTYPE(unsigned char byte, (program_counter *pc));
-_PROTOTYPE(void execute, (void));
-_PROTOTYPE(char prog_char, (void));
-_PROTOTYPE(char input_char, (void));
-_PROTOTYPE(void push_constant, (char (*in_char)(void), int conv_base));
-_PROTOTYPE(void push_b10_const, (program_counter *pc));
-_PROTOTYPE(void assign, (int c_code));
+void stop_execution (int);
+unsigned char byte (program_counter *pc_);
+void execute (void);
+int prog_char (void);
+int input_char (void);
+void push_constant (int (*in_char)(void), int conv_base);
+void push_b10_const (program_counter *pc_);
+void assign (char code);
/* From util.c */
-_PROTOTYPE(char *strcopyof, (char *str));
-_PROTOTYPE(arg_list *nextarg, (arg_list *args, int val, int is_var));
-_PROTOTYPE(char *arg_str, (arg_list *args));
-_PROTOTYPE(char *call_str, (arg_list *args));
-_PROTOTYPE(void free_args, (arg_list *args));
-_PROTOTYPE(void check_params, (arg_list *params, arg_list *autos));
-_PROTOTYPE(void init_gen, (void));
-_PROTOTYPE(void generate, (char *str));
-_PROTOTYPE(void run_code, (void));
-_PROTOTYPE(void out_char, (int ch));
-_PROTOTYPE(void out_schar, (int ch));
-_PROTOTYPE(id_rec *find_id, (id_rec *tree, char *id));
-_PROTOTYPE(int insert_id_rec, (id_rec **root, id_rec *new_id));
-_PROTOTYPE(void init_tree, (void));
-_PROTOTYPE(int lookup, (char *name, int namekind));
-_PROTOTYPE(char *bc_malloc, (int));
-_PROTOTYPE(void out_of_memory, (void));
-_PROTOTYPE(void welcome, (void));
-_PROTOTYPE(void warranty, (char *));
-_PROTOTYPE(void show_bc_version, (void));
-_PROTOTYPE(void limits, (void));
-_PROTOTYPE(void yyerror, (char *str ,...));
-_PROTOTYPE(void warn, (char *mesg ,...));
-_PROTOTYPE(void rt_error, (char *mesg ,...));
-_PROTOTYPE(void rt_warn, (char *mesg ,...));
+char *strcopyof (const char *str);
+arg_list *nextarg (arg_list *args, int val, int is_var);
+char *arg_str (arg_list *args);
+char *call_str (arg_list *args);
+void free_args (arg_list *args);
+void check_params (arg_list *params, arg_list *autos);
+void set_genstr_size (int);
+void init_gen (void);
+void generate (const char *str);
+void run_code (void);
+void out_char (int ch);
+void out_schar (int ch);
+id_rec *find_id (id_rec *tree, const char *id);
+int insert_id_rec (id_rec **root, id_rec *new_id);
+void init_tree (void);
+int lookup (char *name, int namekind);
+void *bc_malloc (size_t);
+void out_of_memory (void);
+void welcome (void);
+void warranty (const char *);
+void show_bc_version (void);
+void limits (void);
+void yyerror (const char *str ,...);
+void ct_warn (const char *mesg ,...);
+void rt_error (const char *mesg ,...);
+void rt_warn (const char *mesg ,...);
+void bc_exit (int);
/* From load.c */
-_PROTOTYPE(void init_load, (void));
-_PROTOTYPE(void addbyte, (int byte));
-_PROTOTYPE(void def_label, (long lab));
-_PROTOTYPE(long long_val, (char **str));
-_PROTOTYPE(void load_code, (char *code));
+void init_load (void);
+void addbyte (unsigned char thebyte);
+void def_label (unsigned long lab);
+long long_val (const char **str);
+void load_code (const char *code);
/* From main.c */
-_PROTOTYPE(int open_new_file, (void));
-_PROTOTYPE(void new_yy_file, (FILE *file));
-_PROTOTYPE(void use_quit, (int));
+int open_new_file (void);
+void new_yy_file (FILE *file);
+void use_quit (int);
/* From storage.c */
-_PROTOTYPE(void init_storage, (void));
-_PROTOTYPE(void more_functions, (void));
-_PROTOTYPE(void more_variables, (void));
-_PROTOTYPE(void more_arrays, (void));
-_PROTOTYPE(void clear_func, (int func ));
-_PROTOTYPE(int fpop, (void));
-_PROTOTYPE(void fpush, (int val ));
-_PROTOTYPE(void pop, (void));
-_PROTOTYPE(void push_copy, (bc_num num ));
-_PROTOTYPE(void push_num, (bc_num num ));
-_PROTOTYPE(char check_stack, (int depth ));
-_PROTOTYPE(bc_var *get_var, (int var_name ));
-_PROTOTYPE(bc_num *get_array_num, (int var_index, long index ));
-_PROTOTYPE(void store_var, (int var_name ));
-_PROTOTYPE(void store_array, (int var_name ));
-_PROTOTYPE(void load_var, (int var_name ));
-_PROTOTYPE(void load_array, (int var_name ));
-_PROTOTYPE(void decr_var, (int var_name ));
-_PROTOTYPE(void decr_array, (int var_name ));
-_PROTOTYPE(void incr_var, (int var_name ));
-_PROTOTYPE(void incr_array, (int var_name ));
-_PROTOTYPE(void auto_var, (int name ));
-_PROTOTYPE(void free_a_tree, (bc_array_node *root, int depth ));
-_PROTOTYPE(void pop_vars, (arg_list *list ));
-_PROTOTYPE(void process_params, (program_counter *pc, int func ));
+void init_storage (void);
+void more_functions (void);
+void more_variables (void);
+void more_arrays (void);
+void clear_func (int func);
+int fpop (void);
+void fpush (int val);
+void pop (void);
+void push_copy (bc_num num);
+void push_num (bc_num num);
+char check_stack (int depth);
+bc_var *get_var (int var_name);
+bc_num *get_array_num (int var_index, unsigned long _index_);
+void store_var (int var_name);
+void store_array (int var_name);
+void load_var (int var_name);
+void load_array (int var_name);
+void decr_var (int var_name);
+void decr_array (int var_name);
+void incr_var (int var_name);
+void incr_array (int var_name);
+void auto_var (int name);
+void free_a_tree (bc_array_node *root, int depth);
+void pop_vars (arg_list *list);
+void process_params (program_counter *_pc_, int func);
/* For the scanner and parser.... */
-_PROTOTYPE(int yyparse, (void));
-_PROTOTYPE(int yylex, (void));
+int yyparse (void);
+int yylex (void);
#if defined(LIBEDIT)
/* The *?*&^ prompt function */
-_PROTOTYPE(char *null_prompt, (EditLine *));
+char *null_prompt (EditLine *);
#endif
/* Other things... */
#ifndef HAVE_UNISTD_H
-_PROTOTYPE (int getopt, (int, char *[], CONST char *));
+(int getopt (int, char *[], CONST char *);
#endif
diff --git a/bc/sbc.y b/bc/sbc.y
index b1ff1d1..586686b 100644
--- a/bc/sbc.y
+++ b/bc/sbc.y
@@ -17,8 +17,9 @@
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ 51 Franklin Street, Fifth Floor
+ Boston, MA 02110-1301 USA
+
You may contact the author by:
e-mail: philnelson@acm.org
@@ -82,22 +83,22 @@ program : /* empty */
{
$$ = 0;
std_only = TRUE;
- if (interactive)
+ if (interactive && !quiet)
{
- printf ("s%s\n", BC_VERSION);
- welcome();
+ show_bc_version ();
+ welcome ();
}
}
| program input_item
;
input_item : semicolon_list ENDOFLINE
- { run_code(); }
+ { run_code (); }
| function
- { run_code(); }
+ { run_code (); }
| error ENDOFLINE
{
yyerrok;
- init_gen() ;
+ init_gen () ;
}
;
semicolon_list : /* empty */
@@ -119,7 +120,7 @@ statement_or_error : statement
{ $$ = $2; }
;
statement : Warranty
- { warranty("s"); }
+ { warranty ("s"); }
| expression
{
if ($1 & 1)
@@ -145,7 +146,7 @@ statement : Warranty
}
}
| Quit
- { exit(0); }
+ { bc_exit (0); }
| Return
{ generate ("0R"); }
| Return '(' return_expression ')'
@@ -217,10 +218,14 @@ statement : Warranty
;
function : Define NAME '(' opt_parameter_list ')' '{'
ENDOFLINE opt_auto_define_list
- {
+ { char *params, *autos;
check_params ($4,$8);
- sprintf (genstr, "F%d,%s.%s[", lookup($2,FUNCT),
- arg_str ($4), arg_str ($8));
+ params = arg_str ($4);
+ autos = arg_str ($8);
+ set_genstr_size (30 + strlen (params)
+ + strlen (autos));
+ sprintf (genstr, "F%d,%s.%s[", lookup ($2,FUNCT),
+ params, autos);
generate (genstr);
free_args ($4);
free_args ($8);
@@ -238,9 +243,9 @@ opt_parameter_list : /* empty */
| parameter_list
;
parameter_list : NAME
- { $$ = nextarg (NULL, lookup($1,SIMPLE), FALSE); }
+ { $$ = nextarg (NULL, lookup ($1,SIMPLE), FALSE); }
| define_list ',' NAME
- { $$ = nextarg ($1, lookup($3,SIMPLE), FALSE); }
+ { $$ = nextarg ($1, lookup ($3,SIMPLE), FALSE); }
;
opt_auto_define_list : /* empty */
{ $$ = NULL; }
@@ -250,13 +255,13 @@ opt_auto_define_list : /* empty */
{ $$ = $2; }
;
define_list : NAME
- { $$ = nextarg (NULL, lookup($1,SIMPLE), FALSE); }
+ { $$ = nextarg (NULL, lookup ($1,SIMPLE), FALSE); }
| NAME '[' ']'
- { $$ = nextarg (NULL, lookup($1,ARRAY), FALSE); }
+ { $$ = nextarg (NULL, lookup ($1,ARRAY), FALSE); }
| define_list ',' NAME
- { $$ = nextarg ($1, lookup($3,SIMPLE), FALSE); }
+ { $$ = nextarg ($1, lookup ($3,SIMPLE), FALSE); }
| define_list ',' NAME '[' ']'
- { $$ = nextarg ($1, lookup($3,ARRAY), FALSE); }
+ { $$ = nextarg ($1, lookup ($3,ARRAY), FALSE); }
;
opt_argument_list : /* empty */
{ $$ = NULL; }
@@ -352,7 +357,7 @@ expression : named_expression ASSIGN_OP
}
| NUMBER
{
- int len = strlen($1);
+ int len = strlen ($1);
$$ = 1;
if (len == 1 && *$1 == '0')
generate ("0");
@@ -375,13 +380,14 @@ expression : named_expression ASSIGN_OP
{
$$ = 1;
if ($3 != NULL)
- {
- sprintf (genstr, "C%d,%s:", lookup($1,FUNCT),
- arg_str ($3));
+ { char *params = call_str ($3);
+ set_genstr_size (20 + strlen (params));
+ sprintf (genstr, "C%d,%s:",
+ lookup ($1,FUNCT), params);
free_args ($3);
}
else
- sprintf (genstr, "C%d:", lookup($1,FUNCT));
+ sprintf (genstr, "C%d:", lookup ($1,FUNCT));
generate (genstr);
}
| INCR_DECR named_expression
@@ -434,9 +440,9 @@ expression : named_expression ASSIGN_OP
{ generate ("cS"); $$ = 1;}
;
named_expression : NAME
- { $$ = lookup($1,SIMPLE); }
+ { $$ = lookup ($1,SIMPLE); }
| NAME '[' expression ']'
- { $$ = lookup($1,ARRAY); }
+ { $$ = lookup ($1,ARRAY); }
| Ibase
{ $$ = 0; }
| Obase
diff --git a/bc/scan.c b/bc/scan.c
index 8d9c92d..b237f55 100644
--- a/bc/scan.c
+++ b/bc/scan.c
@@ -1,67 +1,117 @@
-/* A lexical scanner generated by flex */
-/* Scanner skeleton version:
- * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
- */
+#line 3 "scan.c"
+
+#define YY_INT_ALIGNED short int
+
+/* A lexical scanner generated by flex */
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
+#define YY_FLEX_SUBMINOR_VERSION 35
+#if YY_FLEX_SUBMINOR_VERSION > 0
+#define FLEX_BETA
+#endif
+/* First, we deal with platform-specific or compiler-specific issues. */
+
+/* begin standard C headers. */
+#ifdef _LIBC
+#include "namespace.h"
+#endif
#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <stdlib.h>
+/* end standard C headers. */
-/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
-#ifdef c_plusplus
-#ifndef __cplusplus
-#define __cplusplus
-#endif
+/* $NetBSD: flexint.h,v 1.1.1.1 2009/10/26 00:26:19 christos Exp $ */
+
+/* flex integer type definitions */
+
+#ifndef FLEXINT_H
+#define FLEXINT_H
+
+/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
+
+#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+
+/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
+ * if you want the limit (max/min) macros for int types.
+ */
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
#endif
+#include <inttypes.h>
+typedef int8_t flex_int8_t;
+typedef uint8_t flex_uint8_t;
+typedef int16_t flex_int16_t;
+typedef uint16_t flex_uint16_t;
+typedef int32_t flex_int32_t;
+typedef uint32_t flex_uint32_t;
+#else
+typedef signed char flex_int8_t;
+typedef short int flex_int16_t;
+typedef int flex_int32_t;
+typedef unsigned char flex_uint8_t;
+typedef unsigned short int flex_uint16_t;
+typedef unsigned int flex_uint32_t;
+#endif /* ! C99 */
-#ifdef __cplusplus
+/* Limits of integral types. */
+#ifndef INT8_MIN
+#define INT8_MIN (-128)
+#endif
+#ifndef INT16_MIN
+#define INT16_MIN (-32767-1)
+#endif
+#ifndef INT32_MIN
+#define INT32_MIN (-2147483647-1)
+#endif
+#ifndef INT8_MAX
+#define INT8_MAX (127)
+#endif
+#ifndef INT16_MAX
+#define INT16_MAX (32767)
+#endif
+#ifndef INT32_MAX
+#define INT32_MAX (2147483647)
+#endif
+#ifndef UINT8_MAX
+#define UINT8_MAX (255U)
+#endif
+#ifndef UINT16_MAX
+#define UINT16_MAX (65535U)
+#endif
+#ifndef UINT32_MAX
+#define UINT32_MAX (4294967295U)
+#endif
-#include <stdlib.h>
-#include <unistd.h>
+#endif /* ! FLEXINT_H */
-/* Use prototypes in function declarations. */
-#define YY_USE_PROTOS
+#ifdef __cplusplus
/* The "const" storage-class-modifier is valid. */
#define YY_USE_CONST
#else /* ! __cplusplus */
-#if __STDC__
+/* C99 requires __STDC__ to be defined as 1. */
+#if defined (__STDC__)
-#define YY_USE_PROTOS
#define YY_USE_CONST
-#endif /* __STDC__ */
+#endif /* defined (__STDC__) */
#endif /* ! __cplusplus */
-#ifdef __TURBOC__
- #pragma warn -rch
- #pragma warn -use
-#include <io.h>
-#include <stdlib.h>
-#define YY_USE_CONST
-#define YY_USE_PROTOS
-#endif
-
#ifdef YY_USE_CONST
#define yyconst const
#else
#define yyconst
#endif
-
-#ifdef YY_USE_PROTOS
-#define YY_PROTO(proto) proto
-#else
-#define YY_PROTO(proto) ()
-#endif
-
/* Returned upon end-of-file. */
#define YY_NULL 0
@@ -76,71 +126,70 @@
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
*/
-#define BEGIN yy_start = 1 + 2 *
+#define BEGIN (yy_start) = 1 + 2 *
/* Translate the current start state into a value that can be later handed
* to BEGIN to return to the state. The YYSTATE alias is for lex
* compatibility.
*/
-#define YY_START ((yy_start - 1) / 2)
+#define YY_START (((yy_start) - 1) / 2)
#define YYSTATE YY_START
/* Action number for EOF rule of a given start state. */
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
/* Special action meaning "start processing a new file". */
-#define YY_NEW_FILE yyrestart( yyin )
+#define YY_NEW_FILE yyrestart(yyin )
#define YY_END_OF_BUFFER_CHAR 0
/* Size of default input buffer. */
+#ifndef YY_BUF_SIZE
#define YY_BUF_SIZE 16384
+#endif
+/* The state buf must be large enough to hold one state per character in the main buffer.
+ */
+#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
+
+#ifndef YY_TYPEDEF_YY_BUFFER_STATE
+#define YY_TYPEDEF_YY_BUFFER_STATE
typedef struct yy_buffer_state *YY_BUFFER_STATE;
+#endif
extern int yyleng;
+
extern FILE *yyin, *yyout;
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
-/* The funky do-while in the following #define is used to turn the definition
- * int a single C statement (which needs a semi-colon terminator). This
- * avoids problems with code like:
- *
- * if ( condition_holds )
- * yyless( 5 );
- * else
- * do_something_else();
- *
- * Prior to using the do-while the compiler would get upset at the
- * "else" because it interpreted the "if" statement as being all
- * done when it reached the ';' after the yyless() call.
- */
-
-/* Return all but the first 'n' matched characters back to the input stream. */
-
+ #define YY_LESS_LINENO(n)
+
+/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
do \
{ \
/* Undo effects of setting up yytext. */ \
- *yy_cp = yy_hold_char; \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ *yy_cp = (yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
- yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
YY_DO_BEFORE_ACTION; /* set up yytext again */ \
} \
while ( 0 )
-#define unput(c) yyunput( c, yytext_ptr )
-
-/* The following is because we cannot portably get our hands on size_t
- * (without autoconf's help, which isn't available because we want
- * flex-generated scanners to compile on their own).
- */
-typedef unsigned int yy_size_t;
+#define unput(c) yyunput( c, (yytext_ptr) )
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+#ifndef YY_STRUCT_YY_BUFFER_STATE
+#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
FILE *yy_input_file;
@@ -177,12 +226,16 @@ struct yy_buffer_state
*/
int yy_at_bol;
+ int yy_bs_lineno; /**< The line count. */
+ int yy_bs_column; /**< The column count. */
+
/* Whether to try to fill the input buffer when we reach the
* end of it.
*/
int yy_fill_buffer;
int yy_buffer_status;
+
#define YY_BUFFER_NEW 0
#define YY_BUFFER_NORMAL 1
/* When an EOF's been seen but there's still some text to process
@@ -196,28 +249,38 @@ struct yy_buffer_state
* just pointing yyin at a new input file.
*/
#define YY_BUFFER_EOF_PENDING 2
+
};
+#endif /* !YY_STRUCT_YY_BUFFER_STATE */
-static YY_BUFFER_STATE yy_current_buffer = 0;
+/* Stack of input buffers. */
+static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
+static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
+static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* "scanner state".
+ *
+ * Returns the top of the stack, or NULL.
*/
-#define YY_CURRENT_BUFFER yy_current_buffer
+#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
+ : NULL)
+/* Same as previous macro, but useful when we know that the buffer stack is not
+ * NULL or when we need an lvalue. For internal use only.
+ */
+#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
-
static int yy_n_chars; /* number of characters read into yy_ch_buf */
-
-
int yyleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
-static int yy_init = 1; /* whether we need to initialize */
+static int yy_init = 0; /* whether we need to initialize */
static int yy_start = 0; /* start state number */
/* Flag which is used to allow yywrap()'s to do buffer switches
@@ -225,103 +288,134 @@ static int yy_start = 0; /* start state number */
*/
static int yy_did_buffer_switch_on_eof;
-void yyrestart YY_PROTO(( FILE *input_file ));
+void yyrestart (FILE *input_file );
+void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
+YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
+void yy_delete_buffer (YY_BUFFER_STATE b );
+void yy_flush_buffer (YY_BUFFER_STATE b );
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
+void yypop_buffer_state (void );
-void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
-void yy_load_buffer_state YY_PROTO(( void ));
-YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
-void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
-void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
-#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+static void yyensure_buffer_stack (void );
+static void yy_load_buffer_state (void );
+static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
-YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
-YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
-YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
-static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
-static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
-static void yy_flex_free YY_PROTO(( void * ));
+YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
+YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
+
+void *yyalloc (yy_size_t );
+void *yyrealloc (void *,yy_size_t );
+void yyfree (void * );
#define yy_new_buffer yy_create_buffer
#define yy_set_interactive(is_interactive) \
{ \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_is_interactive = is_interactive; \
+ if ( ! YY_CURRENT_BUFFER ){ \
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
}
#define yy_set_bol(at_bol) \
{ \
- if ( ! yy_current_buffer ) \
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
- yy_current_buffer->yy_at_bol = at_bol; \
+ if ( ! YY_CURRENT_BUFFER ){\
+ yyensure_buffer_stack (); \
+ YY_CURRENT_BUFFER_LVALUE = \
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
+ } \
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
}
-#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
+
+/* Begin user sect3 */
typedef unsigned char YY_CHAR;
+
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+
typedef int yy_state_type;
+
+extern int yylineno;
+
+int yylineno = 1;
+
extern char *yytext;
#define yytext_ptr yytext
-static yy_state_type yy_get_previous_state YY_PROTO(( void ));
-static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
-static int yy_get_next_buffer YY_PROTO(( void ));
-static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+static yy_state_type yy_get_previous_state (void );
+static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
+static int yy_get_next_buffer (void );
+#if defined(__GNUC__) && __GNUC__ >= 3
+__attribute__((__noreturn__))
+#endif
+static void yy_fatal_error (yyconst char msg[] );
/* Done after the current pattern has been matched and before the
* corresponding action - sets up yytext.
*/
#define YY_DO_BEFORE_ACTION \
- yytext_ptr = yy_bp; \
- yyleng = (int) (yy_cp - yy_bp); \
- yy_hold_char = *yy_cp; \
+ (yytext_ptr) = yy_bp; \
+ yyleng = (size_t) (yy_cp - yy_bp); \
+ (yy_hold_char) = *yy_cp; \
*yy_cp = '\0'; \
- yy_c_buf_p = yy_cp;
+ (yy_c_buf_p) = yy_cp;
-#define YY_NUM_RULES 44
-#define YY_END_OF_BUFFER 45
-static yyconst short int yy_accept[298] =
+#define YY_NUM_RULES 46
+#define YY_END_OF_BUFFER 47
+/* This struct is not used in this scanner,
+ but its presence is necessary. */
+struct yy_trans_info
+ {
+ flex_int32_t yy_verify;
+ flex_int32_t yy_nxt;
+ };
+static yyconst flex_int16_t yy_accept[316] =
{ 0,
- 0, 0, 2, 2, 45, 43, 38, 36, 30, 43,
- 1, 31, 43, 27, 31, 27, 27, 26, 31, 42,
- 34, 32, 34, 43, 27, 40, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 40, 43, 2, 2, 3, 2, 2, 1, 2, 2,
+ 0, 0, 2, 2, 47, 45, 40, 38, 32, 45,
+ 1, 33, 33, 29, 33, 29, 29, 28, 33, 44,
+ 36, 34, 36, 45, 29, 42, 42, 42, 42, 42,
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
+ 42, 42, 45, 2, 2, 3, 2, 2, 1, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 38,
- 34, 0, 41, 32, 28, 35, 42, 0, 39, 42,
- 42, 0, 33, 37, 40, 40, 40, 40, 40, 40,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 40, 36, 0, 43, 34, 30, 37, 44, 0,
+ 41, 44, 44, 0, 35, 39, 42, 42, 42, 42,
- 40, 40, 40, 40, 10, 40, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 40, 29, 2, 2, 2,
+ 42, 42, 42, 42, 42, 42, 10, 42, 42, 42,
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
+ 31, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 42, 0, 0, 42, 0,
- 40, 40, 40, 40, 40, 9, 40, 40, 40, 40,
- 40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
- 40, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 44, 0, 0, 44, 0, 42, 42, 42, 42,
+ 42, 9, 42, 42, 42, 42, 42, 42, 42, 42,
+ 42, 42, 42, 42, 42, 42, 42, 42, 42, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 16, 40, 40, 40,
- 17, 19, 40, 40, 20, 40, 40, 40, 40, 6,
- 18, 40, 40, 12, 40, 40, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 5, 40, 40, 40,
- 14, 40, 40, 15, 24, 40, 13, 40, 11, 2,
+ 2, 2, 2, 2, 2, 2, 16, 42, 42, 42,
+ 17, 20, 42, 42, 21, 42, 42, 42, 42, 6,
+ 42, 18, 42, 42, 12, 22, 42, 42, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 40, 4, 40, 7, 25, 8, 40, 2,
- 2, 2, 2, 2, 2, 2, 40, 21, 40, 2,
- 2, 2, 23, 22, 2, 2, 0
+ 5, 42, 42, 42, 14, 42, 42, 15, 26, 42,
+ 42, 13, 42, 11, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 42, 4,
+ 42, 7, 27, 19, 8, 42, 2, 2, 2, 2,
+ 2, 2, 2, 2, 42, 23, 42, 2, 2, 2,
+ 25, 24, 2, 2, 0
} ;
-static yyconst int yy_ec[256] =
+static yyconst flex_int32_t yy_ec[256] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -330,13 +424,13 @@ static yyconst int yy_ec[256] =
10, 11, 12, 13, 14, 15, 16, 17, 17, 17,
17, 17, 17, 17, 17, 17, 17, 1, 18, 19,
20, 21, 1, 1, 22, 22, 22, 22, 22, 22,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
23, 24, 25, 26, 27, 1, 28, 29, 30, 31,
32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
- 42, 43, 44, 45, 46, 47, 48, 37, 49, 37,
- 50, 37, 51, 52, 53, 1, 1, 1, 1, 1,
+ 42, 43, 44, 45, 46, 47, 48, 49, 50, 37,
+ 51, 37, 52, 53, 54, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -353,229 +447,242 @@ static yyconst int yy_ec[256] =
1, 1, 1, 1, 1
} ;
-static yyconst int yy_meta[54] =
+static yyconst flex_int32_t yy_meta[55] =
{ 0,
1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 1, 1, 1,
1, 1, 1, 1, 1, 1, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 1, 1, 1
+ 3, 1, 1, 1
} ;
-static yyconst short int yy_base[302] =
+static yyconst flex_int16_t yy_base[320] =
{ 0,
- 0, 0, 53, 0, 525, 526, 522, 526, 503, 517,
- 526, 501, 512, 526, 499, 95, 94, 94, 99, 105,
- 498, 114, 497, 513, 495, 466, 468, 470, 479, 471,
- 467, 0, 81, 102, 105, 479, 462, 458, 473, 94,
- 104, 452, 0, 501, 526, 482, 139, 0, 481, 492,
- 0, 479, 131, 132, 131, 125, 132, 478, 150, 477,
- 493, 475, 160, 115, 117, 126, 130, 125, 446, 183,
- 184, 186, 187, 123, 445, 180, 185, 192, 440, 489,
- 526, 485, 526, 526, 526, 526, 158, 486, 526, 162,
- 221, 485, 526, 526, 0, 440, 454, 444, 451, 437,
-
- 437, 442, 434, 451, 0, 432, 436, 436, 447, 438,
- 437, 195, 444, 426, 425, 433, 526, 0, 466, 0,
- 178, 0, 0, 0, 0, 222, 464, 0, 230, 233,
- 463, 0, 417, 65, 189, 208, 193, 205, 213, 220,
- 214, 235, 416, 218, 224, 227, 241, 234, 237, 243,
- 246, 231, 232, 245, 0, 275, 460, 278, 279, 459,
- 419, 432, 412, 422, 425, 0, 409, 408, 408, 406,
- 418, 415, 404, 408, 401, 416, 398, 406, 397, 398,
- 403, 287, 438, 288, 437, 182, 250, 239, 270, 275,
- 391, 266, 268, 271, 273, 274, 288, 279, 285, 281,
-
- 299, 390, 292, 287, 293, 298, 0, 399, 400, 394,
- 0, 0, 392, 401, 0, 385, 384, 398, 382, 0,
- 0, 383, 395, 0, 398, 393, 376, 294, 303, 302,
- 375, 374, 306, 312, 373, 305, 308, 313, 310, 372,
- 371, 314, 317, 370, 335, 332, 0, 376, 384, 370,
- 0, 379, 367, 0, 0, 371, 0, 370, 0, 362,
- 325, 336, 322, 361, 137, 323, 360, 359, 331, 358,
- 333, 357, 356, 0, 353, 0, 0, 0, 355, 349,
- 343, 327, 342, 340, 334, 338, 346, 0, 238, 344,
- 236, 339, 0, 0, 177, 102, 526, 392, 120, 395,
-
- 398
+ 0, 0, 54, 0, 553, 554, 550, 554, 531, 545,
+ 554, 529, 540, 554, 527, 97, 96, 96, 101, 107,
+ 526, 116, 525, 541, 523, 494, 496, 498, 507, 499,
+ 495, 0, 83, 104, 107, 507, 490, 486, 106, 96,
+ 491, 113, 479, 0, 529, 554, 510, 141, 0, 509,
+ 520, 0, 507, 133, 135, 130, 139, 141, 506, 150,
+ 505, 521, 503, 160, 123, 125, 137, 112, 130, 474,
+ 184, 185, 187, 188, 134, 473, 193, 183, 132, 194,
+ 467, 517, 554, 513, 554, 554, 554, 554, 221, 514,
+ 554, 222, 232, 513, 554, 554, 0, 468, 482, 472,
+
+ 479, 465, 465, 470, 462, 479, 0, 460, 464, 464,
+ 475, 466, 465, 459, 206, 471, 453, 461, 451, 459,
+ 554, 0, 492, 0, 178, 0, 0, 0, 0, 233,
+ 490, 0, 241, 244, 489, 0, 443, 67, 192, 189,
+ 219, 138, 203, 221, 180, 234, 442, 224, 223, 233,
+ 246, 239, 240, 236, 250, 251, 235, 253, 245, 255,
+ 0, 278, 486, 287, 288, 485, 445, 458, 438, 448,
+ 451, 0, 435, 434, 434, 432, 444, 441, 430, 434,
+ 427, 442, 441, 423, 431, 422, 437, 422, 427, 291,
+ 462, 297, 461, 244, 268, 259, 281, 286, 415, 275,
+
+ 277, 280, 283, 293, 284, 287, 295, 290, 308, 309,
+ 414, 303, 297, 315, 302, 310, 0, 423, 424, 418,
+ 0, 0, 416, 425, 0, 409, 408, 422, 406, 0,
+ 410, 0, 406, 418, 0, 0, 421, 416, 399, 314,
+ 312, 313, 398, 397, 311, 323, 396, 317, 319, 336,
+ 322, 395, 330, 394, 328, 342, 393, 392, 347, 345,
+ 0, 398, 406, 392, 0, 401, 389, 0, 0, 394,
+ 392, 0, 391, 0, 383, 338, 348, 337, 382, 346,
+ 341, 381, 380, 343, 351, 379, 356, 378, 373, 0,
+ 364, 0, 0, 0, 0, 367, 365, 364, 350, 363,
+
+ 362, 361, 359, 355, 374, 0, 337, 368, 237, 357,
+ 0, 0, 168, 127, 554, 416, 122, 419, 422
} ;
-static yyconst short int yy_def[302] =
+static yyconst flex_int16_t yy_def[320] =
{ 0,
- 297, 1, 297, 3, 297, 297, 297, 297, 297, 298,
- 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 299, 299, 299, 299, 299,
- 299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
- 299, 297, 300, 300, 297, 300, 301, 300, 300, 300,
- 300, 300, 300, 300, 300, 300, 300, 300, 300, 300,
- 300, 300, 300, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 300, 297,
- 297, 298, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 299, 299, 299, 299, 299, 299,
-
- 299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
- 299, 299, 299, 299, 299, 299, 297, 300, 300, 300,
- 301, 300, 300, 300, 300, 300, 300, 300, 300, 300,
- 300, 300, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 300, 297, 297, 297, 297, 297,
- 299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
- 299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
- 299, 300, 300, 300, 300, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-
- 63, 63, 63, 63, 63, 63, 299, 299, 299, 299,
- 299, 299, 299, 299, 299, 299, 299, 299, 299, 299,
- 299, 299, 299, 299, 299, 299, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 299, 299, 299, 299,
- 299, 299, 299, 299, 299, 299, 299, 299, 299, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 63, 63, 299, 299, 299, 299, 299, 299, 299, 63,
- 63, 63, 63, 63, 63, 63, 299, 299, 299, 63,
- 63, 63, 299, 299, 63, 63, 0, 297, 297, 297,
-
- 297
+ 315, 1, 315, 3, 315, 315, 315, 315, 315, 316,
+ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 317, 317, 317, 317, 317,
+ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
+ 317, 317, 315, 318, 318, 315, 318, 319, 318, 318,
+ 318, 318, 318, 318, 318, 318, 318, 318, 318, 318,
+ 318, 318, 318, 318, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 318, 315, 315, 316, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 315, 317, 317, 317, 317,
+
+ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
+ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
+ 315, 318, 318, 318, 319, 318, 318, 318, 318, 318,
+ 318, 318, 318, 318, 318, 318, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 318, 315, 315, 315, 315, 315, 317, 317, 317, 317,
+ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
+ 317, 317, 317, 317, 317, 317, 317, 317, 317, 318,
+ 318, 318, 318, 64, 64, 64, 64, 64, 64, 64,
+
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 317, 317, 317, 317,
+ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
+ 317, 317, 317, 317, 317, 317, 317, 317, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 317, 317, 317, 317, 317, 317, 317, 317, 317, 317,
+ 317, 317, 317, 317, 64, 64, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 317, 317,
+ 317, 317, 317, 317, 317, 317, 64, 64, 64, 64,
+
+ 64, 64, 64, 64, 317, 317, 317, 64, 64, 64,
+ 317, 317, 64, 64, 0, 315, 315, 315, 315
} ;
-static yyconst short int yy_nxt[580] =
+static yyconst flex_int16_t yy_nxt[609] =
{ 0,
6, 7, 8, 9, 10, 11, 12, 13, 14, 14,
15, 16, 14, 17, 18, 19, 20, 14, 21, 22,
23, 20, 14, 24, 14, 25, 6, 26, 27, 28,
29, 30, 31, 32, 33, 34, 32, 32, 35, 32,
- 32, 36, 37, 38, 39, 40, 32, 32, 41, 32,
- 14, 42, 14, 43, 44, 45, 46, 47, 48, 49,
- 50, 51, 51, 52, 53, 51, 54, 55, 56, 57,
- 51, 58, 59, 60, 57, 51, 61, 51, 62, 43,
- 63, 64, 65, 66, 67, 68, 69, 70, 71, 69,
- 69, 72, 69, 69, 73, 74, 75, 76, 77, 69,
-
- 69, 78, 69, 51, 79, 51, 86, 86, 102, 89,
- 87, 186, 133, 84, 84, 87, 103, 88, 84, 90,
- 93, 91, 95, 113, 93, 93, 91, 93, 92, 93,
- 104, 115, 106, 81, 105, 128, 107, 114, 116, 93,
- 108, 82, 125, 122, 123, 125, 129, 126, 130, 133,
- 123, 123, 126, 130, 127, 131, 132, 137, 136, 135,
- 132, 132, 133, 132, 133, 132, 139, 148, 138, 120,
- 133, 283, 133, 133, 156, 132, 133, 133, 159, 156,
- 82, 157, 122, 159, 133, 160, 133, 133, 133, 133,
- 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
-
- 133, 133, 133, 133, 133, 133, 133, 134, 133, 133,
- 140, 150, 142, 144, 151, 147, 143, 145, 141, 153,
- 187, 146, 176, 227, 133, 189, 154, 133, 152, 133,
- 133, 133, 133, 133, 133, 90, 133, 91, 182, 133,
- 133, 177, 91, 182, 92, 183, 184, 129, 188, 130,
- 190, 184, 133, 185, 130, 133, 131, 191, 192, 193,
- 133, 133, 194, 195, 196, 133, 197, 133, 198, 199,
- 201, 133, 200, 203, 133, 204, 205, 228, 133, 133,
- 206, 133, 133, 133, 133, 229, 133, 294, 133, 202,
- 133, 156, 133, 133, 87, 159, 156, 133, 157, 87,
-
- 159, 88, 160, 182, 184, 230, 231, 236, 182, 184,
- 183, 185, 232, 133, 233, 133, 234, 133, 133, 235,
- 133, 133, 133, 237, 238, 239, 133, 240, 133, 241,
- 243, 260, 133, 244, 133, 133, 246, 245, 261, 133,
- 133, 133, 262, 264, 267, 133, 133, 263, 270, 133,
- 133, 265, 133, 133, 266, 133, 268, 133, 269, 133,
- 133, 133, 271, 272, 133, 280, 282, 281, 284, 133,
- 133, 285, 133, 286, 133, 295, 291, 293, 133, 133,
- 133, 133, 133, 133, 292, 133, 133, 133, 296, 133,
- 133, 133, 82, 82, 82, 118, 290, 118, 121, 121,
-
- 121, 289, 288, 287, 133, 133, 133, 133, 133, 133,
- 279, 278, 277, 276, 275, 274, 273, 133, 133, 133,
- 133, 133, 133, 133, 259, 258, 257, 256, 255, 254,
- 253, 252, 251, 250, 249, 248, 247, 242, 133, 159,
- 156, 226, 225, 224, 223, 222, 221, 220, 219, 218,
- 217, 216, 215, 214, 213, 212, 211, 210, 209, 208,
- 207, 159, 156, 133, 133, 91, 158, 119, 181, 180,
- 179, 178, 175, 174, 173, 172, 171, 170, 169, 168,
- 167, 166, 165, 164, 163, 162, 161, 91, 158, 83,
- 80, 155, 149, 133, 123, 94, 120, 120, 123, 124,
-
- 123, 120, 119, 117, 112, 111, 110, 109, 101, 100,
- 99, 98, 97, 96, 84, 94, 81, 81, 84, 85,
- 84, 83, 81, 80, 297, 5, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297
+ 32, 36, 37, 38, 39, 40, 32, 32, 41, 42,
+ 32, 14, 43, 14, 44, 45, 46, 47, 48, 49,
+ 50, 51, 52, 52, 53, 54, 52, 55, 56, 57,
+ 58, 52, 59, 60, 61, 58, 52, 62, 52, 63,
+ 44, 64, 65, 66, 67, 68, 69, 70, 71, 72,
+ 70, 70, 73, 70, 70, 74, 75, 76, 77, 78,
+
+ 70, 70, 79, 80, 70, 52, 81, 52, 88, 88,
+ 104, 91, 89, 194, 137, 86, 86, 89, 105, 90,
+ 86, 92, 95, 93, 97, 116, 95, 95, 93, 95,
+ 94, 95, 106, 114, 108, 83, 107, 115, 109, 117,
+ 119, 95, 110, 84, 129, 126, 130, 120, 129, 132,
+ 142, 130, 127, 131, 127, 133, 136, 134, 127, 137,
+ 136, 136, 134, 136, 135, 136, 140, 139, 141, 124,
+ 137, 143, 137, 158, 137, 136, 137, 137, 152, 137,
+ 84, 137, 126, 198, 137, 137, 137, 137, 137, 137,
+ 137, 137, 137, 137, 137, 137, 137, 137, 137, 137,
+
+ 137, 137, 137, 137, 137, 137, 137, 138, 137, 137,
+ 137, 144, 156, 146, 148, 137, 151, 147, 149, 145,
+ 154, 159, 150, 195, 155, 201, 157, 137, 160, 196,
+ 137, 137, 137, 183, 137, 137, 137, 162, 165, 137,
+ 137, 137, 162, 165, 163, 166, 92, 199, 93, 190,
+ 137, 197, 184, 93, 190, 94, 191, 192, 133, 200,
+ 134, 202, 192, 204, 193, 134, 137, 135, 137, 203,
+ 137, 137, 205, 206, 207, 208, 209, 210, 212, 213,
+ 137, 137, 137, 137, 137, 239, 137, 137, 214, 215,
+ 216, 137, 137, 137, 162, 240, 211, 137, 137, 162,
+
+ 137, 163, 137, 89, 165, 241, 137, 190, 89, 165,
+ 90, 166, 190, 192, 191, 137, 242, 243, 192, 249,
+ 193, 244, 137, 245, 137, 246, 248, 137, 137, 247,
+ 137, 137, 250, 137, 137, 251, 252, 137, 253, 254,
+ 137, 256, 137, 257, 137, 258, 259, 276, 260, 137,
+ 137, 275, 278, 277, 279, 137, 137, 137, 137, 137,
+ 137, 137, 137, 280, 137, 281, 137, 282, 283, 137,
+ 137, 284, 285, 286, 287, 137, 288, 137, 297, 298,
+ 300, 299, 302, 137, 137, 137, 301, 312, 137, 137,
+ 137, 303, 137, 137, 137, 137, 304, 137, 137, 313,
+
+ 309, 310, 137, 137, 137, 311, 137, 314, 137, 137,
+ 137, 137, 308, 307, 306, 137, 84, 84, 84, 122,
+ 305, 122, 125, 125, 125, 137, 137, 137, 137, 137,
+ 137, 296, 295, 294, 293, 292, 291, 290, 289, 137,
+ 137, 137, 137, 137, 137, 137, 137, 274, 273, 272,
+ 271, 270, 269, 268, 267, 266, 265, 264, 263, 262,
+ 261, 255, 137, 165, 162, 238, 237, 236, 235, 234,
+ 233, 232, 231, 230, 229, 228, 227, 226, 225, 224,
+ 223, 222, 221, 220, 219, 218, 217, 165, 162, 137,
+ 137, 93, 164, 123, 189, 188, 187, 186, 185, 182,
+
+ 181, 180, 179, 178, 177, 176, 175, 174, 173, 172,
+ 171, 170, 169, 168, 167, 93, 164, 85, 82, 161,
+ 153, 137, 127, 96, 124, 124, 127, 128, 127, 124,
+ 123, 121, 118, 113, 112, 111, 103, 102, 101, 100,
+ 99, 98, 86, 96, 83, 83, 86, 87, 86, 85,
+ 83, 82, 315, 5, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
+
+ 315, 315, 315, 315, 315, 315, 315, 315
} ;
-static yyconst short int yy_chk[580] =
+static yyconst flex_int16_t yy_chk[609] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 3, 3, 3, 3, 3, 3, 3,
+ 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 16, 17, 33, 19,
- 18, 134, 134, 17, 16, 18, 33, 18, 19, 20,
- 22, 20, 299, 40, 22, 22, 20, 22, 20, 22,
- 34, 41, 35, 22, 34, 56, 35, 40, 41, 22,
- 35, 47, 53, 47, 56, 54, 57, 55, 57, 296,
- 53, 54, 55, 57, 55, 57, 59, 66, 65, 64,
- 59, 59, 64, 59, 65, 59, 68, 74, 67, 59,
- 74, 265, 68, 66, 87, 59, 63, 67, 90, 87,
- 121, 87, 121, 90, 265, 90, 63, 63, 63, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
-
- 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
- 70, 76, 71, 72, 77, 73, 71, 72, 70, 78,
- 135, 72, 112, 186, 295, 137, 78, 76, 77, 186,
- 70, 71, 77, 72, 73, 91, 135, 91, 126, 78,
- 137, 112, 91, 126, 91, 126, 129, 130, 136, 130,
- 138, 129, 138, 129, 130, 136, 130, 139, 140, 141,
- 139, 141, 142, 144, 145, 144, 146, 140, 147, 148,
- 150, 145, 149, 151, 146, 152, 153, 187, 152, 153,
- 154, 148, 142, 291, 149, 188, 188, 289, 147, 150,
- 150, 156, 154, 151, 158, 159, 156, 187, 156, 158,
-
- 159, 158, 159, 182, 184, 189, 190, 196, 182, 184,
- 182, 184, 192, 192, 193, 193, 194, 189, 194, 195,
- 195, 196, 190, 197, 198, 199, 198, 200, 200, 201,
- 203, 228, 199, 204, 204, 197, 206, 205, 229, 203,
- 205, 228, 230, 234, 238, 206, 201, 233, 243, 230,
- 229, 236, 236, 233, 237, 237, 239, 239, 242, 234,
- 238, 242, 245, 246, 243, 261, 263, 262, 266, 263,
- 266, 269, 261, 271, 282, 290, 282, 287, 269, 246,
- 271, 285, 245, 262, 286, 286, 292, 284, 292, 283,
- 281, 290, 298, 298, 298, 300, 280, 300, 301, 301,
-
- 301, 279, 275, 273, 272, 270, 268, 267, 264, 260,
- 258, 256, 253, 252, 250, 249, 248, 244, 241, 240,
- 235, 232, 231, 227, 226, 225, 223, 222, 219, 218,
- 217, 216, 214, 213, 210, 209, 208, 202, 191, 185,
- 183, 181, 180, 179, 178, 177, 176, 175, 174, 173,
- 172, 171, 170, 169, 168, 167, 165, 164, 163, 162,
- 161, 160, 157, 143, 133, 131, 127, 119, 116, 115,
- 114, 113, 111, 110, 109, 108, 107, 106, 104, 103,
- 102, 101, 100, 99, 98, 97, 96, 92, 88, 82,
- 80, 79, 75, 69, 62, 61, 60, 58, 52, 50,
-
- 49, 46, 44, 42, 39, 38, 37, 36, 31, 30,
- 29, 28, 27, 26, 25, 24, 23, 21, 15, 13,
- 12, 10, 9, 7, 5, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297, 297,
- 297, 297, 297, 297, 297, 297, 297, 297, 297
+ 3, 3, 3, 3, 3, 3, 3, 3, 16, 17,
+ 33, 19, 18, 138, 138, 17, 16, 18, 33, 18,
+ 19, 20, 22, 20, 317, 40, 22, 22, 20, 22,
+ 20, 22, 34, 39, 35, 22, 34, 39, 35, 40,
+ 42, 22, 35, 48, 54, 48, 56, 42, 55, 57,
+ 68, 56, 54, 56, 55, 58, 60, 58, 57, 68,
+ 60, 60, 58, 60, 58, 60, 66, 65, 67, 60,
+ 65, 69, 66, 79, 314, 60, 64, 69, 75, 79,
+ 125, 75, 125, 142, 67, 142, 64, 64, 64, 64,
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+ 64, 71, 78, 72, 73, 313, 74, 72, 73, 71,
+ 77, 80, 73, 139, 77, 145, 78, 145, 80, 140,
+ 78, 71, 72, 115, 73, 74, 140, 89, 92, 139,
+ 77, 80, 89, 92, 89, 92, 93, 143, 93, 130,
+ 143, 141, 115, 93, 130, 93, 130, 133, 134, 144,
+ 134, 146, 133, 149, 133, 134, 141, 134, 144, 148,
+ 149, 148, 150, 151, 152, 153, 154, 155, 156, 157,
+ 150, 146, 157, 154, 309, 194, 152, 153, 158, 159,
+ 160, 194, 159, 151, 162, 195, 155, 155, 156, 162,
+
+ 158, 162, 160, 164, 165, 196, 196, 190, 164, 165,
+ 164, 165, 190, 192, 190, 195, 197, 198, 192, 205,
+ 192, 200, 200, 201, 201, 202, 204, 202, 197, 203,
+ 203, 205, 206, 198, 206, 207, 208, 208, 209, 210,
+ 204, 212, 207, 213, 213, 214, 215, 241, 216, 215,
+ 212, 240, 245, 242, 246, 209, 210, 216, 245, 241,
+ 242, 240, 214, 248, 248, 249, 249, 250, 251, 251,
+ 246, 253, 255, 256, 259, 255, 260, 253, 276, 277,
+ 280, 278, 284, 250, 278, 276, 281, 307, 281, 256,
+ 284, 285, 260, 280, 259, 277, 287, 299, 285, 308,
+
+ 299, 304, 304, 287, 310, 305, 303, 310, 302, 301,
+ 300, 298, 297, 296, 291, 308, 316, 316, 316, 318,
+ 289, 318, 319, 319, 319, 288, 286, 283, 282, 279,
+ 275, 273, 271, 270, 267, 266, 264, 263, 262, 258,
+ 257, 254, 252, 247, 244, 243, 239, 238, 237, 234,
+ 233, 231, 229, 228, 227, 226, 224, 223, 220, 219,
+ 218, 211, 199, 193, 191, 189, 188, 187, 186, 185,
+ 184, 183, 182, 181, 180, 179, 178, 177, 176, 175,
+ 174, 173, 171, 170, 169, 168, 167, 166, 163, 147,
+ 137, 135, 131, 123, 120, 119, 118, 117, 116, 114,
+
+ 113, 112, 111, 110, 109, 108, 106, 105, 104, 103,
+ 102, 101, 100, 99, 98, 94, 90, 84, 82, 81,
+ 76, 70, 63, 62, 61, 59, 53, 51, 50, 47,
+ 45, 43, 41, 38, 37, 36, 31, 30, 29, 28,
+ 27, 26, 25, 24, 23, 21, 15, 13, 12, 10,
+ 9, 7, 5, 315, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
+ 315, 315, 315, 315, 315, 315, 315, 315, 315, 315,
+
+ 315, 315, 315, 315, 315, 315, 315, 315
} ;
static yy_state_type yy_last_accepting_state;
static char *yy_last_accepting_cpos;
+extern int yy_flex_debug;
+int yy_flex_debug = 0;
+
/* The intent behind this definition is that it'll catch
* any uses of REJECT which flex missed.
*/
@@ -584,17 +691,14 @@ static char *yy_last_accepting_cpos;
#define YY_MORE_ADJ 0
#define YY_RESTORE_YY_MORE_OFFSET
char *yytext;
-#line 1 "scan.l"
-#define INITIAL 0
-#line 2 "scan.l"
-/* scan.l: the (f)lex description file for the scanner. */
-
+#line 1 "../../bc/scan.l"
/* This file is part of GNU bc.
- Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -603,10 +707,8 @@ char *yytext;
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -616,6 +718,8 @@ char *yytext;
Bellingham, WA 98226-9062
*************************************************************************/
+/* scan.l: the (f)lex description file for the scanner. */
+#line 31 "../../bc/scan.l"
#include "bcdefs.h"
#include "bc.h"
@@ -636,7 +740,7 @@ char *yytext;
/* We want to define our own yywrap. */
#undef yywrap
-_PROTOTYPE(int yywrap, (void));
+int yywrap (void);
#if defined(LIBEDIT)
/* Support for the BSD libedit with history for
@@ -647,40 +751,30 @@ _PROTOTYPE(int yywrap, (void));
/* Have input call the following function. */
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
- bcel_input((char *)buf, &result, max_size)
+ bcel_input((char *)buf, (yy_size_t *)&result, max_size)
/* Variables to help interface editline with bc. */
static const char *bcel_line = (char *)NULL;
static int bcel_len = 0;
-
-/* Required to get rid of that ugly ? default prompt! */
-char *
-null_prompt (EditLine *el)
-{
- return "";
-}
-
-
/* bcel_input puts upto MAX characters into BUF with the number put in
BUF placed in *RESULT. If the yy input file is the same as
stdin, use editline. Otherwise, just read it.
*/
static void
-bcel_input (buf, result, max)
- char *buf;
- int *result;
- int max;
+bcel_input (char *buf, yy_size_t *result, int max)
{
+ ssize_t rdsize;
if (!edit || yyin != stdin)
{
- while ( (*result = read( fileno(yyin), buf, max )) < 0 )
+ while ( (rdsize = read( fileno(yyin), buf, max )) < 0 )
if (errno != EINTR)
{
yyerror( "read() in flex scanner failed" );
- exit (1);
+ bc_exit (1);
}
+ *result = (yy_size_t) rdsize;
return;
}
@@ -731,7 +825,6 @@ static int rl_len = 0;
/* Definitions for readline access. */
extern FILE *rl_instream;
-_PROTOTYPE(char *readline, (char *));
/* rl_input puts upto MAX characters into BUF with the number put in
BUF placed in *RESULT. If the yy input file is the same as
@@ -739,10 +832,7 @@ _PROTOTYPE(char *readline, (char *));
*/
static void
-rl_input (buf, result, max)
- char *buf;
- int *result;
- int max;
+rl_input (char *buf, int *result, int max)
{
if (yyin != rl_instream)
{
@@ -750,7 +840,7 @@ rl_input (buf, result, max)
if (errno != EINTR)
{
yyerror( "read() in flex scanner failed" );
- exit (1);
+ bc_exit (1);
}
return;
}
@@ -803,9 +893,54 @@ rl_input (buf, result, max)
YY_FATAL_ERROR( "read() in flex scanner failed" );
#endif
+
+#line 898 "scan.c"
+
+#define INITIAL 0
#define slcomment 1
-#line 809 "lex.yy.c"
+#ifndef YY_NO_UNISTD_H
+/* Special case for "unistd.h", since it is non-ANSI. We include it way
+ * down here because we want the user's section 1 to have been scanned first.
+ * The user has a chance to override it with an option.
+ */
+#include <unistd.h>
+#endif
+
+#ifndef YY_EXTRA_TYPE
+#define YY_EXTRA_TYPE void *
+#endif
+
+static int yy_init_globals (void );
+
+/* Accessor methods to globals.
+ These are made visible to non-reentrant scanners for convenience. */
+
+int yylex_destroy (void );
+
+int yyget_debug (void );
+
+void yyset_debug (int debug_flag );
+
+YY_EXTRA_TYPE yyget_extra (void );
+
+void yyset_extra (YY_EXTRA_TYPE user_defined );
+
+FILE *yyget_in (void );
+
+void yyset_in (FILE * _in_str );
+
+FILE *yyget_out (void );
+
+void yyset_out (FILE * _out_str );
+
+int yyget_leng (void );
+
+char *yyget_text (void );
+
+int yyget_lineno (void );
+
+void yyset_lineno (int _line_number );
/* Macros after this point can all be overridden by user definitions in
* section 1.
@@ -813,65 +948,34 @@ rl_input (buf, result, max)
#ifndef YY_SKIP_YYWRAP
#ifdef __cplusplus
-extern "C" int yywrap YY_PROTO(( void ));
+extern "C" int yywrap (void );
#else
-extern int yywrap YY_PROTO(( void ));
+extern int yywrap (void );
#endif
#endif
#ifndef YY_NO_UNPUT
-static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+
+ static void yyunput (int c,char *buf_ptr );
+
#endif
#ifndef yytext_ptr
-static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+static void yy_flex_strncpy (char *,yyconst char *,int );
#endif
#ifdef YY_NEED_STRLEN
-static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+static int yy_flex_strlen (yyconst char * );
#endif
#ifndef YY_NO_INPUT
+
#ifdef __cplusplus
-static int yyinput YY_PROTO(( void ));
+static int yyinput (void );
#else
-static int input YY_PROTO(( void ));
-#endif
+static int input (void );
#endif
-#if YY_STACK_USED
-static int yy_start_stack_ptr = 0;
-static int yy_start_stack_depth = 0;
-static int *yy_start_stack = 0;
-#ifndef YY_NO_PUSH_STATE
-static void yy_push_state YY_PROTO(( int new_state ));
-#endif
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state YY_PROTO(( void ));
-#endif
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state YY_PROTO(( void ));
-#endif
-
-#else
-#define YY_NO_PUSH_STATE 1
-#define YY_NO_POP_STATE 1
-#define YY_NO_TOP_STATE 1
-#endif
-
-#ifdef YY_MALLOC_DECL
-YY_MALLOC_DECL
-#else
-#if __STDC__
-#ifndef __cplusplus
-#include <stdlib.h>
-#endif
-#else
-/* Just try to get by without declaring the routines. This will fail
- * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
- * or sizeof(void*) != sizeof(int).
- */
-#endif
#endif
/* Amount of stuff to slurp up with each read. */
@@ -880,12 +984,11 @@ YY_MALLOC_DECL
#endif
/* Copy whatever the last rule matched to the standard output. */
-
#ifndef ECHO
/* This used to be an fputs(), but since the string might contain NUL's,
* we now use fwrite().
*/
-#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#define ECHO fwrite( yytext, yyleng, 1, yyout )
#endif
/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
@@ -893,9 +996,10 @@ YY_MALLOC_DECL
*/
#ifndef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
- if ( yy_current_buffer->yy_is_interactive ) \
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
{ \
- int c = '*', n; \
+ int c = '*'; \
+ size_t n; \
for ( n = 0; n < max_size && \
(c = getc( yyin )) != EOF && c != '\n'; ++n ) \
buf[n] = (char) c; \
@@ -905,9 +1009,22 @@ YY_MALLOC_DECL
YY_FATAL_ERROR( "input in flex scanner failed" ); \
result = n; \
} \
- else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
- && ferror( yyin ) ) \
- YY_FATAL_ERROR( "input in flex scanner failed" );
+ else \
+ { \
+ errno=0; \
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
+ { \
+ if( errno != EINTR) \
+ { \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ break; \
+ } \
+ errno=0; \
+ clearerr(yyin); \
+ } \
+ }\
+\
+
#endif
/* No semi-colon after return; correct usage is to write "yyterminate();" -
@@ -928,12 +1045,18 @@ YY_MALLOC_DECL
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
#endif
+/* end tables serialization structures and prototypes */
+
/* Default declaration of generated scanner - a define so the user can
* easily add parameters.
*/
#ifndef YY_DECL
-#define YY_DECL int yylex YY_PROTO(( void ))
-#endif
+#define YY_DECL_IS_OURS 1
+
+extern int yylex (void);
+
+#define YY_DECL int yylex (void)
+#endif /* !YY_DECL */
/* Code executed at the beginning of each rule, after yytext and yyleng
* have been set up.
@@ -944,32 +1067,34 @@ YY_MALLOC_DECL
/* Code executed at the end of each rule. */
#ifndef YY_BREAK
-#define YY_BREAK break;
+#define YY_BREAK /*LINTED*/break;
#endif
#define YY_RULE_SETUP \
YY_USER_ACTION
+/** The main scanner function which does all the work.
+ */
YY_DECL
- {
+{
register yy_state_type yy_current_state;
register char *yy_cp, *yy_bp;
register int yy_act;
+
+#line 208 "../../bc/scan.l"
-#line 222 "scan.l"
+#line 1087 "scan.c"
-#line 962 "lex.yy.c"
-
- if ( yy_init )
+ if ( !(yy_init) )
{
- yy_init = 0;
+ (yy_init) = 1;
#ifdef YY_USER_INIT
YY_USER_INIT;
#endif
- if ( ! yy_start )
- yy_start = 1; /* first start state */
+ if ( ! (yy_start) )
+ (yy_start) = 1; /* first start state */
if ( ! yyin )
yyin = stdin;
@@ -977,73 +1102,73 @@ YY_DECL
if ( ! yyout )
yyout = stdout;
- if ( ! yy_current_buffer )
- yy_current_buffer =
- yy_create_buffer( yyin, YY_BUF_SIZE );
+ if ( ! YY_CURRENT_BUFFER ) {
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer(yyin,YY_BUF_SIZE );
+ }
- yy_load_buffer_state();
+ yy_load_buffer_state( );
}
- while ( 1 ) /* loops until end-of-file is reached */
+ while (/*CONSTCOND*/ 1 ) /* loops until end-of-file is reached */
{
- yy_cp = yy_c_buf_p;
+ yy_cp = (yy_c_buf_p);
/* Support of yytext. */
- *yy_cp = yy_hold_char;
+ *yy_cp = (yy_hold_char);
/* yy_bp points to the position in yy_ch_buf of the start of
* the current run.
*/
yy_bp = yy_cp;
- yy_current_state = yy_start;
+ yy_current_state = (yy_start);
yy_match:
do
{
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
if ( yy_accept[yy_current_state] )
{
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 298 )
+ if ( yy_current_state >= 316 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
++yy_cp;
}
- while ( yy_base[yy_current_state] != 526 );
+ while ( yy_base[yy_current_state] != 554 );
yy_find_action:
yy_act = yy_accept[yy_current_state];
if ( yy_act == 0 )
{ /* have to back up */
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
yy_act = yy_accept[yy_current_state];
}
YY_DO_BEFORE_ACTION;
-
do_action: /* This label is used only to access EOF actions. */
-
switch ( yy_act )
{ /* beginning of action switch */
case 0: /* must back up */
/* undo the effects of YY_DO_BEFORE_ACTION */
- *yy_cp = yy_hold_char;
- yy_cp = yy_last_accepting_cpos;
- yy_current_state = yy_last_accepting_state;
+ *yy_cp = (yy_hold_char);
+ yy_cp = (yy_last_accepting_cpos);
+ yy_current_state = (yy_last_accepting_state);
goto yy_find_action;
case 1:
YY_RULE_SETUP
-#line 223 "scan.l"
+#line 209 "../../bc/scan.l"
{
if (!std_only)
BEGIN(slcomment);
@@ -1053,102 +1178,113 @@ YY_RULE_SETUP
YY_BREAK
case 2:
YY_RULE_SETUP
-#line 229 "scan.l"
+#line 215 "../../bc/scan.l"
{ BEGIN(INITIAL); }
YY_BREAK
case 3:
+/* rule 3 can match eol */
YY_RULE_SETUP
-#line 230 "scan.l"
+#line 216 "../../bc/scan.l"
{ line_no++; BEGIN(INITIAL); return(ENDOFLINE); }
YY_BREAK
case 4:
YY_RULE_SETUP
-#line 231 "scan.l"
+#line 217 "../../bc/scan.l"
return(Define);
YY_BREAK
case 5:
YY_RULE_SETUP
-#line 232 "scan.l"
+#line 218 "../../bc/scan.l"
return(Break);
YY_BREAK
case 6:
YY_RULE_SETUP
-#line 233 "scan.l"
+#line 219 "../../bc/scan.l"
return(Quit);
YY_BREAK
case 7:
YY_RULE_SETUP
-#line 234 "scan.l"
+#line 220 "../../bc/scan.l"
return(Length);
YY_BREAK
case 8:
YY_RULE_SETUP
-#line 235 "scan.l"
+#line 221 "../../bc/scan.l"
return(Return);
YY_BREAK
case 9:
YY_RULE_SETUP
-#line 236 "scan.l"
+#line 222 "../../bc/scan.l"
return(For);
YY_BREAK
case 10:
YY_RULE_SETUP
-#line 237 "scan.l"
+#line 223 "../../bc/scan.l"
return(If);
YY_BREAK
case 11:
YY_RULE_SETUP
-#line 238 "scan.l"
+#line 224 "../../bc/scan.l"
return(While);
YY_BREAK
case 12:
YY_RULE_SETUP
-#line 239 "scan.l"
+#line 225 "../../bc/scan.l"
return(Sqrt);
YY_BREAK
case 13:
YY_RULE_SETUP
-#line 240 "scan.l"
+#line 226 "../../bc/scan.l"
return(Scale);
YY_BREAK
case 14:
YY_RULE_SETUP
-#line 241 "scan.l"
+#line 227 "../../bc/scan.l"
return(Ibase);
YY_BREAK
case 15:
YY_RULE_SETUP
-#line 242 "scan.l"
+#line 228 "../../bc/scan.l"
return(Obase);
YY_BREAK
case 16:
YY_RULE_SETUP
-#line 243 "scan.l"
+#line 229 "../../bc/scan.l"
return(Auto);
YY_BREAK
case 17:
YY_RULE_SETUP
-#line 244 "scan.l"
+#line 230 "../../bc/scan.l"
return(Else);
YY_BREAK
case 18:
YY_RULE_SETUP
-#line 245 "scan.l"
+#line 231 "../../bc/scan.l"
return(Read);
YY_BREAK
case 19:
YY_RULE_SETUP
-#line 246 "scan.l"
-return(Halt);
+#line 232 "../../bc/scan.l"
+return(Random);
YY_BREAK
case 20:
YY_RULE_SETUP
-#line 247 "scan.l"
-return(Last);
+#line 233 "../../bc/scan.l"
+return(Halt);
YY_BREAK
case 21:
YY_RULE_SETUP
-#line 248 "scan.l"
+#line 234 "../../bc/scan.l"
+return(Last);
+ YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 235 "../../bc/scan.l"
+return(Void);
+ YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 236 "../../bc/scan.l"
{
#if defined(READLINE) || defined(LIBEDIT)
return(HistoryVar);
@@ -1157,29 +1293,29 @@ YY_RULE_SETUP
#endif
}
YY_BREAK
-case 22:
+case 24:
YY_RULE_SETUP
-#line 256 "scan.l"
+#line 244 "../../bc/scan.l"
return(Warranty);
YY_BREAK
-case 23:
+case 25:
YY_RULE_SETUP
-#line 257 "scan.l"
+#line 245 "../../bc/scan.l"
return(Continue);
YY_BREAK
-case 24:
+case 26:
YY_RULE_SETUP
-#line 258 "scan.l"
+#line 246 "../../bc/scan.l"
return(Print);
YY_BREAK
-case 25:
+case 27:
YY_RULE_SETUP
-#line 259 "scan.l"
+#line 247 "../../bc/scan.l"
return(Limits);
YY_BREAK
-case 26:
+case 28:
YY_RULE_SETUP
-#line 260 "scan.l"
+#line 248 "../../bc/scan.l"
{
#ifdef DOT_IS_LAST
return(Last);
@@ -1188,46 +1324,46 @@ YY_RULE_SETUP
#endif
}
YY_BREAK
-case 27:
+case 29:
YY_RULE_SETUP
-#line 267 "scan.l"
+#line 255 "../../bc/scan.l"
{ yylval.c_value = yytext[0];
return((int)yytext[0]); }
YY_BREAK
-case 28:
+case 30:
YY_RULE_SETUP
-#line 269 "scan.l"
+#line 257 "../../bc/scan.l"
{ return(AND); }
YY_BREAK
-case 29:
+case 31:
YY_RULE_SETUP
-#line 270 "scan.l"
+#line 258 "../../bc/scan.l"
{ return(OR); }
YY_BREAK
-case 30:
+case 32:
YY_RULE_SETUP
-#line 271 "scan.l"
+#line 259 "../../bc/scan.l"
{ return(NOT); }
YY_BREAK
-case 31:
+case 33:
YY_RULE_SETUP
-#line 272 "scan.l"
+#line 260 "../../bc/scan.l"
{ yylval.c_value = yytext[0]; return((int)yytext[0]); }
YY_BREAK
-case 32:
+case 34:
YY_RULE_SETUP
-#line 273 "scan.l"
+#line 261 "../../bc/scan.l"
{ yylval.c_value = yytext[0]; return(ASSIGN_OP); }
YY_BREAK
-case 33:
+case 35:
YY_RULE_SETUP
-#line 274 "scan.l"
+#line 262 "../../bc/scan.l"
{
#ifdef OLD_EQ_OP
char warn_save;
warn_save = warn_not_std;
warn_not_std = TRUE;
- warn ("Old fashioned =<op>");
+ ct_warn ("Old fashioned =<op>");
warn_not_std = warn_save;
yylval.c_value = yytext[1];
#else
@@ -1237,34 +1373,36 @@ YY_RULE_SETUP
return(ASSIGN_OP);
}
YY_BREAK
-case 34:
+case 36:
YY_RULE_SETUP
-#line 288 "scan.l"
+#line 276 "../../bc/scan.l"
{ yylval.s_value = strcopyof(yytext); return(REL_OP); }
YY_BREAK
-case 35:
+case 37:
YY_RULE_SETUP
-#line 289 "scan.l"
+#line 277 "../../bc/scan.l"
{ yylval.c_value = yytext[0]; return(INCR_DECR); }
YY_BREAK
-case 36:
+case 38:
+/* rule 38 can match eol */
YY_RULE_SETUP
-#line 290 "scan.l"
+#line 278 "../../bc/scan.l"
{ line_no++; return(ENDOFLINE); }
YY_BREAK
-case 37:
+case 39:
+/* rule 39 can match eol */
YY_RULE_SETUP
-#line 291 "scan.l"
+#line 279 "../../bc/scan.l"
{ line_no++; /* ignore a "quoted" newline */ }
YY_BREAK
-case 38:
+case 40:
YY_RULE_SETUP
-#line 292 "scan.l"
+#line 280 "../../bc/scan.l"
{ /* ignore spaces and tabs */ }
YY_BREAK
-case 39:
+case 41:
YY_RULE_SETUP
-#line 293 "scan.l"
+#line 281 "../../bc/scan.l"
{
int c;
@@ -1287,16 +1425,17 @@ YY_RULE_SETUP
}
}
YY_BREAK
-case 40:
+case 42:
YY_RULE_SETUP
-#line 314 "scan.l"
+#line 302 "../../bc/scan.l"
{ yylval.s_value = strcopyof(yytext); return(NAME); }
YY_BREAK
-case 41:
+case 43:
+/* rule 43 can match eol */
YY_RULE_SETUP
-#line 315 "scan.l"
+#line 303 "../../bc/scan.l"
{
- unsigned char *look;
+ const char *look;
int count = 0;
yylval.s_value = strcopyof(yytext);
for (look = yytext; *look != 0; look++)
@@ -1308,11 +1447,12 @@ YY_RULE_SETUP
return(STRING);
}
YY_BREAK
-case 42:
+case 44:
+/* rule 44 can match eol */
YY_RULE_SETUP
-#line 327 "scan.l"
+#line 315 "../../bc/scan.l"
{
- unsigned char *src, *dst;
+ char *src, *dst;
int len;
/* remove a trailing decimal point. */
len = strlen(yytext);
@@ -1331,6 +1471,11 @@ YY_RULE_SETUP
src++; src++;
line_no++;
}
+ if (*src == ',')
+ {
+ src++;
+ ct_warn("Commas in numbers");
+ }
else
*dst++ = *src++;
}
@@ -1339,9 +1484,9 @@ YY_RULE_SETUP
return(NUMBER);
}
YY_BREAK
-case 43:
+case 45:
YY_RULE_SETUP
-#line 354 "scan.l"
+#line 347 "../../bc/scan.l"
{
if (yytext[0] < ' ')
yyerror ("illegal character: ^%c",yytext[0] + '@');
@@ -1352,12 +1497,12 @@ YY_RULE_SETUP
yyerror ("illegal character: %s",yytext);
}
YY_BREAK
-case 44:
+case 46:
YY_RULE_SETUP
-#line 363 "scan.l"
+#line 356 "../../bc/scan.l"
ECHO;
YY_BREAK
-#line 1361 "lex.yy.c"
+#line 1506 "scan.c"
case YY_STATE_EOF(INITIAL):
case YY_STATE_EOF(slcomment):
yyterminate();
@@ -1365,26 +1510,26 @@ case YY_STATE_EOF(slcomment):
case YY_END_OF_BUFFER:
{
/* Amount of text matched not including the EOB char. */
- int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
/* Undo the effects of YY_DO_BEFORE_ACTION. */
- *yy_cp = yy_hold_char;
+ *yy_cp = (yy_hold_char);
YY_RESTORE_YY_MORE_OFFSET
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
{
/* We're scanning a new file or input source. It's
* possible that this happened because the user
* just pointed yyin at a new source and called
* yylex(). If so, then we have to assure
- * consistency between yy_current_buffer and our
+ * consistency between YY_CURRENT_BUFFER and our
* globals. Here is the right place to do so, because
* this is the first action (other than possibly a
* back-up) that will match for the new input source.
*/
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yy_current_buffer->yy_input_file = yyin;
- yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
}
/* Note that here we test for yy_c_buf_p "<=" to the position
@@ -1394,13 +1539,13 @@ case YY_STATE_EOF(slcomment):
* end-of-buffer state). Contrast this with the test
* in input().
*/
- if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
{ /* This was really a NUL. */
yy_state_type yy_next_state;
- yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state( );
/* Okay, we're now positioned to make the NUL
* transition. We couldn't have
@@ -1413,30 +1558,30 @@ case YY_STATE_EOF(slcomment):
yy_next_state = yy_try_NUL_trans( yy_current_state );
- yy_bp = yytext_ptr + YY_MORE_ADJ;
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
if ( yy_next_state )
{
/* Consume the NUL. */
- yy_cp = ++yy_c_buf_p;
+ yy_cp = ++(yy_c_buf_p);
yy_current_state = yy_next_state;
goto yy_match;
}
else
{
- yy_cp = yy_c_buf_p;
+ yy_cp = (yy_c_buf_p);
goto yy_find_action;
}
}
- else switch ( yy_get_next_buffer() )
+ else switch ( yy_get_next_buffer( ) )
{
case EOB_ACT_END_OF_FILE:
{
- yy_did_buffer_switch_on_eof = 0;
+ (yy_did_buffer_switch_on_eof) = 0;
- if ( yywrap() )
+ if ( yywrap( ) )
{
/* Note: because we've taken care in
* yy_get_next_buffer() to have set up
@@ -1447,7 +1592,7 @@ case YY_STATE_EOF(slcomment):
* YY_NULL, it'll still work - another
* YY_NULL will get returned.
*/
- yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
yy_act = YY_STATE_EOF(YY_START);
goto do_action;
@@ -1455,30 +1600,30 @@ case YY_STATE_EOF(slcomment):
else
{
- if ( ! yy_did_buffer_switch_on_eof )
+ if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
}
break;
}
case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p =
- yytext_ptr + yy_amount_of_matched_text;
+ (yy_c_buf_p) =
+ (yytext_ptr) + yy_amount_of_matched_text;
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state( );
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
goto yy_match;
case EOB_ACT_LAST_MATCH:
- yy_c_buf_p =
- &yy_current_buffer->yy_ch_buf[yy_n_chars];
+ (yy_c_buf_p) =
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
- yy_current_state = yy_get_previous_state();
+ yy_current_state = yy_get_previous_state( );
- yy_cp = yy_c_buf_p;
- yy_bp = yytext_ptr + YY_MORE_ADJ;
+ yy_cp = (yy_c_buf_p);
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
goto yy_find_action;
}
break;
@@ -1489,8 +1634,7 @@ case YY_STATE_EOF(slcomment):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
- } /* end of yylex */
-
+} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
*
@@ -1499,21 +1643,20 @@ case YY_STATE_EOF(slcomment):
* EOB_ACT_CONTINUE_SCAN - continue scanning from current position
* EOB_ACT_END_OF_FILE - end of file
*/
-
-static int yy_get_next_buffer()
- {
- register char *dest = yy_current_buffer->yy_ch_buf;
- register char *source = yytext_ptr;
+static int yy_get_next_buffer (void)
+{
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
+ register char *source = (yytext_ptr);
register int number_to_move, i;
int ret_val;
- if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
YY_FATAL_ERROR(
"fatal flex scanner internal error--end of buffer missed" );
- if ( yy_current_buffer->yy_fill_buffer == 0 )
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
{ /* Don't try to fill the buffer, so this is an EOF. */
- if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
{
/* We matched a single character, the EOB, so
* treat this as a final EOF.
@@ -1533,34 +1676,30 @@ static int yy_get_next_buffer()
/* Try to read more data. */
/* First move last chars to start of buffer. */
- number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
for ( i = 0; i < number_to_move; ++i )
*(dest++) = *(source++);
- if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
/* don't do the read, it's not guaranteed to return an EOF,
* just force an EOF
*/
- yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
else
{
- int num_to_read =
- yy_current_buffer->yy_buf_size - number_to_move - 1;
+ int num_to_read =
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
-#ifdef YY_USES_REJECT
- YY_FATAL_ERROR(
-"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
-#else
/* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = yy_current_buffer;
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
int yy_c_buf_p_offset =
- (int) (yy_c_buf_p - b->yy_ch_buf);
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
@@ -1573,8 +1712,7 @@ static int yy_get_next_buffer()
b->yy_ch_buf = (char *)
/* Include room in for 2 EOB chars. */
- yy_flex_realloc( (void *) b->yy_ch_buf,
- b->yy_buf_size + 2 );
+ yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
}
else
/* Can't grow it, we don't own it. */
@@ -1584,35 +1722,35 @@ static int yy_get_next_buffer()
YY_FATAL_ERROR(
"fatal error - scanner input buffer overflow" );
- yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
- num_to_read = yy_current_buffer->yy_buf_size -
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
number_to_move - 1;
-#endif
+
}
if ( num_to_read > YY_READ_BUF_SIZE )
num_to_read = YY_READ_BUF_SIZE;
/* Read in more data. */
- YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
- yy_n_chars, num_to_read );
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+ (yy_n_chars), (size_t) num_to_read );
- yy_current_buffer->yy_n_chars = yy_n_chars;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
- if ( yy_n_chars == 0 )
+ if ( (yy_n_chars) == 0 )
{
if ( number_to_move == YY_MORE_ADJ )
{
ret_val = EOB_ACT_END_OF_FILE;
- yyrestart( yyin );
+ yyrestart(yyin );
}
else
{
ret_val = EOB_ACT_LAST_MATCH;
- yy_current_buffer->yy_buffer_status =
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
YY_BUFFER_EOF_PENDING;
}
}
@@ -1620,152 +1758,149 @@ static int yy_get_next_buffer()
else
ret_val = EOB_ACT_CONTINUE_SCAN;
- yy_n_chars += number_to_move;
- yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
- yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
+ /* Extend the array by 50%, plus the number we really need. */
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
+ }
- yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+ (yy_n_chars) += number_to_move;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
- return ret_val;
- }
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
+ return ret_val;
+}
/* yy_get_previous_state - get the state just before the EOB char was reached */
-static yy_state_type yy_get_previous_state()
- {
+ static yy_state_type yy_get_previous_state (void)
+{
register yy_state_type yy_current_state;
register char *yy_cp;
+
+ yy_current_state = (yy_start);
- yy_current_state = yy_start;
-
- for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
{
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] )
{
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 298 )
+ if ( yy_current_state >= 316 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
}
return yy_current_state;
- }
-
+}
/* yy_try_NUL_trans - try to make a transition on the NUL character
*
* synopsis
* next_state = yy_try_NUL_trans( current_state );
*/
-
-#ifdef YY_USE_PROTOS
-static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
-#else
-static yy_state_type yy_try_NUL_trans( yy_current_state )
-yy_state_type yy_current_state;
-#endif
- {
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
+{
register int yy_is_jam;
- register char *yy_cp = yy_c_buf_p;
+ register char *yy_cp = (yy_c_buf_p);
register YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] )
{
- yy_last_accepting_state = yy_current_state;
- yy_last_accepting_cpos = yy_cp;
+ (yy_last_accepting_state) = yy_current_state;
+ (yy_last_accepting_cpos) = yy_cp;
}
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
- if ( yy_current_state >= 298 )
+ if ( yy_current_state >= 316 )
yy_c = yy_meta[(unsigned int) yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
- yy_is_jam = (yy_current_state == 297);
+ yy_is_jam = (yy_current_state == 315);
return yy_is_jam ? 0 : yy_current_state;
- }
-
+}
#ifndef YY_NO_UNPUT
-#ifdef YY_USE_PROTOS
-static void yyunput( int c, register char *yy_bp )
-#else
-static void yyunput( c, yy_bp )
-int c;
-register char *yy_bp;
-#endif
- {
- register char *yy_cp = yy_c_buf_p;
+
+ static void yyunput (int c, register char * yy_bp )
+{
+ register char *yy_cp;
+
+ yy_cp = (yy_c_buf_p);
/* undo effects of setting up yytext */
- *yy_cp = yy_hold_char;
+ *yy_cp = (yy_hold_char);
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
- register int number_to_move = yy_n_chars + 2;
- register char *dest = &yy_current_buffer->yy_ch_buf[
- yy_current_buffer->yy_buf_size + 2];
+ register int number_to_move = (yy_n_chars) + 2;
+ register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
register char *source =
- &yy_current_buffer->yy_ch_buf[number_to_move];
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
- while ( source > yy_current_buffer->yy_ch_buf )
+ while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
*--dest = *--source;
yy_cp += (int) (dest - source);
yy_bp += (int) (dest - source);
- yy_current_buffer->yy_n_chars =
- yy_n_chars = yy_current_buffer->yy_buf_size;
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
- if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
YY_FATAL_ERROR( "flex scanner push-back overflow" );
}
*--yy_cp = (char) c;
+ (yytext_ptr) = yy_bp;
+ (yy_hold_char) = *yy_cp;
+ (yy_c_buf_p) = yy_cp;
+}
- yytext_ptr = yy_bp;
- yy_hold_char = *yy_cp;
- yy_c_buf_p = yy_cp;
- }
-#endif /* ifndef YY_NO_UNPUT */
-
+#endif
+#ifndef YY_NO_INPUT
#ifdef __cplusplus
-static int yyinput()
+ static int yyinput (void)
#else
-static int input()
+ static int input (void)
#endif
- {
- int c;
- *yy_c_buf_p = yy_hold_char;
+{
+ int c;
+
+ *(yy_c_buf_p) = (yy_hold_char);
- if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
{
/* yy_c_buf_p now points to the character we want to return.
* If this occurs *before* the EOB characters, then it's a
* valid NUL; if not, then we've hit the end of the buffer.
*/
- if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
/* This was really a NUL. */
- *yy_c_buf_p = '\0';
+ *(yy_c_buf_p) = '\0';
else
{ /* need more input */
- int offset = yy_c_buf_p - yytext_ptr;
- ++yy_c_buf_p;
+ int offset = (yy_c_buf_p) - (yytext_ptr);
+ ++(yy_c_buf_p);
- switch ( yy_get_next_buffer() )
+ switch ( yy_get_next_buffer( ) )
{
case EOB_ACT_LAST_MATCH:
/* This happens because yy_g_n_b()
@@ -1779,16 +1914,16 @@ static int input()
*/
/* Reset buffer status. */
- yyrestart( yyin );
+ yyrestart(yyin );
- /* fall through */
+ /*FALLTHROUGH*/
case EOB_ACT_END_OF_FILE:
{
- if ( yywrap() )
+ if ( yywrap( ) )
return EOF;
- if ( ! yy_did_buffer_switch_on_eof )
+ if ( ! (yy_did_buffer_switch_on_eof) )
YY_NEW_FILE;
#ifdef __cplusplus
return yyinput();
@@ -1798,90 +1933,92 @@ static int input()
}
case EOB_ACT_CONTINUE_SCAN:
- yy_c_buf_p = yytext_ptr + offset;
+ (yy_c_buf_p) = (yytext_ptr) + offset;
break;
}
}
}
- c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
- *yy_c_buf_p = '\0'; /* preserve yytext */
- yy_hold_char = *++yy_c_buf_p;
-
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
+ *(yy_c_buf_p) = '\0'; /* preserve yytext */
+ (yy_hold_char) = *++(yy_c_buf_p);
return c;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yyrestart( FILE *input_file )
-#else
-void yyrestart( input_file )
-FILE *input_file;
-#endif
- {
- if ( ! yy_current_buffer )
- yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+}
+#endif /* ifndef YY_NO_INPUT */
- yy_init_buffer( yy_current_buffer, input_file );
- yy_load_buffer_state();
+/** Immediately switch to a different input stream.
+ * @param input_file A readable stream.
+ *
+ * @note This function does not reset the start condition to @c INITIAL .
+ */
+ void yyrestart (FILE * input_file )
+{
+
+ if ( ! YY_CURRENT_BUFFER ){
+ yyensure_buffer_stack ();
+ YY_CURRENT_BUFFER_LVALUE =
+ yy_create_buffer(yyin,YY_BUF_SIZE );
}
+ yy_init_buffer(YY_CURRENT_BUFFER,input_file );
+ yy_load_buffer_state( );
+}
-#ifdef YY_USE_PROTOS
-void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
-#else
-void yy_switch_to_buffer( new_buffer )
-YY_BUFFER_STATE new_buffer;
-#endif
- {
- if ( yy_current_buffer == new_buffer )
+/** Switch to a different input buffer.
+ * @param new_buffer The new input buffer.
+ *
+ */
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
+{
+
+ /* TODO. We should be able to replace this entire function body
+ * with
+ * yypop_buffer_state();
+ * yypush_buffer_state(new_buffer);
+ */
+ yyensure_buffer_stack ();
+ if ( YY_CURRENT_BUFFER == new_buffer )
return;
- if ( yy_current_buffer )
+ if ( YY_CURRENT_BUFFER )
{
/* Flush out information for old buffer. */
- *yy_c_buf_p = yy_hold_char;
- yy_current_buffer->yy_buf_pos = yy_c_buf_p;
- yy_current_buffer->yy_n_chars = yy_n_chars;
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
- yy_current_buffer = new_buffer;
- yy_load_buffer_state();
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+ yy_load_buffer_state( );
/* We don't actually know whether we did this switch during
* EOF (yywrap()) processing, but the only time this flag
* is looked at is after yywrap() is called, so it's safe
* to go ahead and always set it.
*/
- yy_did_buffer_switch_on_eof = 1;
- }
-
-
-#ifdef YY_USE_PROTOS
-void yy_load_buffer_state( void )
-#else
-void yy_load_buffer_state()
-#endif
- {
- yy_n_chars = yy_current_buffer->yy_n_chars;
- yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
- yyin = yy_current_buffer->yy_input_file;
- yy_hold_char = *yy_c_buf_p;
- }
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+static void yy_load_buffer_state (void)
+{
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
+ (yy_hold_char) = *(yy_c_buf_p);
+}
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
-#else
-YY_BUFFER_STATE yy_create_buffer( file, size )
-FILE *file;
-int size;
-#endif
- {
+/** Allocate and initialize an input buffer state.
+ * @param file A readable stream.
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
+ *
+ * @return the allocated buffer state.
+ */
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
+{
YY_BUFFER_STATE b;
-
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@@ -1890,80 +2027,75 @@ int size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
- b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_is_our_buffer = 1;
- yy_init_buffer( b, file );
+ yy_init_buffer(b,file );
return b;
- }
-
+}
-#ifdef YY_USE_PROTOS
-void yy_delete_buffer( YY_BUFFER_STATE b )
-#else
-void yy_delete_buffer( b )
-YY_BUFFER_STATE b;
-#endif
- {
+/** Destroy the buffer.
+ * @param b a buffer created with yy_create_buffer()
+ *
+ */
+ void yy_delete_buffer (YY_BUFFER_STATE b )
+{
+
if ( ! b )
return;
- if ( b == yy_current_buffer )
- yy_current_buffer = (YY_BUFFER_STATE) 0;
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
if ( b->yy_is_our_buffer )
- yy_flex_free( (void *) b->yy_ch_buf );
+ yyfree((void *) b->yy_ch_buf );
- yy_flex_free( (void *) b );
- }
-
-
-#ifndef YY_ALWAYS_INTERACTIVE
-#ifndef YY_NEVER_INTERACTIVE
-extern int isatty YY_PROTO(( int ));
-#endif
-#endif
-
-#ifdef YY_USE_PROTOS
-void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
-#else
-void yy_init_buffer( b, file )
-YY_BUFFER_STATE b;
-FILE *file;
-#endif
+ yyfree((void *) b );
+}
+#ifndef __cplusplus
+extern int isatty (int );
+#endif /* __cplusplus */
+
+/* Initializes or reinitializes a buffer.
+ * This function is sometimes called more than once on the same buffer,
+ * such as during a yyrestart() or at EOF.
+ */
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
- {
- yy_flush_buffer( b );
+{
+ int oerrno = errno;
+
+ yy_flush_buffer(b );
b->yy_input_file = file;
b->yy_fill_buffer = 1;
-#if YY_ALWAYS_INTERACTIVE
- b->yy_is_interactive = 1;
-#else
-#if YY_NEVER_INTERACTIVE
- b->yy_is_interactive = 0;
-#else
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
-#endif
-#endif
- }
-
+ /* If b is the current buffer, then yy_init_buffer was _probably_
+ * called from yyrestart() or through yy_get_next_buffer.
+ * In that case, we don't want to reset the lineno or column.
+ */
+ if (b != YY_CURRENT_BUFFER){
+ b->yy_bs_lineno = 1;
+ b->yy_bs_column = 0;
+ }
-#ifdef YY_USE_PROTOS
-void yy_flush_buffer( YY_BUFFER_STATE b )
-#else
-void yy_flush_buffer( b )
-YY_BUFFER_STATE b;
-#endif
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+
+ errno = oerrno;
+}
- {
- if ( ! b )
+/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
+ *
+ */
+ void yy_flush_buffer (YY_BUFFER_STATE b )
+{
+ if ( ! b )
return;
b->yy_n_chars = 0;
@@ -1980,29 +2112,125 @@ YY_BUFFER_STATE b;
b->yy_at_bol = 1;
b->yy_buffer_status = YY_BUFFER_NEW;
- if ( b == yy_current_buffer )
- yy_load_buffer_state();
+ if ( b == YY_CURRENT_BUFFER )
+ yy_load_buffer_state( );
+}
+
+/** Pushes the new state onto the stack. The new state becomes
+ * the current state. This function will allocate the stack
+ * if necessary.
+ * @param new_buffer The new state.
+ *
+ */
+void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
+{
+ if (new_buffer == NULL)
+ return;
+
+ yyensure_buffer_stack();
+
+ /* This block is copied from yy_switch_to_buffer. */
+ if ( YY_CURRENT_BUFFER )
+ {
+ /* Flush out information for old buffer. */
+ *(yy_c_buf_p) = (yy_hold_char);
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
+ }
+
+ /* Only push if top exists. Otherwise, replace top. */
+ if (YY_CURRENT_BUFFER)
+ (yy_buffer_stack_top)++;
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
+
+ /* copied from yy_switch_to_buffer. */
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
+}
+
+/** Removes and deletes the top of the stack, if present.
+ * The next element becomes the new top.
+ *
+ */
+void yypop_buffer_state (void)
+{
+ if (!YY_CURRENT_BUFFER)
+ return;
+
+ yy_delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ if ((yy_buffer_stack_top) > 0)
+ --(yy_buffer_stack_top);
+
+ if (YY_CURRENT_BUFFER) {
+ yy_load_buffer_state( );
+ (yy_did_buffer_switch_on_eof) = 1;
}
+}
+/* Allocates the stack if it does not exist.
+ * Guarantees space for at least one push.
+ */
+static void yyensure_buffer_stack (void)
+{
+ int num_to_alloc;
+
+ if (!(yy_buffer_stack)) {
+
+ /* First allocation is just for 2 elements, since we don't know if this
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
+ * immediate realloc on the next call.
+ */
+ num_to_alloc = 1;
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
+
+ (yy_buffer_stack_max) = num_to_alloc;
+ (yy_buffer_stack_top) = 0;
+ return;
+ }
-#ifndef YY_NO_SCAN_BUFFER
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
-#else
-YY_BUFFER_STATE yy_scan_buffer( base, size )
-char *base;
-yy_size_t size;
-#endif
- {
- YY_BUFFER_STATE b;
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
+ /* Increase the buffer to prepare for a possible push. */
+ int grow_size = 8 /* arbitrary grow size */;
+
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
+ ((yy_buffer_stack),
+ num_to_alloc * sizeof(struct yy_buffer_state*)
+ );
+ if ( ! (yy_buffer_stack) )
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
+
+ /* zero only the new slots.*/
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
+ (yy_buffer_stack_max) = num_to_alloc;
+ }
+}
+
+/** Setup the input buffer state to scan directly from a user-specified character buffer.
+ * @param base the character buffer
+ * @param size the size in bytes of the character buffer
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
+{
+ YY_BUFFER_STATE b;
+
if ( size < 2 ||
base[size-2] != YY_END_OF_BUFFER_CHAR ||
base[size-1] != YY_END_OF_BUFFER_CHAR )
/* They forgot to leave room for the EOB's. */
return 0;
- b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
@@ -2016,56 +2244,51 @@ yy_size_t size;
b->yy_fill_buffer = 0;
b->yy_buffer_status = YY_BUFFER_NEW;
- yy_switch_to_buffer( b );
+ yy_switch_to_buffer(b );
return b;
- }
-#endif
-
-
-#ifndef YY_NO_SCAN_STRING
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
-#else
-YY_BUFFER_STATE yy_scan_string( yy_str )
-yyconst char *yy_str;
-#endif
- {
- int len;
- for ( len = 0; yy_str[len]; ++len )
- ;
-
- return yy_scan_bytes( yy_str, len );
- }
-#endif
+}
+/** Setup the input buffer state to scan a string. The next call to yylex() will
+ * scan from a @e copy of @a str.
+ * @param yystr a NUL-terminated string to scan
+ *
+ * @return the newly allocated buffer state object.
+ * @note If you want to scan bytes that may contain NUL values, then use
+ * yy_scan_bytes() instead.
+ */
+YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
+{
+
+ return yy_scan_bytes(yystr,strlen(yystr) );
+}
-#ifndef YY_NO_SCAN_BYTES
-#ifdef YY_USE_PROTOS
-YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
-#else
-YY_BUFFER_STATE yy_scan_bytes( bytes, len )
-yyconst char *bytes;
-int len;
-#endif
- {
+/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
+ * scan from a @e copy of @a bytes.
+ * @param bytes the byte buffer to scan
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
+ *
+ * @return the newly allocated buffer state object.
+ */
+YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
+{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
int i;
-
+
/* Get memory for full buffer, including space for trailing EOB's. */
- n = len + 2;
- buf = (char *) yy_flex_alloc( n );
+ n = _yybytes_len + 2;
+ buf = (char *) yyalloc(n );
if ( ! buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
- for ( i = 0; i < len; ++i )
- buf[i] = bytes[i];
+ for ( i = 0; i < _yybytes_len; ++i )
+ buf[i] = yybytes[i];
- buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
- b = yy_scan_buffer( buf, n );
+ b = yy_scan_buffer(buf,n );
if ( ! b )
YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
@@ -2075,148 +2298,196 @@ int len;
b->yy_is_our_buffer = 1;
return b;
- }
+}
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
#endif
+static void yy_fatal_error (yyconst char* msg )
+{
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+}
-#ifndef YY_NO_PUSH_STATE
-#ifdef YY_USE_PROTOS
-static void yy_push_state( int new_state )
-#else
-static void yy_push_state( new_state )
-int new_state;
-#endif
- {
- if ( yy_start_stack_ptr >= yy_start_stack_depth )
- {
- yy_size_t new_size;
+/* Redefine yyless() so it works in section 3 code. */
- yy_start_stack_depth += YY_START_STACK_INCR;
- new_size = yy_start_stack_depth * sizeof( int );
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ int yyless_macro_arg = (n); \
+ YY_LESS_LINENO(yyless_macro_arg);\
+ yytext[yyleng] = (yy_hold_char); \
+ (yy_c_buf_p) = yytext + yyless_macro_arg; \
+ (yy_hold_char) = *(yy_c_buf_p); \
+ *(yy_c_buf_p) = '\0'; \
+ yyleng = yyless_macro_arg; \
+ } \
+ while ( 0 )
- if ( ! yy_start_stack )
- yy_start_stack = (int *) yy_flex_alloc( new_size );
+/* Accessor methods (get/set functions) to struct members. */
- else
- yy_start_stack = (int *) yy_flex_realloc(
- (void *) yy_start_stack, new_size );
+/** Get the current line number.
+ *
+ */
+int yyget_lineno (void)
+{
+
+ return yylineno;
+}
- if ( ! yy_start_stack )
- YY_FATAL_ERROR(
- "out of memory expanding start-condition stack" );
- }
+/** Get the input stream.
+ *
+ */
+FILE *yyget_in (void)
+{
+ return yyin;
+}
- yy_start_stack[yy_start_stack_ptr++] = YY_START;
+/** Get the output stream.
+ *
+ */
+FILE *yyget_out (void)
+{
+ return yyout;
+}
- BEGIN(new_state);
- }
-#endif
+/** Get the length of the current token.
+ *
+ */
+int yyget_leng (void)
+{
+ return yyleng;
+}
+/** Get the current token.
+ *
+ */
-#ifndef YY_NO_POP_STATE
-static void yy_pop_state()
- {
- if ( --yy_start_stack_ptr < 0 )
- YY_FATAL_ERROR( "start-condition stack underflow" );
+char *yyget_text (void)
+{
+ return yytext;
+}
- BEGIN(yy_start_stack[yy_start_stack_ptr]);
- }
-#endif
+/** Set the current line number.
+ * @param _line_number
+ *
+ */
+void yyset_lineno (int _line_number )
+{
+
+ yylineno = _line_number;
+}
+/** Set the input stream. This does not discard the current
+ * input buffer.
+ * @param _in_str A readable stream.
+ *
+ * @see yy_switch_to_buffer
+ */
+void yyset_in (FILE * _in_str )
+{
+ yyin = _in_str ;
+}
-#ifndef YY_NO_TOP_STATE
-static int yy_top_state()
- {
- return yy_start_stack[yy_start_stack_ptr - 1];
- }
-#endif
+void yyset_out (FILE * _out_str )
+{
+ yyout = _out_str ;
+}
-#ifndef YY_EXIT_FAILURE
-#define YY_EXIT_FAILURE 2
-#endif
+int yyget_debug (void)
+{
+ return yy_flex_debug;
+}
+
+void yyset_debug (int _bdebug )
+{
+ yy_flex_debug = _bdebug ;
+}
-#ifdef YY_USE_PROTOS
-static void yy_fatal_error( yyconst char msg[] )
+static int yy_init_globals (void)
+{
+ /* Initialization is the same as for the non-reentrant scanner.
+ * This function is called from yylex_destroy(), so don't allocate here.
+ */
+
+ (yy_buffer_stack) = 0;
+ (yy_buffer_stack_top) = 0;
+ (yy_buffer_stack_max) = 0;
+ (yy_c_buf_p) = (char *) 0;
+ (yy_init) = 0;
+ (yy_start) = 0;
+
+/* Defined in main.c */
+#ifdef YY_STDINIT
+ yyin = stdin;
+ yyout = stdout;
#else
-static void yy_fatal_error( msg )
-char msg[];
+ yyin = (FILE *) 0;
+ yyout = (FILE *) 0;
#endif
- {
- (void) fprintf( stderr, "%s\n", msg );
- exit( YY_EXIT_FAILURE );
- }
+ /* For future reference: Set errno on error, since we are called by
+ * yylex_init()
+ */
+ return 0;
+}
+/* yylex_destroy is for both reentrant and non-reentrant scanners. */
+int yylex_destroy (void)
+{
+
+ /* Pop the buffer stack, destroying each element. */
+ while(YY_CURRENT_BUFFER){
+ yy_delete_buffer(YY_CURRENT_BUFFER );
+ YY_CURRENT_BUFFER_LVALUE = NULL;
+ yypop_buffer_state();
+ }
-/* Redefine yyless() so it works in section 3 code. */
+ /* Destroy the stack itself. */
+ yyfree((yy_buffer_stack) );
+ (yy_buffer_stack) = NULL;
-#undef yyless
-#define yyless(n) \
- do \
- { \
- /* Undo effects of setting up yytext. */ \
- yytext[yyleng] = yy_hold_char; \
- yy_c_buf_p = yytext + n; \
- yy_hold_char = *yy_c_buf_p; \
- *yy_c_buf_p = '\0'; \
- yyleng = n; \
- } \
- while ( 0 )
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
+ * yylex() is called, initialization will occur. */
+ yy_init_globals( );
+ return 0;
+}
-/* Internal utility routines. */
+/*
+ * Internal utility routines.
+ */
#ifndef yytext_ptr
-#ifdef YY_USE_PROTOS
-static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
-#else
-static void yy_flex_strncpy( s1, s2, n )
-char *s1;
-yyconst char *s2;
-int n;
-#endif
- {
+static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
+{
register int i;
for ( i = 0; i < n; ++i )
s1[i] = s2[i];
- }
+}
#endif
#ifdef YY_NEED_STRLEN
-#ifdef YY_USE_PROTOS
-static int yy_flex_strlen( yyconst char *s )
-#else
-static int yy_flex_strlen( s )
-yyconst char *s;
-#endif
- {
+static int yy_flex_strlen (yyconst char * s )
+{
register int n;
for ( n = 0; s[n]; ++n )
;
return n;
- }
+}
#endif
-
-#ifdef YY_USE_PROTOS
-static void *yy_flex_alloc( yy_size_t size )
-#else
-static void *yy_flex_alloc( size )
-yy_size_t size;
-#endif
- {
+void *yyalloc (yy_size_t size )
+{
return (void *) malloc( size );
- }
+}
-#ifdef YY_USE_PROTOS
-static void *yy_flex_realloc( void *ptr, yy_size_t size )
-#else
-static void *yy_flex_realloc( ptr, size )
-void *ptr;
-yy_size_t size;
-#endif
- {
+void *yyrealloc (void * ptr, yy_size_t size )
+{
/* The cast to (char *) in the following accommodates both
* implementations that use char* generic pointers, and those
* that use void* generic pointers. It works with the latter
@@ -2225,26 +2496,17 @@ yy_size_t size;
* as though doing an assignment.
*/
return (void *) realloc( (char *) ptr, size );
- }
+}
-#ifdef YY_USE_PROTOS
-static void yy_flex_free( void *ptr )
-#else
-static void yy_flex_free( ptr )
-void *ptr;
-#endif
- {
- free( ptr );
- }
+void yyfree (void * ptr )
+{
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
+}
+
+#define YYTABLES_NAME "yytables"
+
+#line 356 "../../bc/scan.l"
-#if YY_MAIN
-int main()
- {
- yylex();
- return 0;
- }
-#endif
-#line 363 "scan.l"
@@ -2252,8 +2514,10 @@ int main()
/* This is the way to get multiple files input into lex. */
int
-yywrap()
+yywrap(void)
{
if (!open_new_file ()) return (1); /* EOF on standard in. */
- return (0); /* We have more input. */
+ return (0); /* We have more input. */
+ yyunput(0,NULL); /* Make sure the compiler think yyunput is used. */
}
+
diff --git a/bc/scan.l b/bc/scan.l
index b4addaa..eb2e2dd 100644
--- a/bc/scan.l
+++ b/bc/scan.l
@@ -1,12 +1,10 @@
-%{
-/* scan.l: the (f)lex description file for the scanner. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991, 1992, 1993, 1994, 1997 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -15,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -29,6 +25,10 @@
*************************************************************************/
+/* scan.l: the (f)lex description file for the scanner. */
+
+%{
+
#include "bcdefs.h"
#include "bc.h"
#include "global.h"
@@ -48,7 +48,7 @@
/* We want to define our own yywrap. */
#undef yywrap
-_PROTOTYPE(int yywrap, (void));
+int yywrap (void);
#if defined(LIBEDIT)
/* Support for the BSD libedit with history for
@@ -59,40 +59,30 @@ _PROTOTYPE(int yywrap, (void));
/* Have input call the following function. */
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
- bcel_input((char *)buf, &result, max_size)
+ bcel_input((char *)buf, (yy_size_t *)&result, max_size)
/* Variables to help interface editline with bc. */
static const char *bcel_line = (char *)NULL;
static int bcel_len = 0;
-
-/* Required to get rid of that ugly ? default prompt! */
-char *
-null_prompt (EditLine *el)
-{
- return "";
-}
-
-
/* bcel_input puts upto MAX characters into BUF with the number put in
BUF placed in *RESULT. If the yy input file is the same as
stdin, use editline. Otherwise, just read it.
*/
static void
-bcel_input (buf, result, max)
- char *buf;
- int *result;
- int max;
+bcel_input (char *buf, yy_size_t *result, int max)
{
+ ssize_t rdsize;
if (!edit || yyin != stdin)
{
- while ( (*result = read( fileno(yyin), buf, max )) < 0 )
+ while ( (rdsize = read( fileno(yyin), buf, max )) < 0 )
if (errno != EINTR)
{
yyerror( "read() in flex scanner failed" );
- exit (1);
+ bc_exit (1);
}
+ *result = (yy_size_t) rdsize;
return;
}
@@ -143,7 +133,6 @@ static int rl_len = 0;
/* Definitions for readline access. */
extern FILE *rl_instream;
-_PROTOTYPE(char *readline, (char *));
/* rl_input puts upto MAX characters into BUF with the number put in
BUF placed in *RESULT. If the yy input file is the same as
@@ -151,10 +140,7 @@ _PROTOTYPE(char *readline, (char *));
*/
static void
-rl_input (buf, result, max)
- char *buf;
- int *result;
- int max;
+rl_input (char *buf, int *result, int max)
{
if (yyin != rl_instream)
{
@@ -162,7 +148,7 @@ rl_input (buf, result, max)
if (errno != EINTR)
{
yyerror( "read() in flex scanner failed" );
- exit (1);
+ bc_exit (1);
}
return;
}
@@ -216,7 +202,7 @@ rl_input (buf, result, max)
#endif
%}
-DIGIT [0-9A-F]
+DIGIT [0-9A-Z]
LETTER [a-z]
%s slcomment
%%
@@ -243,8 +229,10 @@ obase return(Obase);
auto return(Auto);
else return(Else);
read return(Read);
+random return(Random);
halt return(Halt);
last return(Last);
+void return(Void);
history {
#if defined(READLINE) || defined(LIBEDIT)
return(HistoryVar);
@@ -269,14 +257,14 @@ limits return(Limits);
&& { return(AND); }
\|\| { return(OR); }
"!" { return(NOT); }
-"*"|"/"|"%" { yylval.c_value = yytext[0]; return((int)yytext[0]); }
+"*"|"/"|"%"|"&" { yylval.c_value = yytext[0]; return((int)yytext[0]); }
"="|\+=|-=|\*=|\/=|%=|\^= { yylval.c_value = yytext[0]; return(ASSIGN_OP); }
=\+|=-|=\*|=\/|=%|=\^ {
#ifdef OLD_EQ_OP
char warn_save;
warn_save = warn_not_std;
warn_not_std = TRUE;
- warn ("Old fashioned =<op>");
+ ct_warn ("Old fashioned =<op>");
warn_not_std = warn_save;
yylval.c_value = yytext[1];
#else
@@ -313,7 +301,7 @@ limits return(Limits);
}
[a-z][a-z0-9_]* { yylval.s_value = strcopyof(yytext); return(NAME); }
\"[^\"]*\" {
- unsigned char *look;
+ const char *look;
int count = 0;
yylval.s_value = strcopyof(yytext);
for (look = yytext; *look != 0; look++)
@@ -325,7 +313,7 @@ limits return(Limits);
return(STRING);
}
{DIGIT}({DIGIT}|\\\n)*("."({DIGIT}|\\\n)*)?|"."(\\\n)*{DIGIT}({DIGIT}|\\\n)* {
- unsigned char *src, *dst;
+ char *src, *dst;
int len;
/* remove a trailing decimal point. */
len = strlen(yytext);
@@ -344,6 +332,11 @@ limits return(Limits);
src++; src++;
line_no++;
}
+ if (*src == ',')
+ {
+ src++;
+ ct_warn("Commas in numbers");
+ }
else
*dst++ = *src++;
}
@@ -367,8 +360,9 @@ limits return(Limits);
/* This is the way to get multiple files input into lex. */
int
-yywrap()
+yywrap(void)
{
if (!open_new_file ()) return (1); /* EOF on standard in. */
- return (0); /* We have more input. */
+ return (0); /* We have more input. */
+ yyunput(0,NULL); /* Make sure the compiler think yyunput is used. */
}
diff --git a/bc/storage.c b/bc/storage.c
index 10ebf5c..c79db82 100644
--- a/bc/storage.c
+++ b/bc/storage.c
@@ -1,11 +1,10 @@
-/* storage.c: Code and data storage manipulations. This includes labels. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991-1994, 1997, 2000 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,21 +25,26 @@
*************************************************************************/
+/* storage.c: Code and data storage manipulations. This includes labels. */
+
#include "bcdefs.h"
-#include "global.h"
#include "proto.h"
+/* Local prototypes */
+static bc_array_node *copy_tree (bc_array_node *ary_node, int depth);
+static bc_array *copy_array (bc_array *ary);
+
/* Initialize the storage at the beginning of the run. */
void
-init_storage ()
+init_storage (void)
{
/* Functions: we start with none and ask for more. */
f_count = 0;
more_functions ();
- f_names[0] = "(main)";
+ f_names[0] = strdup("(main)");
/* Variables. */
v_count = 0;
@@ -69,7 +71,7 @@ init_storage ()
arrays that are needed. This adds another 32 of the requested object. */
void
-more_functions (VOID)
+more_functions (void)
{
int old_count;
int indx;
@@ -84,8 +86,8 @@ more_functions (VOID)
/* Add a fixed amount and allocate new space. */
f_count += STORE_INCR;
- functions = (bc_function *) bc_malloc (f_count*sizeof (bc_function));
- f_names = (char **) bc_malloc (f_count*sizeof (char *));
+ functions = bc_malloc (f_count*sizeof (bc_function));
+ f_names = bc_malloc (f_count*sizeof (char *));
/* Copy old ones. */
for (indx = 0; indx < old_count; indx++)
@@ -99,7 +101,8 @@ more_functions (VOID)
{
f = &functions[indx];
f->f_defined = FALSE;
- f->f_body = (char *) bc_malloc (BC_START_SIZE);
+ f->f_void = FALSE;
+ f->f_body = bc_malloc (BC_START_SIZE);
f->f_body_size = BC_START_SIZE;
f->f_code_size = 0;
f->f_label = NULL;
@@ -116,7 +119,7 @@ more_functions (VOID)
}
void
-more_variables ()
+more_variables (void)
{
int indx;
int old_count;
@@ -130,12 +133,15 @@ more_variables ()
/* Increment by a fixed amount and allocate. */
v_count += STORE_INCR;
- variables = (bc_var **) bc_malloc (v_count*sizeof(bc_var *));
- v_names = (char **) bc_malloc (v_count*sizeof(char *));
+ variables = bc_malloc (v_count*sizeof(bc_var *));
+ v_names = bc_malloc (v_count*sizeof(char *));
/* Copy the old variables. */
for (indx = 3; indx < old_count; indx++)
- variables[indx] = old_var[indx];
+ {
+ variables[indx] = old_var[indx];
+ v_names[indx] = old_names[indx];
+ }
/* Initialize the new elements. */
for (; indx < v_count; indx++)
@@ -150,7 +156,7 @@ more_variables ()
}
void
-more_arrays ()
+more_arrays (void)
{
int indx;
int old_count;
@@ -164,16 +170,19 @@ more_arrays ()
/* Increment by a fixed amount and allocate. */
a_count += STORE_INCR;
- arrays = (bc_var_array **) bc_malloc (a_count*sizeof(bc_var_array *));
- a_names = (char **) bc_malloc (a_count*sizeof(char *));
+ arrays = bc_malloc (a_count*sizeof(bc_var_array *));
+ a_names = bc_malloc (a_count*sizeof(char *));
/* Copy the old arrays. */
for (indx = 1; indx < old_count; indx++)
- arrays[indx] = old_ary[indx];
+ {
+ arrays[indx] = old_ary[indx];
+ a_names[indx] = old_names[indx];
+ }
/* Initialize the new elements. */
- for (; indx < v_count; indx++)
+ for (; indx < a_count; indx++)
arrays[indx] = NULL;
/* Free the old elements. */
@@ -188,8 +197,7 @@ more_arrays ()
/* clear_func clears out function FUNC and makes it ready to redefine. */
void
-clear_func (func)
- int func;
+clear_func (int func)
{
bc_function *f;
bc_label_group *lg;
@@ -221,7 +229,7 @@ clear_func (func)
/* Pop the function execution stack and return the top. */
int
-fpop()
+fpop(void)
{
fstack_rec *temp;
int retval;
@@ -245,12 +253,11 @@ fpop()
/* Push VAL on to the function stack. */
void
-fpush (val)
- int val;
+fpush (int val)
{
fstack_rec *temp;
- temp = (fstack_rec *) bc_malloc (sizeof (fstack_rec));
+ temp = bc_malloc (sizeof (fstack_rec));
temp->s_next = fn_stack;
temp->s_val = val;
fn_stack = temp;
@@ -260,7 +267,7 @@ fpush (val)
/* Pop and discard the top element of the regular execution stack. */
void
-pop ()
+pop (void)
{
estack_rec *temp;
@@ -277,12 +284,11 @@ pop ()
/* Push a copy of NUM on to the regular execution stack. */
void
-push_copy (num)
- bc_num num;
+push_copy (bc_num num)
{
estack_rec *temp;
- temp = (estack_rec *) bc_malloc (sizeof (estack_rec));
+ temp = bc_malloc (sizeof (estack_rec));
temp->s_num = bc_copy_num (num);
temp->s_next = ex_stack;
ex_stack = temp;
@@ -292,12 +298,11 @@ push_copy (num)
/* Push NUM on to the regular execution stack. Do NOT push a copy. */
void
-push_num (num)
- bc_num num;
+push_num (bc_num num)
{
estack_rec *temp;
- temp = (estack_rec *) bc_malloc (sizeof (estack_rec));
+ temp = bc_malloc (sizeof (estack_rec));
temp->s_num = num;
temp->s_next = ex_stack;
ex_stack = temp;
@@ -309,8 +314,7 @@ push_num (num)
return FALSE. */
char
-check_stack (depth)
- int depth;
+check_stack (int depth)
{
estack_rec *temp;
@@ -336,15 +340,14 @@ check_stack (depth)
exist, one is created. */
bc_var *
-get_var (var_name)
- int var_name;
+get_var (int var_name)
{
bc_var *var_ptr;
var_ptr = variables[var_name];
if (var_ptr == NULL)
{
- var_ptr = variables[var_name] = (bc_var *) bc_malloc (sizeof (bc_var));
+ var_ptr = variables[var_name] = bc_malloc (sizeof (bc_var));
bc_init_num (&var_ptr->v_value);
}
return var_ptr;
@@ -358,22 +361,20 @@ get_var (var_name)
the index into the bc array. */
bc_num *
-get_array_num (var_index, index)
- int var_index;
- long index;
+get_array_num (int var_index, unsigned long idx)
{
bc_var_array *ary_ptr;
bc_array *a_var;
bc_array_node *temp;
- int log, ix, ix1;
+ int log;
+ unsigned int ix, ix1;
int sub [NODE_DEPTH];
/* Get the array entry. */
ary_ptr = arrays[var_index];
if (ary_ptr == NULL)
{
- ary_ptr = arrays[var_index] =
- (bc_var_array *) bc_malloc (sizeof (bc_var_array));
+ ary_ptr = arrays[var_index] = bc_malloc (sizeof (bc_var_array));
ary_ptr->a_value = NULL;
ary_ptr->a_next = NULL;
ary_ptr->a_param = FALSE;
@@ -381,14 +382,14 @@ get_array_num (var_index, index)
a_var = ary_ptr->a_value;
if (a_var == NULL) {
- a_var = ary_ptr->a_value = (bc_array *) bc_malloc (sizeof (bc_array));
+ a_var = ary_ptr->a_value = bc_malloc (sizeof (bc_array));
a_var->a_tree = NULL;
a_var->a_depth = 0;
}
/* Get the index variable. */
- sub[0] = index & NODE_MASK;
- ix = index >> NODE_SHIFT;
+ sub[0] = idx & NODE_MASK;
+ ix = idx >> NODE_SHIFT;
log = 1;
while (ix > 0 || log < a_var->a_depth)
{
@@ -400,7 +401,7 @@ get_array_num (var_index, index)
/* Build any tree that is necessary. */
while (log > a_var->a_depth)
{
- temp = (bc_array_node *) bc_malloc (sizeof(bc_array_node));
+ temp = bc_malloc (sizeof(bc_array_node));
if (a_var->a_depth != 0)
{
temp->n_items.n_down[0] = a_var->a_tree;
@@ -423,8 +424,7 @@ get_array_num (var_index, index)
ix1 = sub[log];
if (temp->n_items.n_down[ix1] == NULL)
{
- temp->n_items.n_down[ix1] =
- (bc_array_node *) bc_malloc (sizeof(bc_array_node));
+ temp->n_items.n_down[ix1] = bc_malloc (sizeof(bc_array_node));
temp = temp->n_items.n_down[ix1];
if (log > 1)
for (ix=0; ix < NODE_SIZE; ix++)
@@ -446,8 +446,7 @@ get_array_num (var_index, index)
This includes the special variables ibase, obase, and scale. */
void
-store_var (var_name)
- int var_name;
+store_var (int var_name)
{
bc_var *var_ptr;
long temp;
@@ -508,8 +507,22 @@ store_var (var_name)
else
if (temp > 16 || toobig)
{
- i_base = 16;
- rt_warn ("ibase too large, set to 16");
+ if (std_only)
+ {
+ i_base = 16;
+ rt_warn ("ibase too large, set to 16");
+ }
+ else if (temp > 36 || toobig)
+ {
+ i_base = 36;
+ rt_warn ("ibase too large, set to 36");
+ }
+ else
+ {
+ if (temp >= 16 && warn_not_std)
+ rt_warn ("ibase larger than 16 is non-standard");
+ i_base = temp;
+ }
}
else
i_base = (int) temp;
@@ -570,20 +583,19 @@ store_var (var_name)
of stack for the index into the array. */
void
-store_array (var_name)
- int var_name;
+store_array (int var_name)
{
bc_num *num_ptr;
- long index;
+ long idx;
if (!check_stack(2)) return;
- index = bc_num2long (ex_stack->s_next->s_num);
- if (index < 0 || index > BC_DIM_MAX ||
- (index == 0 && !bc_is_zero(ex_stack->s_next->s_num)))
+ idx = bc_num2long (ex_stack->s_next->s_num);
+ if (idx < 0 || idx > BC_DIM_MAX ||
+ (idx == 0 && !bc_is_zero(ex_stack->s_next->s_num)))
rt_error ("Array %s subscript out of bounds.", a_names[var_name]);
else
{
- num_ptr = get_array_num (var_name, index);
+ num_ptr = get_array_num (var_name, idx);
if (num_ptr != NULL)
{
bc_free_num (num_ptr);
@@ -601,8 +613,7 @@ store_array (var_name)
the special variables ibase, obase and scale. */
void
-load_var (var_name)
- int var_name;
+load_var (int var_name)
{
bc_var *var_ptr;
@@ -650,20 +661,19 @@ load_var (var_name)
the special variables ibase, obase and scale. */
void
-load_array (var_name)
- int var_name;
+load_array (int var_name)
{
bc_num *num_ptr;
- long index;
+ long idx;
if (!check_stack(1)) return;
- index = bc_num2long (ex_stack->s_num);
- if (index < 0 || index > BC_DIM_MAX ||
- (index == 0 && !bc_is_zero(ex_stack->s_num)))
+ idx = bc_num2long (ex_stack->s_num);
+ if (idx < 0 || idx > BC_DIM_MAX ||
+ (idx == 0 && !bc_is_zero(ex_stack->s_num)))
rt_error ("Array %s subscript out of bounds.", a_names[var_name]);
else
{
- num_ptr = get_array_num (var_name, index);
+ num_ptr = get_array_num (var_name, idx);
if (num_ptr != NULL)
{
pop();
@@ -677,8 +687,7 @@ load_array (var_name)
ibase, obase, and scale. */
void
-decr_var (var_name)
- int var_name;
+decr_var (int var_name)
{
bc_var *var_ptr;
@@ -717,6 +726,7 @@ decr_var (var_name)
rt_warn ("history is negative, set to unlimited");
UNLIMIT_HISTORY;
}
+ break;
#endif
default: /* It is a simple variable. */
@@ -731,21 +741,20 @@ decr_var (var_name)
the execution stack is the index and it is popped off the stack. */
void
-decr_array (var_name)
- int var_name;
+decr_array (int var_name)
{
bc_num *num_ptr;
- long index;
+ long idx;
/* It is an array variable. */
if (!check_stack (1)) return;
- index = bc_num2long (ex_stack->s_num);
- if (index < 0 || index > BC_DIM_MAX ||
- (index == 0 && !bc_is_zero (ex_stack->s_num)))
+ idx = bc_num2long (ex_stack->s_num);
+ if (idx < 0 || idx > BC_DIM_MAX ||
+ (idx == 0 && !bc_is_zero (ex_stack->s_num)))
rt_error ("Array %s subscript out of bounds.", a_names[var_name]);
else
{
- num_ptr = get_array_num (var_name, index);
+ num_ptr = get_array_num (var_name, idx);
if (num_ptr != NULL)
{
pop ();
@@ -759,8 +768,7 @@ decr_array (var_name)
ibase, obase, and scale. */
void
-incr_var (var_name)
- int var_name;
+incr_var (int var_name)
{
bc_var *var_ptr;
@@ -799,6 +807,7 @@ incr_var (var_name)
rt_warn ("history set to unlimited");
UNLIMIT_HISTORY;
}
+ break;
#endif
default: /* It is a simple variable. */
@@ -814,20 +823,19 @@ incr_var (var_name)
execution stack is the index and is popped off the stack. */
void
-incr_array (var_name)
- int var_name;
+incr_array (int var_name)
{
bc_num *num_ptr;
- long index;
+ long idx;
if (!check_stack (1)) return;
- index = bc_num2long (ex_stack->s_num);
- if (index < 0 || index > BC_DIM_MAX ||
- (index == 0 && !bc_is_zero (ex_stack->s_num)))
+ idx = bc_num2long (ex_stack->s_num);
+ if (idx < 0 || idx > BC_DIM_MAX ||
+ (idx == 0 && !bc_is_zero (ex_stack->s_num)))
rt_error ("Array %s subscript out of bounds.", a_names[var_name]);
else
{
- num_ptr = get_array_num (var_name, index);
+ num_ptr = get_array_num (var_name, idx);
if (num_ptr != NULL)
{
pop ();
@@ -842,8 +850,7 @@ incr_array (var_name)
/* NAME is an auto variable that needs to be pushed on its stack. */
void
-auto_var (name)
- int name;
+auto_var (int name)
{
bc_var *v_temp;
bc_var_array *a_temp;
@@ -853,7 +860,7 @@ auto_var (name)
{
/* A simple variable. */
ix = name;
- v_temp = (bc_var *) bc_malloc (sizeof (bc_var));
+ v_temp = bc_malloc (sizeof (bc_var));
v_temp->v_next = variables[ix];
bc_init_num (&v_temp->v_value);
variables[ix] = v_temp;
@@ -862,7 +869,7 @@ auto_var (name)
{
/* An array variable. */
ix = -name;
- a_temp = (bc_var_array *) bc_malloc (sizeof (bc_var_array));
+ a_temp = bc_malloc (sizeof (bc_var_array));
a_temp->a_next = arrays[ix];
a_temp->a_value = NULL;
a_temp->a_param = FALSE;
@@ -875,9 +882,7 @@ auto_var (name)
This is used when popping an array variable off its auto stack. */
void
-free_a_tree ( root, depth )
- bc_array_node *root;
- int depth;
+free_a_tree (bc_array_node *root, int depth)
{
int ix;
@@ -898,8 +903,7 @@ free_a_tree ( root, depth )
popped off their auto stacks. */
void
-pop_vars (list)
- arg_list *list;
+pop_vars (arg_list *list)
{
bc_var *v_temp;
bc_var_array *a_temp;
@@ -941,12 +945,10 @@ pop_vars (list)
}
/* COPY_NODE: Copies an array node for a call by value parameter. */
-bc_array_node *
-copy_tree (ary_node, depth)
- bc_array_node *ary_node;
- int depth;
+static bc_array_node *
+copy_tree (bc_array_node *ary_node, int depth)
{
- bc_array_node *res = (bc_array_node *) bc_malloc (sizeof(bc_array_node));
+ bc_array_node *res = bc_malloc (sizeof(bc_array_node));
int i;
if (depth > 1)
@@ -968,11 +970,10 @@ copy_tree (ary_node, depth)
/* COPY_ARRAY: Copies an array for a call by value array parameter.
ARY is the pointer to the bc_array structure. */
-bc_array *
-copy_array (ary)
- bc_array *ary;
+static bc_array *
+copy_array (bc_array *ary)
{
- bc_array *res = (bc_array *) bc_malloc (sizeof(bc_array));
+ bc_array *res = bc_malloc (sizeof(bc_array));
res->a_depth = ary->a_depth;
res->a_tree = copy_tree (ary->a_tree, ary->a_depth);
return (res);
@@ -985,21 +986,18 @@ copy_array (ary)
variable. */
void
-process_params (pc, func)
- program_counter *pc;
- int func;
+process_params (program_counter *progctr, int func)
{
char ch;
arg_list *params;
int ix, ix1;
bc_var *v_temp;
bc_var_array *a_src, *a_dest;
- bc_num *n_temp;
/* Get the parameter names from the function. */
params = functions[func].f_params;
- while ((ch = byte(pc)) != ':')
+ while ((ch = byte(progctr)) != ':')
{
if (params != NULL)
{
@@ -1007,7 +1005,7 @@ process_params (pc, func)
{
/* A simple variable. */
ix = params->av_name;
- v_temp = (bc_var *) bc_malloc (sizeof(bc_var));
+ v_temp = bc_malloc (sizeof(bc_var));
v_temp->v_next = variables[ix];
v_temp->v_value = ex_stack->s_num;
bc_init_num (&ex_stack->s_num);
@@ -1020,7 +1018,7 @@ process_params (pc, func)
/* Compute source index and make sure some structure exists. */
ix = (int) bc_num2long (ex_stack->s_num);
- n_temp = get_array_num (ix, 0);
+ (void) get_array_num (ix, 0);
/* Push a new array and Compute Destination index */
auto_var (params->av_name);
diff --git a/bc/util.c b/bc/util.c
index c305c2e..8eba093 100644
--- a/bc/util.c
+++ b/bc/util.c
@@ -1,11 +1,10 @@
-/* util.c: Utility routines for bc. */
-
/* This file is part of GNU bc.
- Copyright (C) 1991-1994, 1997, 2000 Free Software Foundation, Inc.
+
+ Copyright (C) 1991-1994, 1997, 2006, 2008, 2012-2017 Free Software Foundation, Inc.
This program 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,
@@ -14,10 +13,8 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; see the file COPYING. If not, write to
- The Free Software Foundation, Inc.
- 59 Temple Place, Suite 330
- Boston, MA 02111 USA
+ along with this program; see the file COPYING. If not, see
+ <http://www.gnu.org/licenses>.
You may contact the author by:
e-mail: philnelson@acm.org
@@ -28,6 +25,7 @@
*************************************************************************/
+/* util.c: Utility routines for bc. */
#include "bcdefs.h"
#ifndef VARARGS
@@ -35,7 +33,6 @@
#else
#include <varargs.h>
#endif
-#include "global.h"
#include "proto.h"
@@ -43,12 +40,11 @@
memory. */
char *
-strcopyof (str)
- char *str;
+strcopyof (const char *str)
{
char *temp;
- temp = (char *) bc_malloc (strlen (str)+1);
+ temp = bc_malloc (strlen (str)+1);
return (strcpy (temp,str));
}
@@ -56,13 +52,10 @@ strcopyof (str)
/* nextarg adds another value to the list of arguments. */
arg_list *
-nextarg (args, val, is_var)
- arg_list *args;
- int val;
- int is_var;
+nextarg (arg_list *args, int val, int is_var)
{ arg_list *temp;
- temp = (arg_list *) bc_malloc (sizeof (arg_list));
+ temp = bc_malloc (sizeof (arg_list));
temp->av_name = val;
temp->arg_is_var = is_var;
temp->next = args;
@@ -84,22 +77,20 @@ static char *arglist1 = NULL, *arglist2 = NULL;
characters needed. 1 char is the minimum needed.
*/
-_PROTOTYPE (static char *make_arg_str, (arg_list *args, int len));
+static char *make_arg_str (arg_list *args, int len);
static char *
-make_arg_str (args, len)
- arg_list *args;
- int len;
+make_arg_str (arg_list *args, int len)
{
char *temp;
- char sval[20];
+ char sval[30];
/* Recursive call. */
if (args != NULL)
temp = make_arg_str (args->next, len+12);
else
{
- temp = (char *) bc_malloc (len);
+ temp = bc_malloc (len);
*temp = 0;
return temp;
}
@@ -107,21 +98,20 @@ make_arg_str (args, len)
/* Add the current number to the end of the string. */
if (args->arg_is_var)
if (len != 1)
- sprintf (sval, "*%d,", args->av_name);
+ snprintf (sval, sizeof(sval), "*%d,", args->av_name);
else
- sprintf (sval, "*%d", args->av_name);
+ snprintf (sval, sizeof(sval), "*%d", args->av_name);
else
if (len != 1)
- sprintf (sval, "%d,", args->av_name);
+ snprintf (sval, sizeof(sval), "%d,", args->av_name);
else
- sprintf (sval, "%d", args->av_name);
+ snprintf (sval, sizeof(sval), "%d", args->av_name);
temp = strcat (temp, sval);
return (temp);
}
char *
-arg_str (args)
- arg_list *args;
+arg_str (arg_list *args)
{
if (arglist2 != NULL)
free (arglist2);
@@ -131,8 +121,7 @@ arg_str (args)
}
char *
-call_str (args)
- arg_list *args;
+call_str (arg_list *args)
{
arg_list *temp;
int arg_count;
@@ -145,7 +134,7 @@ call_str (args)
/* Count the number of args and add the 0's and 1's. */
for (temp = args, arg_count = 0; temp != NULL; temp = temp->next)
arg_count++;
- arglist1 = (char *) bc_malloc(arg_count+1);
+ arglist1 = bc_malloc(arg_count+1);
for (temp = args, ix=0; temp != NULL; temp = temp->next)
arglist1[ix++] = ( temp->av_name ? '1' : '0');
arglist1[ix] = 0;
@@ -156,8 +145,7 @@ call_str (args)
/* free_args frees an argument list ARGS. */
void
-free_args (args)
- arg_list *args;
+free_args (arg_list *args)
{
arg_list *temp;
@@ -176,8 +164,7 @@ free_args (args)
warnings are generated for array parameters. */
void
-check_params ( params, autos )
- arg_list *params, *autos;
+check_params (arg_list *params, arg_list *autos)
{
arg_list *tmp1, *tmp2;
@@ -195,7 +182,7 @@ check_params ( params, autos )
tmp2 = tmp2->next;
}
if (tmp1->arg_is_var)
- warn ("Variable array parameter");
+ ct_warn ("Variable array parameter");
tmp1 = tmp1->next;
}
}
@@ -237,11 +224,23 @@ check_params ( params, autos )
}
}
+/* genstr management to avoid buffer overflow. */
+void
+set_genstr_size (int size)
+{
+ if (size > genlen) {
+ if (genstr != NULL)
+ free(genstr);
+ genstr = bc_malloc (size);
+ genlen = size;
+ }
+}
+
/* Initialize the code generator the parser. */
void
-init_gen ()
+init_gen (void)
{
/* Get things ready. */
break_label = 0;
@@ -254,14 +253,14 @@ init_gen ()
init_load ();
had_error = FALSE;
did_gen = FALSE;
+ set_genstr_size (64);
}
/* generate code STR for the machine. */
void
-generate (str)
- char *str;
+generate (const char *str)
{
did_gen = TRUE;
if (compile_only)
@@ -282,7 +281,7 @@ generate (str)
/* Execute the current code as loaded. */
void
-run_code()
+run_code(void)
{
/* If no compile errors run the current code. */
if (!had_error && did_gen)
@@ -309,8 +308,7 @@ run_code()
break the output with a "\<cr>". Always used for numbers. */
void
-out_char (ch)
- int ch;
+out_char (int ch)
{
if (ch == '\n')
{
@@ -320,7 +318,7 @@ out_char (ch)
else
{
out_col++;
- if (out_col == line_size-1)
+ if (out_col == line_size-1 && line_size != 0)
{
putchar ('\\');
putchar ('\n');
@@ -336,8 +334,7 @@ out_char (ch)
In POSIX bc, strings are not broken across lines. */
void
-out_schar (ch)
- int ch;
+out_schar (int ch)
{
if (ch == '\n')
{
@@ -349,7 +346,7 @@ out_schar (ch)
if (!std_only)
{
out_col++;
- if (out_col == line_size-1)
+ if (out_col == line_size-1 && line_size != 0)
{
putchar ('\\');
putchar ('\n');
@@ -367,9 +364,7 @@ out_schar (ch)
ID. If there is no node in TREE with ID, NULL is returned. */
id_rec *
-find_id (tree, id)
- id_rec *tree;
- char *id;
+find_id (id_rec *tree, const char *id)
{
int cmp_result;
@@ -393,9 +388,7 @@ find_id (tree, id)
ROOT down is increased otherwise it returns FALSE. This is a
recursive balanced binary tree insertion algorithm. */
-int insert_id_rec (root, new_id)
- id_rec **root;
- id_rec *new_id;
+int insert_id_rec (id_rec **root, id_rec *new_id)
{
id_rec *A, *B;
@@ -418,50 +411,50 @@ int insert_id_rec (root, new_id)
/* The height increased. */
(*root)->balance --;
- switch ((*root)->balance)
- {
- case 0: /* no height increase. */
- return (FALSE);
- case -1: /* height increase. */
- return (FALSE);
- case -2: /* we need to do a rebalancing act. */
- A = *root;
- B = (*root)->left;
- if (B->balance <= 0)
- {
- /* Single Rotate. */
- A->left = B->right;
- B->right = A;
- *root = B;
- A->balance = 0;
- B->balance = 0;
- }
- else
+ switch ((*root)->balance)
{
- /* Double Rotate. */
- *root = B->right;
- B->right = (*root)->left;
- A->left = (*root)->right;
- (*root)->left = B;
- (*root)->right = A;
- switch ((*root)->balance)
+ case 0: /* no height increase. */
+ return (FALSE);
+ case -1: /* height increase. */
+ return (TRUE);
+ case -2: /* we need to do a rebalancing act. */
+ A = *root;
+ B = (*root)->left;
+ if (B->balance <= 0)
{
- case -1:
- A->balance = 1;
- B->balance = 0;
- break;
- case 0:
+ /* Single Rotate. */
+ A->left = B->right;
+ B->right = A;
+ *root = B;
A->balance = 0;
B->balance = 0;
- break;
- case 1:
- A->balance = 0;
- B->balance = -1;
- break;
}
- (*root)->balance = 0;
- }
- }
+ else
+ {
+ /* Double Rotate. */
+ *root = B->right;
+ B->right = (*root)->left;
+ A->left = (*root)->right;
+ (*root)->left = B;
+ (*root)->right = A;
+ switch ((*root)->balance)
+ {
+ case -1:
+ A->balance = 1;
+ B->balance = 0;
+ break;
+ case 0:
+ A->balance = 0;
+ B->balance = 0;
+ break;
+ case 1:
+ A->balance = 0;
+ B->balance = -1;
+ break;
+ }
+ (*root)->balance = 0;
+ }
+ }
}
}
else
@@ -471,12 +464,13 @@ int insert_id_rec (root, new_id)
{
/* The height increased. */
(*root)->balance ++;
+
switch ((*root)->balance)
{
case 0: /* no height increase. */
return (FALSE);
case 1: /* height increase. */
- return (FALSE);
+ return (TRUE);
case 2: /* we need to do a rebalancing act. */
A = *root;
B = (*root)->right;
@@ -526,7 +520,7 @@ int insert_id_rec (root, new_id)
/* Initialize variables for the symbol table tree. */
void
-init_tree()
+init_tree(void)
{
name_tree = NULL;
next_array = 1;
@@ -539,22 +533,20 @@ init_tree()
/* Lookup routines for symbol table names. */
int
-lookup (name, namekind)
- char *name;
- int namekind;
+lookup (char *name, int namekind)
{
id_rec *id;
/* Warn about non-standard name. */
if (strlen(name) != 1)
- warn ("multiple letter name - %s", name);
+ ct_warn ("multiple letter name - %s", name);
/* Look for the id. */
id = find_id (name_tree, name);
if (id == NULL)
{
/* We need to make a new item. */
- id = (id_rec *) bc_malloc (sizeof (id_rec));
+ id = bc_malloc (sizeof (id_rec));
id->id = strcopyof (name);
id->a_name = 0;
id->f_name = 0;
@@ -574,36 +566,38 @@ lookup (name, namekind)
return (-id->a_name);
}
id->a_name = next_array++;
- a_names[id->a_name] = name;
if (id->a_name < MAX_STORE)
{
if (id->a_name >= a_count)
more_arrays ();
+ a_names[id->a_name] = name;
return (-id->a_name);
}
yyerror ("Too many array variables");
- exit (1);
+ bc_exit (1);
+ /*NOTREACHED*/
case FUNCT:
case FUNCTDEF:
if (id->f_name != 0)
{
- free(name);
+ free(name);
/* Check to see if we are redefining a math lib function. */
if (use_math && namekind == FUNCTDEF && id->f_name <= 6)
id->f_name = next_func++;
return (id->f_name);
}
id->f_name = next_func++;
- f_names[id->f_name] = name;
if (id->f_name < MAX_STORE)
{
if (id->f_name >= f_count)
more_functions ();
+ f_names[id->f_name] = name;
return (id->f_name);
}
yyerror ("Too many functions");
- exit (1);
+ bc_exit (1);
+ /*NOTREACHED*/
case SIMPLE:
if (id->v_name != 0)
@@ -612,68 +606,29 @@ lookup (name, namekind)
return (id->v_name);
}
id->v_name = next_var++;
- v_names[id->v_name - 1] = name;
if (id->v_name <= MAX_STORE)
{
if (id->v_name >= v_count)
more_variables ();
+ v_names[id->v_name - 1] = name;
return (id->v_name);
}
yyerror ("Too many variables");
- exit (1);
+ bc_exit (1);
+ /*NOTREACHED*/
+
}
yyerror ("End of util.c/lookup() reached. Please report this bug.");
- exit (1);
- /* not reached */
-}
-
-
-/* Print the welcome banner. */
-
-void
-welcome()
-{
- printf ("This is free software with ABSOLUTELY NO WARRANTY.\n");
- printf ("For details type `warranty'. \n");
-}
-
-/* Print out the version information. */
-void
-show_bc_version()
-{
- printf("%s %s\n%s\n", PACKAGE, VERSION, BC_COPYRIGHT);
-}
-
-
-/* Print out the warranty information. */
-
-void
-warranty(prefix)
- char *prefix;
-{
- printf ("\n%s", prefix);
- show_bc_version ();
- printf ("\n"
-" This program is free software; you can redistribute it and/or modify\n"
-" it under the terms of the GNU General Public License as published by\n"
-" the Free Software Foundation; either version 2 of the License , or\n"
-" (at your option) any later version.\n\n"
-" This program is distributed in the hope that it will be useful,\n"
-" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
-" GNU General Public License for more details.\n\n"
-" You should have received a copy of the GNU General Public License\n"
-" along with this program. If not, write to\n\n"
-" The Free Software Foundation, Inc.\n"
-" 59 Temple Place, Suite 330\n"
-" Boston, MA 02111, USA.\n\n");
+ bc_exit (1);
+ /*NOTREACHED*/
+ return 0;
}
/* Print out the limits of this program. */
void
-limits()
+limits(void)
{
printf ("BC_BASE_MAX = %d\n", BC_BASE_MAX);
printf ("BC_DIM_MAX = %ld\n", (long) BC_DIM_MAX);
@@ -689,13 +644,12 @@ limits()
/* bc_malloc will check the return value so all other places do not
have to do it! SIZE is the number of bytes to allocate. */
-char *
-bc_malloc (size)
- int size;
+void *
+bc_malloc (size_t size)
{
- char *ptr;
+ void *ptr;
- ptr = (char *) malloc (size);
+ ptr = (void *) malloc (size);
if (ptr == NULL)
out_of_memory ();
@@ -708,10 +662,11 @@ bc_malloc (size)
/* Malloc could not get enought memory. */
void
-out_of_memory()
+out_of_memory(void)
{
fprintf (stderr, "Fatal error: Out of memory for malloc.\n");
- exit (1);
+ bc_exit (1);
+ /*NOTREACHED*/
}
@@ -721,19 +676,19 @@ out_of_memory()
#ifndef VARARGS
#ifdef __STDC__
void
-yyerror (char *str, ...)
+yyerror (const char *str, ...)
#else
void
yyerror (str)
- char *str;
+ const char *str;
#endif
#else
void
yyerror (str, va_alist)
- char *str;
+ const char *str;
#endif
{
- char *name;
+ const char *name;
va_list args;
#ifndef VARARGS
@@ -759,19 +714,19 @@ yyerror (str, va_alist)
#ifndef VARARGS
#ifdef __STDC__
void
-warn (char *mesg, ...)
+ct_warn (const char *mesg, ...)
#else
void
-warn (mesg)
- char *mesg;
+ct_warn (mesg)
+ const char *mesg;
#endif
#else
void
-warn (mesg, va_alist)
- char *mesg;
+ct_warn (mesg, va_alist)
+ const char *mesg;
#endif
{
- char *name;
+ const char *name;
va_list args;
#ifndef VARARGS
@@ -785,7 +740,7 @@ warn (mesg, va_alist)
name = "(standard_in)";
else
name = file_name;
- fprintf (stderr,"%s %d: ",name,line_no);
+ fprintf (stderr,"%s %d: Error: ",name,line_no);
vfprintf (stderr, mesg, args);
fprintf (stderr, "\n");
had_error = TRUE;
@@ -809,16 +764,16 @@ warn (mesg, va_alist)
#ifndef VARARGS
#ifdef __STDC__
void
-rt_error (char *mesg, ...)
+rt_error (const char *mesg, ...)
#else
void
rt_error (mesg)
- char *mesg;
+ const char *mesg;
#endif
#else
void
rt_error (mesg, va_alist)
- char *mesg;
+ const char *mesg;
#endif
{
va_list args;
@@ -845,16 +800,14 @@ rt_error (mesg, va_alist)
#ifndef VARARGS
#ifdef __STDC__
void
-rt_warn (char *mesg, ...)
+rt_warn (const char *mesg, ...)
#else
void
-rt_warn (mesg)
- char *mesg;
+rt_warn (const char *mesg)
#endif
#else
void
-rt_warn (mesg, va_alist)
- char *mesg;
+rt_warn (const char *mesg)
#endif
{
va_list args;
@@ -871,3 +824,15 @@ rt_warn (mesg, va_alist)
fprintf (stderr, "\n");
}
+
+/* bc_exit: Make sure to reset the edit state. */
+
+void bc_exit(int val)
+{
+#if defined(LIBEDIT)
+ if (edit != NULL)
+ el_end(edit);
+#endif
+ exit(val);
+ /*NOTREACHED*/
+}
diff --git a/bc/warranty.c b/bc/warranty.c
new file mode 100644
index 0000000..53bbeb4
--- /dev/null
+++ b/bc/warranty.c
@@ -0,0 +1,75 @@
+/* warranty.c: warranty routines for bc. */
+
+/* This file is part of GNU bc.
+ Copyright (C) 1991-1994, 1997, 2000, 2003, 2004 Free Software Foundation, Inc.
+
+ This program 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.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; see the file COPYING. If not, write to
+ The Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor
+ Boston, MA 02110-1335 USA
+
+ You may contact the author by:
+ e-mail: philnelson@acm.org
+ us-mail: Philip A. Nelson
+ Computer Science Department, 9062
+ Western Washington University
+ Bellingham, WA 98226-9062
+
+*************************************************************************/
+
+
+#include "bcdefs.h"
+#include "proto.h"
+
+
+/* Print the welcome banner. */
+
+void
+welcome()
+{
+ printf ("This is free software with ABSOLUTELY NO WARRANTY.\n");
+ printf ("For details type `warranty'. \n");
+}
+
+/* Print out the version information. */
+void
+show_bc_version()
+{
+ printf("%s %s\n%s\n", PACKAGE, VERSION, BC_COPYRIGHT);
+}
+
+
+/* Print out the warranty information. */
+
+void
+warranty(prefix)
+ const char *prefix;
+{
+ printf ("\n%s", prefix);
+ show_bc_version ();
+ printf ("\n"
+" This program is free software; you can redistribute it and/or modify\n"
+" it under the terms of the GNU General Public License as published by\n"
+" the Free Software Foundation; either version 3 of the License , or\n"
+" (at your option) any later version.\n\n"
+" This program is distributed in the hope that it will be useful,\n"
+" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+" GNU General Public License for more details.\n\n"
+" You should have received a copy of the GNU General Public License\n"
+" along with this program. If not, write to\n\n"
+" The Free Software Foundation, Inc.\n"
+" 51 Franklin Street, Fifth Floor\n"
+" Boston, MA 02110-1335 USA\n\n");
+}