kelbt-0.16/0000775000175000017500000000000012603513714007546 500000000000000kelbt-0.16/Makefile.in0000664000175000017500000006032312472122070011532 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # # Copyright 2001-2015 Adrian Thurston # # This file is part of Kelbt # # Kelbt 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. # # Kelbt 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 Kelbt; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA VPATH = @srcdir@ 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@ pkgincludedir = $(includedir)/@PACKAGE@ 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 = : subdir = . DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/configure $(am__configure_deps) COPYING \ ChangeLog TODO depcomp install-sh missing 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) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/src/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ ctags-recursive dvi-recursive html-recursive info-recursive \ install-data-recursive install-dvi-recursive \ install-exec-recursive install-html-recursive \ install-info-recursive install-pdf-recursive \ install-ps-recursive install-recursive installcheck-recursive \ installdirs-recursive pdf-recursive ps-recursive \ tags-recursive uninstall-recursive am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive am__recursive_targets = \ $(RECURSIVE_TARGETS) \ $(RECURSIVE_CLEAN_TARGETS) \ $(am__extra_recursive_targets) AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ cscope distdir dist dist-all distcheck 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 CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ if test -d "$(distdir)"; then \ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -rf "$(distdir)" \ || { sleep 5 && rm -rf "$(distdir)"; }; \ else :; fi am__post_remove_distdir = $(am__remove_distdir) am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best DIST_TARGETS = dist-gzip distuninstallcheck_listfiles = find . -type f -print am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EXEEXT = @EXEEXT@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KELBT = @KELBT@ LDFLAGS = @LDFLAGS@ 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@ PUBDATE = @PUBDATE@ RAGEL = @RAGEL@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CXX = @ac_ct_CXX@ 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@ SUBDIRS = aapl src all: all-recursive .SUFFIXES: am--refresh: Makefile @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): # This directory's subdirectories are mostly independent; you can cd # into them and run 'make' without going through this Makefile. # To change the values of 'make' variables: instead of editing Makefiles, # (1) if the variable is set in 'config.status', edit 'config.status' # (which will cause the Makefiles to be regenerated when you run 'make'); # (2) otherwise, pass the desired values on the 'make' command line. $(am__recursive_targets): @fail=; \ if $(am__make_keepgoing); then \ failcom='fail=yes'; \ else \ failcom='exit 1'; \ fi; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-recursive TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ $(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-recursive 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" cscope: cscope.files test ! -s cscope.files \ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS) clean-cscope: -rm -f cscope.files cscope.files: clean-cscope cscopelist cscopelist: cscopelist-recursive 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 GTAGS GRTAGS GSYMS GPATH tags -rm -f cscope.out cscope.in.out cscope.po.out cscope.files distdir: $(DISTFILES) $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @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 \ 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" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ $(am__make_dryrun) \ || test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" distdir="$(distdir)" \ dist-hook -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__post_remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 $(am__post_remove_distdir) dist-lzip: distdir tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz $(am__post_remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) dist-tarZ: distdir @echo WARNING: "Support for shar distribution archives is" \ "deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__post_remove_distdir) dist dist-all: $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:' $(am__post_remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lz*) \ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) mkdir $(distdir)/_build $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure \ $(AM_DISTCHECK_CONFIGURE_FLAGS) \ $(DISTCHECK_CONFIGURE_FLAGS) \ --srcdir=.. --prefix="$$dc_install_base" \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__post_remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @test -n '$(distuninstallcheck_dir)' || { \ echo 'ERROR: trying to run $@ with an empty' \ '$$(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ $(am__cd) '$(distuninstallcheck_dir)' || { \ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ exit 1; \ }; \ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive 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: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(am__recursive_targets) install-am install-strip .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ am--refresh check check-am clean clean-cscope clean-generic \ cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \ dist-gzip dist-hook dist-lzip dist-shar dist-tarZ dist-xz \ dist-zip distcheck distclean distclean-generic distclean-tags \ distcleancheck distdir distuninstallcheck dvi dvi-am html \ html-am info info-am install install-am 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 installdirs-am maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am tags tags-am uninstall uninstall-am # This file is checked for by the configure script and its existence causes the # parsers and the manual to not be built when the distribution is built. dist-hook: ( \ echo "#!/bin/sh"; \ echo ""; \ echo "# Change to yes to enable building of parsers"; \ echo "# or manual. Reconfigure afterwards."; \ echo "build_parsers=no;"; \ ) \ > $(distdir)/DIST # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: kelbt-0.16/src/0000775000175000017500000000000012603513714010335 500000000000000kelbt-0.16/src/Makefile.in0000664000175000017500000011716312472121505012330 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ # # Copyright 2001-2015 Adrian Thurston # # This file is part of Kelbt # # Kelbt 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. # # Kelbt 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 Kelbt; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA VPATH = @srcdir@ 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@ pkgincludedir = $(includedir)/@PACKAGE@ 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 = kelbt$(EXEEXT) subdir = src DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(srcdir)/config.h.in $(top_srcdir)/depcomp 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 = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_kelbt_OBJECTS = kelbt-pcheck.$(OBJEXT) kelbt-main.$(OBJEXT) \ kelbt-parsedata.$(OBJEXT) kelbt-closure.$(OBJEXT) \ kelbt-fsmbase.$(OBJEXT) kelbt-fsmattach.$(OBJEXT) \ kelbt-fsmgraph.$(OBJEXT) kelbt-codegen.$(OBJEXT) \ kelbt-gvdotgen.$(OBJEXT) kelbt-klscan.$(OBJEXT) \ kelbt-klparse.$(OBJEXT) kelbt_OBJECTS = $(am_kelbt_OBJECTS) kelbt_LDADD = $(LDADD) 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@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) AM_V_CXX = $(am__v_CXX_@AM_V@) am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) am__v_CXX_0 = @echo " CXX " $@; am__v_CXX_1 = CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = 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 = SOURCES = $(kelbt_SOURCES) DIST_SOURCES = $(kelbt_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ *) (install-info --version) >/dev/null 2>&1;; \ esac am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ $(LISP)config.h.in # 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@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EXEEXT = @EXEEXT@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KELBT = @KELBT@ LDFLAGS = @LDFLAGS@ 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@ PUBDATE = @PUBDATE@ RAGEL = @RAGEL@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CXX = @ac_ct_CXX@ 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@ kelbt_SOURCES = \ pcheck.cpp main.cpp parsedata.cpp \ closure.cpp fsmbase.cpp fsmattach.cpp \ fsmgraph.cpp codegen.cpp gvdotgen.cpp \ klscan.cpp klparse.cpp \ buffer.h fsmgraph.h klparse.h pcheck.h \ kelbt.h parsedata.h version.h kelbt_CPPFLAGS = -I$(top_srcdir)/aapl BUILT_SOURCES = \ version.h klparse.cpp klparse.h klscan.cpp EXTRA_DIST = klscan.rl klparse.kh klparse.kl all: $(BUILT_SOURCES) config.h $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .cpp .o .obj $(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) --foreign src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign src/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): config.h: stamp-h1 @test -f $@ || rm -f stamp-h1 @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status src/config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) @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)'; 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 clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) kelbt$(EXEEXT): $(kelbt_OBJECTS) $(kelbt_DEPENDENCIES) $(EXTRA_kelbt_DEPENDENCIES) @rm -f kelbt$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(kelbt_OBJECTS) $(kelbt_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-closure.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-codegen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-fsmattach.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-fsmbase.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-fsmgraph.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-gvdotgen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-klparse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-klscan.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-parsedata.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kelbt-pcheck.Po@am__quote@ .cpp.o: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` kelbt-pcheck.o: pcheck.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-pcheck.o -MD -MP -MF $(DEPDIR)/kelbt-pcheck.Tpo -c -o kelbt-pcheck.o `test -f 'pcheck.cpp' || echo '$(srcdir)/'`pcheck.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-pcheck.Tpo $(DEPDIR)/kelbt-pcheck.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='pcheck.cpp' object='kelbt-pcheck.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-pcheck.o `test -f 'pcheck.cpp' || echo '$(srcdir)/'`pcheck.cpp kelbt-pcheck.obj: pcheck.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-pcheck.obj -MD -MP -MF $(DEPDIR)/kelbt-pcheck.Tpo -c -o kelbt-pcheck.obj `if test -f 'pcheck.cpp'; then $(CYGPATH_W) 'pcheck.cpp'; else $(CYGPATH_W) '$(srcdir)/pcheck.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-pcheck.Tpo $(DEPDIR)/kelbt-pcheck.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='pcheck.cpp' object='kelbt-pcheck.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-pcheck.obj `if test -f 'pcheck.cpp'; then $(CYGPATH_W) 'pcheck.cpp'; else $(CYGPATH_W) '$(srcdir)/pcheck.cpp'; fi` kelbt-main.o: main.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-main.o -MD -MP -MF $(DEPDIR)/kelbt-main.Tpo -c -o kelbt-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-main.Tpo $(DEPDIR)/kelbt-main.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='main.cpp' object='kelbt-main.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-main.o `test -f 'main.cpp' || echo '$(srcdir)/'`main.cpp kelbt-main.obj: main.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-main.obj -MD -MP -MF $(DEPDIR)/kelbt-main.Tpo -c -o kelbt-main.obj `if test -f 'main.cpp'; then $(CYGPATH_W) 'main.cpp'; else $(CYGPATH_W) '$(srcdir)/main.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-main.Tpo $(DEPDIR)/kelbt-main.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='main.cpp' object='kelbt-main.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-main.obj `if test -f 'main.cpp'; then $(CYGPATH_W) 'main.cpp'; else $(CYGPATH_W) '$(srcdir)/main.cpp'; fi` kelbt-parsedata.o: parsedata.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-parsedata.o -MD -MP -MF $(DEPDIR)/kelbt-parsedata.Tpo -c -o kelbt-parsedata.o `test -f 'parsedata.cpp' || echo '$(srcdir)/'`parsedata.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-parsedata.Tpo $(DEPDIR)/kelbt-parsedata.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='parsedata.cpp' object='kelbt-parsedata.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-parsedata.o `test -f 'parsedata.cpp' || echo '$(srcdir)/'`parsedata.cpp kelbt-parsedata.obj: parsedata.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-parsedata.obj -MD -MP -MF $(DEPDIR)/kelbt-parsedata.Tpo -c -o kelbt-parsedata.obj `if test -f 'parsedata.cpp'; then $(CYGPATH_W) 'parsedata.cpp'; else $(CYGPATH_W) '$(srcdir)/parsedata.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-parsedata.Tpo $(DEPDIR)/kelbt-parsedata.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='parsedata.cpp' object='kelbt-parsedata.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-parsedata.obj `if test -f 'parsedata.cpp'; then $(CYGPATH_W) 'parsedata.cpp'; else $(CYGPATH_W) '$(srcdir)/parsedata.cpp'; fi` kelbt-closure.o: closure.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-closure.o -MD -MP -MF $(DEPDIR)/kelbt-closure.Tpo -c -o kelbt-closure.o `test -f 'closure.cpp' || echo '$(srcdir)/'`closure.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-closure.Tpo $(DEPDIR)/kelbt-closure.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='closure.cpp' object='kelbt-closure.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-closure.o `test -f 'closure.cpp' || echo '$(srcdir)/'`closure.cpp kelbt-closure.obj: closure.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-closure.obj -MD -MP -MF $(DEPDIR)/kelbt-closure.Tpo -c -o kelbt-closure.obj `if test -f 'closure.cpp'; then $(CYGPATH_W) 'closure.cpp'; else $(CYGPATH_W) '$(srcdir)/closure.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-closure.Tpo $(DEPDIR)/kelbt-closure.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='closure.cpp' object='kelbt-closure.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-closure.obj `if test -f 'closure.cpp'; then $(CYGPATH_W) 'closure.cpp'; else $(CYGPATH_W) '$(srcdir)/closure.cpp'; fi` kelbt-fsmbase.o: fsmbase.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-fsmbase.o -MD -MP -MF $(DEPDIR)/kelbt-fsmbase.Tpo -c -o kelbt-fsmbase.o `test -f 'fsmbase.cpp' || echo '$(srcdir)/'`fsmbase.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-fsmbase.Tpo $(DEPDIR)/kelbt-fsmbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fsmbase.cpp' object='kelbt-fsmbase.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-fsmbase.o `test -f 'fsmbase.cpp' || echo '$(srcdir)/'`fsmbase.cpp kelbt-fsmbase.obj: fsmbase.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-fsmbase.obj -MD -MP -MF $(DEPDIR)/kelbt-fsmbase.Tpo -c -o kelbt-fsmbase.obj `if test -f 'fsmbase.cpp'; then $(CYGPATH_W) 'fsmbase.cpp'; else $(CYGPATH_W) '$(srcdir)/fsmbase.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-fsmbase.Tpo $(DEPDIR)/kelbt-fsmbase.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fsmbase.cpp' object='kelbt-fsmbase.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-fsmbase.obj `if test -f 'fsmbase.cpp'; then $(CYGPATH_W) 'fsmbase.cpp'; else $(CYGPATH_W) '$(srcdir)/fsmbase.cpp'; fi` kelbt-fsmattach.o: fsmattach.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-fsmattach.o -MD -MP -MF $(DEPDIR)/kelbt-fsmattach.Tpo -c -o kelbt-fsmattach.o `test -f 'fsmattach.cpp' || echo '$(srcdir)/'`fsmattach.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-fsmattach.Tpo $(DEPDIR)/kelbt-fsmattach.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fsmattach.cpp' object='kelbt-fsmattach.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-fsmattach.o `test -f 'fsmattach.cpp' || echo '$(srcdir)/'`fsmattach.cpp kelbt-fsmattach.obj: fsmattach.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-fsmattach.obj -MD -MP -MF $(DEPDIR)/kelbt-fsmattach.Tpo -c -o kelbt-fsmattach.obj `if test -f 'fsmattach.cpp'; then $(CYGPATH_W) 'fsmattach.cpp'; else $(CYGPATH_W) '$(srcdir)/fsmattach.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-fsmattach.Tpo $(DEPDIR)/kelbt-fsmattach.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fsmattach.cpp' object='kelbt-fsmattach.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-fsmattach.obj `if test -f 'fsmattach.cpp'; then $(CYGPATH_W) 'fsmattach.cpp'; else $(CYGPATH_W) '$(srcdir)/fsmattach.cpp'; fi` kelbt-fsmgraph.o: fsmgraph.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-fsmgraph.o -MD -MP -MF $(DEPDIR)/kelbt-fsmgraph.Tpo -c -o kelbt-fsmgraph.o `test -f 'fsmgraph.cpp' || echo '$(srcdir)/'`fsmgraph.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-fsmgraph.Tpo $(DEPDIR)/kelbt-fsmgraph.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fsmgraph.cpp' object='kelbt-fsmgraph.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-fsmgraph.o `test -f 'fsmgraph.cpp' || echo '$(srcdir)/'`fsmgraph.cpp kelbt-fsmgraph.obj: fsmgraph.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-fsmgraph.obj -MD -MP -MF $(DEPDIR)/kelbt-fsmgraph.Tpo -c -o kelbt-fsmgraph.obj `if test -f 'fsmgraph.cpp'; then $(CYGPATH_W) 'fsmgraph.cpp'; else $(CYGPATH_W) '$(srcdir)/fsmgraph.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-fsmgraph.Tpo $(DEPDIR)/kelbt-fsmgraph.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='fsmgraph.cpp' object='kelbt-fsmgraph.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-fsmgraph.obj `if test -f 'fsmgraph.cpp'; then $(CYGPATH_W) 'fsmgraph.cpp'; else $(CYGPATH_W) '$(srcdir)/fsmgraph.cpp'; fi` kelbt-codegen.o: codegen.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-codegen.o -MD -MP -MF $(DEPDIR)/kelbt-codegen.Tpo -c -o kelbt-codegen.o `test -f 'codegen.cpp' || echo '$(srcdir)/'`codegen.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-codegen.Tpo $(DEPDIR)/kelbt-codegen.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='codegen.cpp' object='kelbt-codegen.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-codegen.o `test -f 'codegen.cpp' || echo '$(srcdir)/'`codegen.cpp kelbt-codegen.obj: codegen.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-codegen.obj -MD -MP -MF $(DEPDIR)/kelbt-codegen.Tpo -c -o kelbt-codegen.obj `if test -f 'codegen.cpp'; then $(CYGPATH_W) 'codegen.cpp'; else $(CYGPATH_W) '$(srcdir)/codegen.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-codegen.Tpo $(DEPDIR)/kelbt-codegen.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='codegen.cpp' object='kelbt-codegen.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-codegen.obj `if test -f 'codegen.cpp'; then $(CYGPATH_W) 'codegen.cpp'; else $(CYGPATH_W) '$(srcdir)/codegen.cpp'; fi` kelbt-gvdotgen.o: gvdotgen.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-gvdotgen.o -MD -MP -MF $(DEPDIR)/kelbt-gvdotgen.Tpo -c -o kelbt-gvdotgen.o `test -f 'gvdotgen.cpp' || echo '$(srcdir)/'`gvdotgen.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-gvdotgen.Tpo $(DEPDIR)/kelbt-gvdotgen.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='gvdotgen.cpp' object='kelbt-gvdotgen.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-gvdotgen.o `test -f 'gvdotgen.cpp' || echo '$(srcdir)/'`gvdotgen.cpp kelbt-gvdotgen.obj: gvdotgen.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-gvdotgen.obj -MD -MP -MF $(DEPDIR)/kelbt-gvdotgen.Tpo -c -o kelbt-gvdotgen.obj `if test -f 'gvdotgen.cpp'; then $(CYGPATH_W) 'gvdotgen.cpp'; else $(CYGPATH_W) '$(srcdir)/gvdotgen.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-gvdotgen.Tpo $(DEPDIR)/kelbt-gvdotgen.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='gvdotgen.cpp' object='kelbt-gvdotgen.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-gvdotgen.obj `if test -f 'gvdotgen.cpp'; then $(CYGPATH_W) 'gvdotgen.cpp'; else $(CYGPATH_W) '$(srcdir)/gvdotgen.cpp'; fi` kelbt-klscan.o: klscan.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-klscan.o -MD -MP -MF $(DEPDIR)/kelbt-klscan.Tpo -c -o kelbt-klscan.o `test -f 'klscan.cpp' || echo '$(srcdir)/'`klscan.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-klscan.Tpo $(DEPDIR)/kelbt-klscan.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='klscan.cpp' object='kelbt-klscan.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-klscan.o `test -f 'klscan.cpp' || echo '$(srcdir)/'`klscan.cpp kelbt-klscan.obj: klscan.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-klscan.obj -MD -MP -MF $(DEPDIR)/kelbt-klscan.Tpo -c -o kelbt-klscan.obj `if test -f 'klscan.cpp'; then $(CYGPATH_W) 'klscan.cpp'; else $(CYGPATH_W) '$(srcdir)/klscan.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-klscan.Tpo $(DEPDIR)/kelbt-klscan.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='klscan.cpp' object='kelbt-klscan.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-klscan.obj `if test -f 'klscan.cpp'; then $(CYGPATH_W) 'klscan.cpp'; else $(CYGPATH_W) '$(srcdir)/klscan.cpp'; fi` kelbt-klparse.o: klparse.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-klparse.o -MD -MP -MF $(DEPDIR)/kelbt-klparse.Tpo -c -o kelbt-klparse.o `test -f 'klparse.cpp' || echo '$(srcdir)/'`klparse.cpp @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-klparse.Tpo $(DEPDIR)/kelbt-klparse.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='klparse.cpp' object='kelbt-klparse.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-klparse.o `test -f 'klparse.cpp' || echo '$(srcdir)/'`klparse.cpp kelbt-klparse.obj: klparse.cpp @am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT kelbt-klparse.obj -MD -MP -MF $(DEPDIR)/kelbt-klparse.Tpo -c -o kelbt-klparse.obj `if test -f 'klparse.cpp'; then $(CYGPATH_W) 'klparse.cpp'; else $(CYGPATH_W) '$(srcdir)/klparse.cpp'; fi` @am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/kelbt-klparse.Tpo $(DEPDIR)/kelbt-klparse.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='klparse.cpp' object='kelbt-klparse.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(kelbt_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o kelbt-klparse.obj `if test -f 'klparse.cpp'; then $(CYGPATH_W) 'klparse.cpp'; else $(CYGPATH_W) '$(srcdir)/klparse.cpp'; fi` ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(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 GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @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 \ 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" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(PROGRAMS) config.h installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 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: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-am dvi-am: html: html-am 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: all check install install-am install-strip .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-hdr \ 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 # GEN_BEGIN @BUILD_PARSERS_TRUE@klscan.cpp: klscan.rl klparse.h @BUILD_PARSERS_TRUE@ $(RAGEL) -G2 -o $@ $< @BUILD_PARSERS_TRUE@klparse.h: klparse.kh @BUILD_PARSERS_TRUE@ $(KELBT) -o $@ $< @BUILD_PARSERS_TRUE@klparse.cpp: klparse.kl klparse.kh @BUILD_PARSERS_TRUE@ $(KELBT) -o $@ $< version.h: Makefile echo '#define VERSION "$(VERSION)"' > version.h echo '#define PUBDATE "$(PUBDATE)"' >> version.h # GEN_END # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: kelbt-0.16/src/klscan.rl0000664000175000017500000003207212471720163012074 00000000000000/* * Copyright 2006-2009 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "kelbt.h" #include "klparse.h" using std::ifstream; using std::istream; using std::ostream; using std::cout; using std::cerr; using std::endl; %%{ machine section_parser; write data; }%% struct Scanner { Scanner( const char *fileName, istream &input, ParserDict &parserDict, int include_depth ) : fileName(fileName), input(input), parserDict(parserDict), include_depth(include_depth), parser(0), curline(1) { %% write init; } void startSection( bool singleLineSpec ); void endSection(); void do_scan(); void try_token( int tokid ); void try_token( int tokid, char *start, char *end ); ifstream *tryOpenInclude( char **pathChecks, long &found ); char **makeIncludePathChecks( const char *thisFileName, const char *fileName ); /* Open an error message with the file name and line. */ ostream &error() { /* Keep the error count. */ gblErrorCount += 1; cerr << fileName << ":" << curline << ": "; return cerr; } const char *fileName; istream &input; ParserDict &parserDict; int include_depth; Parser *parser; int curline, inline_start_line; bool singleLineSpec; /* Write statements seen. */ bool writeInstanceData; bool writeTokenDefs; bool writeTypes; bool writeData; bool writeInit; bool writeExec; bool writeFinish; /* For section parser. */ int cs; char *captured; }; void Scanner::startSection( bool singleLineSpec ) { this->singleLineSpec = singleLineSpec; writeInstanceData = false; writeTokenDefs = false; writeTypes = false; writeData = false; writeInit = false; writeExec = false; writeFinish = false; } void Scanner::endSection() { if ( !::generateGraphviz ) { if ( writeInstanceData ) parser->pd.generateInstanceData(); if ( writeTokenDefs ) parser->pd.generateTokenDefs(); if ( writeTypes ) parser->pd.generateTypes(); if ( writeInit ) parser->pd.generateInit(); if ( writeData ) parser->pd.generateData(); if ( writeExec ) parser->pd.generateExec(); if ( writeFinish ) parser->pd.generateFinish(); if ( ! inhibitLineDirectives ) *outStream << "#line " << curline << " \"" << fileName << "\"\n"; } /* This causes us to use the parser with the last parser definition when * generating graphviz code. */ graphvizGenParser = parser; } void Scanner::try_token( int tokid ) { try_token( tokid, 0, 0 ); } bool isAbsolutePath( const char *path ) { return path[0] == '/'; } ifstream *Scanner::tryOpenInclude( char **pathChecks, long &found ) { char **check = pathChecks; ifstream *inFile = new ifstream; while ( *check != 0 ) { inFile->open( *check ); if ( inFile->is_open() ) { found = check - pathChecks; return inFile; } check += 1; } found = -1; delete inFile; return 0; } char **Scanner::makeIncludePathChecks( const char *thisFileName, const char *fileName ) { char **checks = 0; long nextCheck = 0; char *data = strdup(fileName); long length = strlen(fileName); /* Absolute path? */ if ( isAbsolutePath( data ) ) { checks = new char*[2]; checks[nextCheck++] = data; } else { /* Search from the the location of the current file. */ checks = new char *[2 + includePaths.length()]; const char *lastSlash = strrchr( thisFileName, '/' ); if ( lastSlash == 0 ) checks[nextCheck++] = data; else { long givenPathLen = (lastSlash - thisFileName) + 1; long checklen = givenPathLen + length; char *check = new char[checklen+1]; memcpy( check, thisFileName, givenPathLen ); memcpy( check+givenPathLen, data, length ); check[checklen] = 0; checks[nextCheck++] = check; } /* Search from the include paths given on the command line. */ for ( ArgsVector::Iter incp = includePaths; incp.lte(); incp++ ) { long pathLen = strlen( *incp ); long checkLen = pathLen + 1 + length; char *check = new char[checkLen+1]; memcpy( check, *incp, pathLen ); check[pathLen] = '/'; memcpy( check+pathLen+1, data, length ); check[checkLen] = 0; checks[nextCheck++] = check; } } checks[nextCheck] = 0; return checks; } void Scanner::try_token( int tokid, char *start, char *end ) { char *tokdata = 0; int *p = &tokid, *pe = &tokid + 1; if ( start != 0 ) { int len = end-start; tokdata = new char[len+1]; memcpy( tokdata, start, len ); tokdata[len] = 0; } %%{ machine section_parser; alphtype int; # Bring in tokens from the parser. import "klparse.h"; action handle_parser { //cout << "PARSER STATEMENT" << endl; char *parserName = captured; ParserDictEl *pdEl = parserDict.find( parserName ); if ( pdEl != 0 ) { //cout << "USING EXISTING PARSER" << endl; delete[] parserName; } else { //cout << "CREATING NEW PARSER" << endl; pdEl = new ParserDictEl; pdEl->name = parserName; pdEl->parser = new Parser( fileName, parserName, *outStream ); pdEl->parser->init(); parserDict.insert( pdEl ); } parser = pdEl->parser; } action handle_include { /* Make the list of files to try. */ char **checks = makeIncludePathChecks( this->fileName, captured ); /* Open the input file for reading. */ long found = 0; ifstream *inFile = tryOpenInclude( checks, found ); /* Open the input file for reading. */ if ( inFile == 0 ) error() << "include: could not open " << captured << " for reading" << endl; else { Scanner subScanner( checks[found], *inFile, parserDict, include_depth+1 ); subScanner.do_scan(); delete inFile; } } action handle_write { if ( include_depth == 0 ) { char *writeArg = captured; if ( strcmp( writeArg, "instance_data" ) == 0 ) writeInstanceData = true; else if ( strcmp( writeArg, "token_defs" ) == 0 ) writeTokenDefs = true; else if ( strcmp( writeArg, "types" ) == 0 ) writeTypes = true; else if ( strcmp( writeArg, "data" ) == 0 ) writeData = true; else if ( strcmp( writeArg, "init" ) == 0 ) writeInit = true; else if ( strcmp( writeArg, "exec" ) == 0 ) writeExec = true; else if ( strcmp( writeArg, "finish" ) == 0 ) writeFinish = true; } } action handle_else { if ( parser == 0 ) error() << "no section name and no previously named section" << endl; else { int line = TK_Inline ? inline_start_line : curline; int result = parser->token( line, tokid, tokdata ); if ( result < 0 ) error() << "parse error on or near this line" << endl; } } captured_word = TK_Word @{ captured = tokdata; }; captured_string = TK_String @{ captured = tokdata; }; main := ( # Parser statements KW_Parser captured_word ';' @handle_parser | # Include statements. KW_Include captured_string ';' @handle_include | KW_Write captured_word ';' @handle_write | # Everything else. ^(KW_Parser | KW_Include | KW_Write) @handle_else )*; write exec; }%% } %%{ machine klscan; # This is sent by the driver code. EOF = 0; # Machine which tracks newlines NL = '\n' @{ curline++; }; # Identifiers, numbers, commetns, and other common things. ident = ( alpha | '_' ) ( alpha |digit |'_' )*; number = digit+; c_comment = '/*' ( any | NL )* :>> '*/' | '//' [^\n]* NL; single_literal = "'" ([^'\\\r\n] | '\\' [^\n])* "'"; double_literal = '"' ([^"\\\r\n] | '\\' [^\n])* '"'; literal = single_literal | double_literal; whitespace = [ \t\r] | NL; pound_comment = '#' [^\n]* NL; # An inline block of code. This is specified as a scanned, but is sent to # the parser as one long block. The inline_block pointer is used to handle # the preservation of the data. inline_code := |* ident; number; c_comment; literal; whitespace+; '{' => { curly_count += 1; }; '}' => { if ( --curly_count == 0 ) { /* Send the entire block and free the inline_start pointer. */ try_token( TK_Inline, inline_start, te ); inline_start = 0; fgoto parser_def; } }; ( '$' | '@' ) number | '$$' | '@@' => { if ( inline_start < ts ) try_token( TK_Inline, inline_start, ts ); try_token( TK_Reference, ts, te ); inline_start = te; }; any; *|; access_stmt := |* [^;\0]+ => { try_token( TK_AccessData, ts, te ); }; ';' => { try_token( ';' ); fgoto parser_def; }; *|; # Parser definitions. parser_def := |* 'commit' => { try_token( KW_Commit ); }; 'try' => { try_token( KW_Try ); }; 'undo' => { try_token( KW_Undo ); }; 'final' => { try_token( KW_Final ); }; 'translate' => { try_token( KW_Translate ); }; 'token' => { try_token( KW_Token ); }; 'nonterm' => { try_token( KW_NonTerm ); }; 'uses' => { try_token( KW_Uses ); }; 'type' => { try_token( KW_Type ); }; 'parser' => { try_token( KW_Parser ); }; 'include' => { try_token( KW_Include ); }; 'pri' => { try_token( KW_Pri ); }; 'write' => { try_token( KW_Write ); }; 'class' => { try_token( KW_Class ); }; 'shortest' => { try_token( KW_Shortest ); }; 'access' whitespace* => { try_token( KW_Access ); fgoto access_stmt; }; # Parser literals are single characters with single quotes. parser_literal = "'" ([^'\\\r\n] | '\\' any) "'"; ident => { try_token( TK_Word, ts, te ); } ; parser_literal => { try_token( TK_Literal, ts+1, te-1 ); } ; double_literal => { try_token( TK_String, ts+1, te-1 ); } ; number => { try_token( TK_Number, ts, te ); }; pound_comment; '}%%' => { endSection(); fgoto main; }; [ \t\r]+; NL => { if ( singleLineSpec ) { endSection(); fgoto main; } }; '{' => { inline_start_line = curline; inline_start = ts; curly_count = 1; fgoto inline_code; }; any => { try_token( *ts, 0, 0 ); } ; *|; action pass { if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } # Outside code scanner. These tokens get passed through. main := |* ident => pass; number => pass; c_comment => pass; literal => pass; '%%' => { startSection( true ); fgoto parser_def; }; '%%{' => { startSection( false ); fgoto parser_def; }; whitespace+ => pass; EOF; any => pass; *|; }%% %% write data; void Scanner::do_scan() { int bufsize = 8; char *buf = new char[bufsize]; char *ts, *te; int cs, act, have = 0; int curly_count = 0; char *inline_start = 0; char *litstart = 0, *litend = 0; char *identstart = 0, *identend = 0; bool execute = true; %% write init; while ( execute ) { char *p = buf + have; int space = bufsize - have; if ( space == 0 ) { /* We filled up the buffer trying to scan a token. Grow it. */ bufsize = bufsize * 2; char *newbuf = new char[bufsize]; //cout << "FULL BUFFER, NEW SIZE: " << bufsize << endl; /* Recompute p and space. */ p = newbuf + have; space = bufsize - have; /* Patch up pointers possibly in use. */ if ( ts != 0 ) ts = newbuf + ( ts - buf ); if ( inline_start != 0 ) inline_start = newbuf + ( inline_start - buf ); te = newbuf + ( te - buf ); litstart = newbuf + ( litstart - buf ); litend = newbuf + ( litend - buf ); identstart = newbuf + ( identstart - buf ); identend = newbuf + ( identend - buf ); /* Copy the new buffer in. */ memcpy( newbuf, buf, have ); delete[] buf; buf = newbuf; } input.read( p, space ); int len = input.gcount(); char *pe = p + len; /* Check for EOF. */ char *eof = 0; if ( len == 0 ) { eof = pe; execute = false; } %% write exec; /* Check if we failed. */ if ( cs == klscan_error ) { /* Machine failed before finding a token. */ cout << "PARSE ERROR" << endl; exit(1); } /* Decide if we need to preserve anything. */ char *preserve = ts; if ( inline_start != 0 && ( preserve == 0 || inline_start < preserve ) ) preserve = inline_start; /* Now set up the prefix. */ if ( preserve == 0 ) have = 0; else { /* There is data that needs to be shifted over. */ have = pe - preserve; memmove( buf, preserve, have ); unsigned int shiftback = preserve - buf; if ( ts != 0 ) ts -= shiftback; if ( inline_start != 0 ) inline_start -= shiftback; te -= shiftback; litstart -= shiftback; litend -= shiftback; identstart -= shiftback; identend -= shiftback; preserve = buf; } } delete[] buf; } void scan( const char *fileName, istream &input ) { ParserDict parserDict; Scanner scanner( fileName, input, parserDict, 0 ); scanner.do_scan(); /* This uses the most recent parser definition. */ if ( ::generateGraphviz && ::graphvizGenParser != 0 ) graphvizGenParser->pd.generateGraphviz(); } kelbt-0.16/src/buffer.h0000664000175000017500000000260212471662307011705 00000000000000/* * Copyright 2003, 2005 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _BUFFER_H #define _BUFFER_H /* An automatically grown buffer for collecting tokens. Always reuses space; * never down resizes. */ struct Buffer { Buffer(); ~Buffer(); void append( char c ) { if ( length+1 > allocated ) upAllocate( (length+1)*2 ); data[length++] = c; } void append( char *p, int l ) { if ( length+l > allocated ) upAllocate( (length+l)*2 ); memcpy( data+length, p, l ); length += l; } void clear() { length = 0; } char *data; int length; private: int allocated; void upAllocate( int len ); void empty(); }; #endif /* _BUFFER_H */ kelbt-0.16/src/pcheck.h0000664000175000017500000000303512471662307011672 00000000000000/* * Copyright 2001, 2002, 2005, 2008 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PCHECK_H #define _PCHECK_H class ParamCheck { public: ParamCheck( const char *paramSpec, int argc, const char **argv); bool check(); const char *paramArg; /* The argument to the parameter. */ char parameter; /* The parameter matched. */ enum { match, invalid, noparam } state; const char *argOffset; /* If we are reading params inside an * arg this points to the offset. */ const char *curArg; /* Pointer to the current arg. */ int iCurArg; /* Index to the current arg. */ private: const char *paramSpec; /* Parameter spec supplied by the coder. */ int argc; /* Arguement data from the command line. */ const char **argv; }; #endif /* _PCHECK_H */ kelbt-0.16/src/klparse.h0000664000175000017500000000536512471720164012102 00000000000000/* Automatically generated by Kelbt from "klparse.kh". * * Parts of this file are copied from Kelbt source covered by the GNU * GPL. As a special exception, you may use the parts of this file copied * from Kelbt source without restriction. The remainder is derived from * "klparse.kh" and inherits the copyright status of that file. */ #line 1 "klparse.kh" /* * Copyright 2006 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef KLPARSE_H #define KLPARSE_H #include #include "avltree.h" #include "parsedata.h" struct LangEl; struct Token { char *data; InputLoc loc; }; struct Parser { #line 48 "klparse.h" struct Parser_Block *block; struct Parser_LangEl *freshEl; int freshPos; struct Parser_LangEl *pool; int numRetry; int numNodes; struct Parser_LangEl *stackTop; struct Parser_LangEl *lastFinal; int errCount; int curs; #line 49 "klparse.kh" Parser( const char *fileName, char *parserName, std::ostream &out ) : pd( fileName, parserName, out ), sawStart(false), sawInterface(false) {} void init(); int parseLangEl( int type, const Token *token ); int token( int line, int tokid, char *data ); TypeDef *getTypeDef( char *data ); ParseData pd; bool sawStart; bool sawInterface; KlangElVect langElVect; FactorVect factorVect; }; #line 79 "klparse.h" #define KW_Parser 128 #define KW_Include 129 #define KW_Write 130 #define KW_Class 131 #define KW_Commit 132 #define KW_Try 133 #define KW_Undo 134 #define KW_Final 135 #define KW_Translate 136 #define KW_Token 137 #define KW_NonTerm 138 #define KW_Uses 139 #define KW_Type 140 #define KW_Pri 141 #define KW_Shortest 142 #define TK_Word 143 #define TK_String 144 #define TK_Number 145 #define TK_Inline 146 #define TK_Reference 147 #define TK_Literal 148 #define KW_Access 149 #define TK_AccessData 150 #define Parser_tk_eof 151 #line 69 "klparse.kh" struct ParserDictEl : public AvlTreeEl { char *name; Parser *parser; char *getKey() const { return name; }; }; typedef AvlTree ParserDict; #endif kelbt-0.16/src/main.cpp0000664000175000017500000002276012471720203011710 00000000000000/* * Copyright 2001-2005, 2009-2012 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include /* Parsing. */ #include "kelbt.h" #include "parsedata.h" /* Parameters and output. */ #include "pcheck.h" #include "vector.h" #include "version.h" using std::ostream; using std::istream; using std::ifstream; using std::ios; using std::cout; using std::cerr; using std::cin; using std::endl; /* Target language and output style. */ const char *defExtension = ".cpp"; /* Io globals. */ ostream *outStream = 0; output_filter *outFilter = 0; const char *inputFile = 0; const char *outputFile = 0; bool generateGraphviz = false; Parser *graphvizGenParser = 0; bool branchPointInfo = false; bool addUniqueEmptyProductions = false; bool inhibitLineDirectives = false; istream *inStream = 0; ArgsVector includePaths; /* Print a summary of the options. */ void usage() { cout << "usage: kelbt [options] file\n" "general:\n" " -h, -H, -?, --help Print this usage and exit\n" " -v, --version Print version information and exit\n" " -o Write output to \n" " -V Generate a Graphviz dotfile\n" " -i Show branch point info\n" " -t Force top-down with unique empty productions\n" " -l Inhibit writing of #line directives\n" ; } /* Print version information. */ void version() { cout << "Kelbt version " VERSION << " " PUBDATE << endl << "Copyright (c) 2005-2012 by Adrian Thurston" << endl; } /* Scans a string looking for the file extension. If there is a file * extension then pointer returned points to inside the string * passed in. Otherwise returns null. */ const char *findFileExtension( const char *stemFile ) { const char *ppos = stemFile + strlen(stemFile) - 1; /* Scan backwards from the end looking for the first dot. * If we encounter a '/' before the first dot, then stop the scan. */ while ( 1 ) { /* If we found a dot or got to the beginning of the string then * we are done. */ if ( ppos == stemFile || *ppos == '.' ) break; /* If we hit a / then there is no extension. Done. */ if ( *ppos == '/' ) { ppos = stemFile; break; } ppos--; } /* If we got to the front of the string then bail we * did not find an extension */ if ( ppos == stemFile ) ppos = 0; return ppos; } /* Make a file name from a stem. Removes the old filename suffix and * replaces it with a new one. Returns a newed up string. */ const char *fileNameFromStem( const char *stemFile, const char *suffix ) { int len = strlen( stemFile ); assert( len > 0 ); /* Get the extension. */ const char *ppos = findFileExtension( stemFile ); /* If an extension was found, then shorten what we think the len is. */ if ( ppos != 0 ) len = ppos - stemFile; /* Make the return string from the stem and the suffix. */ char *retVal = new char[ len + strlen( suffix ) + 1 ]; strncpy( retVal, stemFile, len ); strcpy( retVal + len, suffix ); return retVal; } /* Total error count. */ int gblErrorCount = 0; /* Print the opening to a program error, then return the error stream. */ ostream &error() { /* Keep the error count. */ // if ( id != 0 && id->pd != 0 ) // id->pd->errorCount += 1; gblErrorCount += 1; cerr << PROGNAME ": "; return cerr; } /* Print the opening to an error in the input, then return the error ostream. */ ostream &error( const InputLoc &loc ) { assert( inputFile != 0 ); /* Keep the error count. */ gblErrorCount += 1; cerr << inputFile << ":" << loc.line << ":" << loc.col << ": "; return cerr; } /* Print the opening to a warning, then return the error ostream. */ ostream &warning( ) { assert( inputFile != 0 ); cerr << inputFile << ": warning: "; return cerr; } /* Print the opening to a warning in the input, then return the error ostream. */ ostream &warning( const InputLoc &loc ) { assert( inputFile != 0 ); cerr << inputFile << ":" << loc.line << ":" << loc.col << ": warning: "; return cerr; } int output_filter::sync( ) { line += 1; return std::filebuf::sync(); } /* Counts newlines before sending data out to file. */ std::streamsize output_filter::xsputn( const char *s, std::streamsize n ) { for ( int i = 0; i < n; i++ ) { if ( s[i] == '\n' ) line += 1; } return std::filebuf::xsputn( s, n ); } void escapeLineDirectivePath( std::ostream &out, const char *path ) { for ( const char *pc = path; *pc != 0; pc++ ) { if ( *pc == '\\' ) out << "\\\\"; else out << *pc; } } void scan( const char *fileName, istream &input ); /* Main, process args and call yyparse to start scanning input. */ int main(int argc, const char **argv) { ParamCheck pc("I:io:VdvHh?-:tl", argc, argv); while ( pc.check() ) { switch ( pc.state ) { case ParamCheck::match: switch ( pc.parameter ) { /* Output. */ case 'o': if ( *pc.paramArg == 0 ) { /* Complain, someone used -o "" */ error() << "zero length output file name" << endl; exit(1); } else if ( outputFile != 0 ) { /* Complain, two output files given. */ error() << "more than one output file" << endl; exit(1); } else { /* Ok, remember the output file name. */ outputFile = pc.paramArg; } break; /* Version and help. */ case 'v': version(); exit(0); case 'H': case 'h': case '?': usage(); exit(0); case 'V': generateGraphviz = true; break; case 'i': branchPointInfo = true; break; case '-': if ( strcasecmp(pc.paramArg, "help") == 0 ) { usage(); exit(0); } else if ( strcasecmp(pc.paramArg, "version") == 0 ) { version(); exit(0); } else { error() << "invalid parameter" << endl; exit(1); } break; case 't': addUniqueEmptyProductions = true; break; case 'l': inhibitLineDirectives = true; break; case 'I': includePaths.append( pc.paramArg ); break; } break; case ParamCheck::invalid: error() << "invalid parameter" << endl; exit(1); case ParamCheck::noparam: /* It is interpreted as an input file. */ if ( *pc.curArg == 0 ) { error() << "zero length input file name" << endl; exit(1); } if ( inputFile != 0 ) { error() << "more than one input file" << endl; exit(1); } /* Remember the filename. */ inputFile = pc.curArg; break; } } /* Look for no input file specified. */ if ( inputFile == 0 ) error() << "no input file" << endl; /* Bail on above errors. */ if ( gblErrorCount > 0 ) exit(1); if ( ! generateGraphviz ) { if ( outputFile == 0 ) outputFile = fileNameFromStem( inputFile, defExtension ); /* Make sure we are not writing to the same file as the input file. */ if ( outputFile != 0 && strcmp( inputFile, outputFile ) == 0 ) { error() << "output file \"" << outputFile << "\" is the same as the input file" << endl; } } /* Open the input file for reading. */ ifstream *inFile = new ifstream( inputFile ); inStream = inFile; if ( ! inFile->is_open() ) error() << "could not open " << inputFile << " for reading" << endl; /* Bail on above errors. */ if ( gblErrorCount > 0 ) exit(1); if ( outputFile != 0 ) { /* Create the filter on the output and open it. */ outFilter = new output_filter; outFilter->open( outputFile, ios::out|ios::trunc ); if ( !outFilter->is_open() ) { error() << "error opening " << outputFile << " for writing" << endl; exit(1); } /* Open the output stream, attaching it to the filter. */ outStream = new ostream( outFilter ); } else { /* Writing to std out. */ outStream = &cout; } if ( ! generateGraphviz ) { /* Put a header on the output to indicate that the file was machine generated. */ *outStream << "/* Automatically generated by Kelbt from \"" << inputFile << "\".\n" " *\n" " * Parts of this file are copied from Kelbt source covered by the GNU\n" " * GPL. As a special exception, you may use the parts of this file copied\n" " * from Kelbt source without restriction. The remainder is derived from\n" " * \"" << inputFile << "\" and inherits the copyright status of that file.\n" " */\n\n"; /* Initial line directive. */ if ( ! inhibitLineDirectives ) { *outStream << "#line 1 \""; escapeLineDirectivePath( *outStream, inputFile ); *outStream << "\"\n"; } } /* Parse the input! */ scan( inputFile, *inStream ); /* If writing to a file, delete the ostream, causing it to flush. * Standard out is flushed automatically. */ if ( outputFile != 0 ) { delete outStream; delete outFilter; } delete inStream; /* Finished, final check for errors.. */ if ( gblErrorCount > 0 ) { /* If we opened and output file, remove it. */ if ( outputFile != 0 ) unlink( outputFile ); exit(1); } return 0; } kelbt-0.16/src/version.h0000664000175000017500000000006712472121505012113 00000000000000#define VERSION "0.16" #define PUBDATE "February 2015" kelbt-0.16/src/closure.cpp0000664000175000017500000003251212471720203012434 00000000000000/* * Copyright 2005 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "kelbt.h" #include "parsedata.h" #include "vector.h" #include #include #include using std::endl; using std::cerr; void ParseData::lr0BringInItem( StateAp *dest, StateAp *prodState, TransAp *expandFrom, Definition *prod ) { /* We use dot sets for finding unique states. In the future, should merge * dots sets with the stateSet pointer (only need one of these). */ assert( dest != prodState ); dest->dotSet.insert( prodState->dotSet ); /* Get the epsilons, context, out priorities. */ dest->pendingCommits.insert( prodState->pendingCommits ); //if ( prodState->pendingCommits.length() > 0 ) // cerr << "THERE ARE PENDING COMMITS DRAWN IN" << endl; if ( prodState->transMap.length() > 0 ) { assert( prodState->transMap.length() == 1 ); TransAp *srcTrans = prodState->transMap[0].value; /* Look for the source in the destination. */ TransMapEl *destTel = dest->transMap.find( srcTrans->lowKey ); if ( destTel == 0 ) { /* Make a new state and transition to it. */ StateAp *newState = graph->addState(); TransAp *newTrans = new TransAp(); /* Attach the new transition to the new state. */ newTrans->lowKey = srcTrans->lowKey; graph->attachTrans( dest, newState, newTrans ); graph->addInTrans( newTrans, srcTrans ); /* The transitions we make during lr0 closure are all shifts. */ assert( newTrans->isShift ); assert( srcTrans->isShift ); /* The new state must have its state set setup. */ newState->stateSet = new StateSet; newState->stateSet->insert( srcTrans->toState ); /* Insert the transition into the map. Be sure to set destTel, it * is needed below. */ dest->transMap.insert( srcTrans->lowKey, newTrans, &destTel ); /* If the item is a non-term, queue it for closure. */ KlangEl *langEl = langElIndex[srcTrans->lowKey]; if ( langEl != 0 && langEl->type == KlangEl::NonTerm ) { graph->transClosureQueue.append( newTrans ); //cerr << "put to trans closure queue" << endl; } } else { //cerr << "merging transitions" << endl; destTel->value->toState->stateSet->insert( srcTrans->toState ); graph->addInTrans( destTel->value, srcTrans ); } /* If this is an expansion then we may need to bring in commits. */ if ( expandFrom != 0 && expandFrom->commits.length() > 0 ) { //cerr << "SETTING COMMIT ON CLOSURE ROUND" << endl; destTel->value->commits.insert( expandFrom->commits ); expandFrom->commits.empty(); } } else { /* ProdState does not have any transitions out. It is at the end of a * production. */ if ( expandFrom != 0 && expandFrom->commits.length() > 0 ) { //cerr << "SETTING COMMIT IN PENDING LOOKAHEAD" << endl; for ( LongSet::Iter len = expandFrom->commits; len.lte(); len++ ) dest->pendingCommits.insert( ProdIdPair( prod->prodId, *len ) ); expandFrom->commits.empty(); } } } void ParseData::lr0InvokeClosure( StateAp *state ) { /* State should not already be closed. */ assert( !state->inClosedMap ); /* This is used each time we invoke closure, it must be cleared. */ graph->transClosureQueue.abandon(); /* Drag in the core items. */ for ( StateSet::Iter ssi = *state->stateSet; ssi.lte(); ssi++ ) lr0BringInItem( state, *ssi, 0, 0 ); /* Now bring in the derived items. */ while ( graph->transClosureQueue.length() > 0 ) { TransAp *toClose = graph->transClosureQueue.detachFirst(); //cerr << "have a transition to derive" << endl; /* Get the langEl. */ KlangEl *langEl = langElIndex[toClose->lowKey]; /* Make graphs for all of the productions that the non * terminal goes to that are not already in the state's dotSet. */ for ( LelDefList::Iter prod = langEl->defList; prod.lte(); prod++ ) { /* Bring in the start state of the production. */ lr0BringInItem( state, prod->fsm->startState, toClose, prod ); } } /* Try and insert into the closed dict. */ DotSetMapEl *lastFound; if ( graph->closedMap.insert( state, &lastFound ) ) { /* Insertion into closed dict succeeded. There is no state with the * same dot set. The state is now closed. It is guaranteed a spot in * the closed dict and it will never go away (states never deleted * during closure). */ graph->stateClosedList.append( state ); state->inClosedMap = true; /* Add all of the states in the out transitions to the closure queue. * This will give us a depth first search of the graph. */ for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { /* Get the state the transEl goes to. */ StateAp *targ = trans->value->toState; /* If the state on this tranisition has not already been slated * for closure, then add it to the queue. */ if ( !targ->onClosureQueue && !targ->inClosedMap ) { graph->stateClosureQueue.append( targ ); targ->onClosureQueue = true; } } } else { /* Insertion into closed dict failed. There is an existing state * with the same dot set. Get the existing state. */ graph->inTransMove( lastFound, state ); for ( TransMap::Iter tel = state->transMap; tel.lte(); tel++ ) { graph->stateList.detach( tel->value->toState ); delete tel->value->toState; delete tel->value; } graph->stateList.detach( state ); delete state; } } /* Invoke cloure on the graph. We use a queue here to achieve a breadth * first search of the tree we build. Note, there are back edges in this * tree. They are the edges made when upon closure, a dot set exists * already. */ void ParseData::lr0CloseAllStates() { /* While there are items on the closure queue. */ while ( graph->stateClosureQueue.length() > 0 ) { /* Pop the first item off. */ StateAp *state = graph->stateClosureQueue.detachFirst(); state->onClosureQueue = false; /* Invoke closure upon the state. */ lr0InvokeClosure( state ); } } void ParseData::transferCommits( TransAp *trans, StateAp *state, long prodId ) { ProdIdPairSet &pendingCommits = state->pendingCommits; for ( ProdIdPairSet::Iter pi = pendingCommits; pi.lte(); pi++ ) { if ( pi->onReduce == prodId ) trans->commits.insert( pi->length ); } } void ParseData::lalr1AddFollow2( TransAp *trans, FollowToAdd &followKeys ) { for ( ExpandToSet::Iter ets = trans->expandTo; ets.lte(); ets++ ) { int prodId = ets->prodId; StateAp *expandTo = ets->state; for ( FollowToAdd::Iter fkey = followKeys; fkey.lte(); fkey++ ) { TransMapEl *transEl = expandTo->transMap.find( fkey->key ); if ( transEl != 0 ) { /* Set up the follow transition. */ TransAp *destTrans = transEl->value; transferCommits( destTrans, expandTo, prodId ); graph->addInReduction( destTrans, prodId, fkey->value ); } else { /* Set up the follow transition. */ TransAp *followTrans = new TransAp; followTrans->lowKey = fkey->key; followTrans->isShift = false; followTrans->reductions.insert( prodId, fkey->value ); transferCommits( followTrans, expandTo, prodId ); graph->attachTrans( expandTo, actionDestState, followTrans ); expandTo->transMap.insert( followTrans->lowKey, followTrans ); graph->transClosureQueue.append( followTrans ); } } } } long TransAp::maxPrior() { long prior = LONG_MIN; if ( isShift && shiftPrior > prior ) prior = shiftPrior; for ( ReductionMap::Iter red = reductions; red.lte(); red++ ) { if ( red->value > prior ) prior = red->value; } return prior; } void ParseData::lalr1AddFollow1( StateAp *state ) { /* Finding non-terminals into the state. */ for ( TransInList::Iter in = state->inRange; in.lte(); in++ ) { long key = in->lowKey; KlangEl *langEl = langElIndex[key]; if ( langEl != 0 && langEl->type == KlangEl::NonTerm ) { /* Finding the following transitions. */ FollowToAdd followKeys; for ( TransMap::Iter fout = state->transMap; fout.lte(); fout++ ) { int fkey = fout->key; KlangEl *flel = langElIndex[fkey]; if ( flel == 0 || flel->type == KlangEl::Term ) { long prior = fout->value->maxPrior(); followKeys.insert( fkey, prior ); } } if ( followKeys.length() > 0 ) lalr1AddFollow2( in, followKeys ); } } } void ParseData::lalr1AddFollow2( TransAp *trans, long followKey, long prior ) { for ( ExpandToSet::Iter ets = trans->expandTo; ets.lte(); ets++ ) { int prodId = ets->prodId; StateAp *expandTo = ets->state; TransMapEl *transEl = expandTo->transMap.find( followKey ); if ( transEl != 0 ) { /* Add in the reductions, or in the shift. */ TransAp *destTrans = transEl->value; transferCommits( destTrans, expandTo, prodId ); graph->addInReduction( destTrans, prodId, prior ); } else { /* Set up the follow transition. */ TransAp *followTrans = new TransAp; followTrans->lowKey = followKey; followTrans->isShift = false; followTrans->reductions.insert( prodId, prior ); transferCommits( followTrans, expandTo, prodId ); graph->attachTrans( expandTo, actionDestState, followTrans ); expandTo->transMap.insert( followTrans->lowKey, followTrans ); graph->transClosureQueue.append( followTrans ); } } } void ParseData::lalr1AddFollow1( TransAp *trans ) { StateAp *state = trans->fromState; int fkey = trans->lowKey; KlangEl *flel = langElIndex[fkey]; if ( flel == 0 || flel->type == KlangEl::Term ) { /* Finding non-terminals into the state. */ for ( TransInList::Iter in = state->inRange; in.lte(); in++ ) { long key = in->lowKey; KlangEl *langEl = langElIndex[key]; if ( langEl != 0 && langEl->type == KlangEl::NonTerm ) { //cerr << "FOLLOW PRIOR TRANSFER 2: " << prior << endl; long prior = trans->maxPrior(); lalr1AddFollow2( in, fkey, prior ); } } } } /* Add follow sets to an LR(0) graph to make it LALR(1). */ void ParseData::lalr1AddFollowSets( ) { /* Make the state that all reduction actions go to. Since a reduction pops * states of the stack and sets the new target state, this state is * actually never reached. Just here to link the trans to. */ actionDestState = graph->addState(); graph->setFinState( actionDestState ); /* Get the entry into the graph and traverse over start. */ StateAp *overStart = graph->followFsm( graph->startState, startDef->fsm ); /* Add _eof after the initial _start. */ TransAp *eofTrans = graph->attachNewTrans( overStart, actionDestState, eofKlangEl->id, eofKlangEl->id ); eofTrans->isShift = true; /* This was used during lr0 table construction. */ graph->transClosureQueue.abandon(); /* Need to pass over every state initially. */ for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) lalr1AddFollow1( state ); /* While the closure queue has items, pop them off and add follow * characters. */ while ( graph->transClosureQueue.length() > 0 ) { /* Pop the first item off and add Follow for it . */ TransAp *trans = graph->transClosureQueue.detachFirst(); lalr1AddFollow1( trans ); } } void ParseData::linkExpansions() { graph->setStateNumbers(); for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { /* Find transitions out on non terminals. */ for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { long key = trans->key; KlangEl *langEl = langElIndex[key]; if ( langEl != 0 && langEl->type == KlangEl::NonTerm ) { /* For each production that the non terminal expand to ... */ for ( LelDefList::Iter prod = langEl->defList; prod.lte(); prod++ ) { /* Follow the production and add to the trans's expand to set. */ StateAp *followRes = graph->followFsm( state, prod->fsm ); //KlangEl *lel = langElIndex[key]; //cerr << state->stateNum << ", "; //if ( lel != 0 ) // cerr << lel->data; //else // cerr << (char)key; //cerr << " -> " << (*fto)->stateNum << " on " << // prod->data << " (fss = " << fin.pos() << ")" << endl; trans->value->expandTo.insert( ExpandToEl( followRes, prod->prodId ) ); } } } } } /* Generate a LALR(1) graph. */ void ParseData::lalr1GenerateParser() { /* Make the intial graph. */ graph = new FsmAp(); graph->langElIndex = langElIndex; StateAp *start = graph->addState(); graph->setStartState( start ); start->stateSet = new StateSet; start->stateSet->insert( startDef->fsm->startState ); /* Queue the start state for closure. */ start->onClosureQueue = true; graph->stateClosureQueue.append( start ); /* Run the lr0 closure. */ lr0CloseAllStates(); /* Link production expansions to the place they expand to. */ linkExpansions(); /* Walk the graph adding follow sets to the LR(0) graph. */ lalr1AddFollowSets(); /* Set the commit on the final eof shift. */ TransAp *overStart = graph->startState->findTrans( userStartKlangEl->id ); TransAp *eofTrans = overStart->toState->findTrans( eofKlangEl->id ); eofTrans->afterShiftCommits.insert( 2 ); } kelbt-0.16/src/klscan.cpp0000664000175000017500000026706312471720203012246 00000000000000#include #include #include #include "kelbt.h" #include "klparse.h" using std::ifstream; using std::istream; using std::ostream; using std::cout; using std::cerr; using std::endl; static const int section_parser_start = 7; static const int section_parser_first_final = 7; static const int section_parser_error = 0; static const int section_parser_en_main = 7; struct Scanner { Scanner( const char *fileName, istream &input, ParserDict &parserDict, int include_depth ) : fileName(fileName), input(input), parserDict(parserDict), include_depth(include_depth), parser(0), curline(1) { { cs = section_parser_start; } } void startSection( bool singleLineSpec ); void endSection(); void do_scan(); void try_token( int tokid ); void try_token( int tokid, char *start, char *end ); ifstream *tryOpenInclude( char **pathChecks, long &found ); char **makeIncludePathChecks( const char *thisFileName, const char *fileName ); /* Open an error message with the file name and line. */ ostream &error() { /* Keep the error count. */ gblErrorCount += 1; cerr << fileName << ":" << curline << ": "; return cerr; } const char *fileName; istream &input; ParserDict &parserDict; int include_depth; Parser *parser; int curline, inline_start_line; bool singleLineSpec; /* Write statements seen. */ bool writeInstanceData; bool writeTokenDefs; bool writeTypes; bool writeData; bool writeInit; bool writeExec; bool writeFinish; /* For section parser. */ int cs; char *captured; }; void Scanner::startSection( bool singleLineSpec ) { this->singleLineSpec = singleLineSpec; writeInstanceData = false; writeTokenDefs = false; writeTypes = false; writeData = false; writeInit = false; writeExec = false; writeFinish = false; } void Scanner::endSection() { if ( !::generateGraphviz ) { if ( writeInstanceData ) parser->pd.generateInstanceData(); if ( writeTokenDefs ) parser->pd.generateTokenDefs(); if ( writeTypes ) parser->pd.generateTypes(); if ( writeInit ) parser->pd.generateInit(); if ( writeData ) parser->pd.generateData(); if ( writeExec ) parser->pd.generateExec(); if ( writeFinish ) parser->pd.generateFinish(); if ( ! inhibitLineDirectives ) *outStream << "#line " << curline << " \"" << fileName << "\"\n"; } /* This causes us to use the parser with the last parser definition when * generating graphviz code. */ graphvizGenParser = parser; } void Scanner::try_token( int tokid ) { try_token( tokid, 0, 0 ); } bool isAbsolutePath( const char *path ) { return path[0] == '/'; } ifstream *Scanner::tryOpenInclude( char **pathChecks, long &found ) { char **check = pathChecks; ifstream *inFile = new ifstream; while ( *check != 0 ) { inFile->open( *check ); if ( inFile->is_open() ) { found = check - pathChecks; return inFile; } check += 1; } found = -1; delete inFile; return 0; } char **Scanner::makeIncludePathChecks( const char *thisFileName, const char *fileName ) { char **checks = 0; long nextCheck = 0; char *data = strdup(fileName); long length = strlen(fileName); /* Absolute path? */ if ( isAbsolutePath( data ) ) { checks = new char*[2]; checks[nextCheck++] = data; } else { /* Search from the the location of the current file. */ checks = new char *[2 + includePaths.length()]; const char *lastSlash = strrchr( thisFileName, '/' ); if ( lastSlash == 0 ) checks[nextCheck++] = data; else { long givenPathLen = (lastSlash - thisFileName) + 1; long checklen = givenPathLen + length; char *check = new char[checklen+1]; memcpy( check, thisFileName, givenPathLen ); memcpy( check+givenPathLen, data, length ); check[checklen] = 0; checks[nextCheck++] = check; } /* Search from the include paths given on the command line. */ for ( ArgsVector::Iter incp = includePaths; incp.lte(); incp++ ) { long pathLen = strlen( *incp ); long checkLen = pathLen + 1 + length; char *check = new char[checkLen+1]; memcpy( check, *incp, pathLen ); check[pathLen] = '/'; memcpy( check+pathLen+1, data, length ); check[checkLen] = 0; checks[nextCheck++] = check; } } checks[nextCheck] = 0; return checks; } void Scanner::try_token( int tokid, char *start, char *end ) { char *tokdata = 0; int *p = &tokid, *pe = &tokid + 1; if ( start != 0 ) { int len = end-start; tokdata = new char[len+1]; memcpy( tokdata, start, len ); tokdata[len] = 0; } { if ( p == pe ) goto _test_eof; switch ( cs ) { case 7: goto st_case_7; case 1: goto st_case_1; case 0: goto st_case_0; case 2: goto st_case_2; case 3: goto st_case_3; case 4: goto st_case_4; case 5: goto st_case_5; case 6: goto st_case_6; } goto st_out; ctr2: {char *parserName = captured; ParserDictEl *pdEl = parserDict.find( parserName ); if ( pdEl != 0 ) { //cout << "USING EXISTING PARSER" << endl; delete[] parserName; } else { //cout << "CREATING NEW PARSER" << endl; pdEl = new ParserDictEl; pdEl->name = parserName; pdEl->parser = new Parser( fileName, parserName, *outStream ); pdEl->parser->init(); parserDict.insert( pdEl ); } parser = pdEl->parser; } goto st7; ctr4: {char **checks = makeIncludePathChecks( this->fileName, captured ); /* Open the input file for reading. */ long found = 0; ifstream *inFile = tryOpenInclude( checks, found ); /* Open the input file for reading. */ if ( inFile == 0 ) error() << "include: could not open " << captured << " for reading" << endl; else { Scanner subScanner( checks[found], *inFile, parserDict, include_depth+1 ); subScanner.do_scan(); delete inFile; } } goto st7; ctr6: {if ( include_depth == 0 ) { char *writeArg = captured; if ( strcmp( writeArg, "instance_data" ) == 0 ) writeInstanceData = true; else if ( strcmp( writeArg, "token_defs" ) == 0 ) writeTokenDefs = true; else if ( strcmp( writeArg, "types" ) == 0 ) writeTypes = true; else if ( strcmp( writeArg, "data" ) == 0 ) writeData = true; else if ( strcmp( writeArg, "init" ) == 0 ) writeInit = true; else if ( strcmp( writeArg, "exec" ) == 0 ) writeExec = true; else if ( strcmp( writeArg, "finish" ) == 0 ) writeFinish = true; } } goto st7; ctr7: {if ( parser == 0 ) error() << "no section name and no previously named section" << endl; else { int line = TK_Inline ? inline_start_line : curline; int result = parser->token( line, tokid, tokdata ); if ( result < 0 ) error() << "parse error on or near this line" << endl; } } goto st7; st7: p+= 1; if ( p == pe ) goto _test_eof7; st_case_7: switch ( ( (*( p )) ) ) { case 128: { goto st1; } case 129: { goto st3; } case 130: { goto st5; } } if ( 131 <= ( (*( p )) ) ) { goto ctr7; } { goto ctr7; } st1: p+= 1; if ( p == pe ) goto _test_eof1; st_case_1: if ( ( (*( p )) ) == 143 ) { goto ctr0; } { goto st0; } st_case_0: st0: cs = 0; goto _out; ctr0: {captured = tokdata; } goto st2; st2: p+= 1; if ( p == pe ) goto _test_eof2; st_case_2: if ( ( (*( p )) ) == 59 ) { goto ctr2; } { goto st0; } st3: p+= 1; if ( p == pe ) goto _test_eof3; st_case_3: if ( ( (*( p )) ) == 144 ) { goto ctr3; } { goto st0; } ctr3: {captured = tokdata; } goto st4; st4: p+= 1; if ( p == pe ) goto _test_eof4; st_case_4: if ( ( (*( p )) ) == 59 ) { goto ctr4; } { goto st0; } st5: p+= 1; if ( p == pe ) goto _test_eof5; st_case_5: if ( ( (*( p )) ) == 143 ) { goto ctr5; } { goto st0; } ctr5: {captured = tokdata; } goto st6; st6: p+= 1; if ( p == pe ) goto _test_eof6; st_case_6: if ( ( (*( p )) ) == 59 ) { goto ctr6; } { goto st0; } st_out: _test_eof7: cs = 7; goto _test_eof; _test_eof1: cs = 1; goto _test_eof; _test_eof2: cs = 2; goto _test_eof; _test_eof3: cs = 3; goto _test_eof; _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; _test_eof: {} _out: {} } } static const int klscan_start = 20; static const int klscan_first_final = 20; static const int klscan_error = -1; static const int klscan_en_inline_code = 29; static const int klscan_en_access_stmt = 39; static const int klscan_en_parser_def = 41; static const int klscan_en_main = 20; void Scanner::do_scan() { int bufsize = 8; char *buf = new char[bufsize]; char *ts, *te; int cs, act, have = 0; int curly_count = 0; char *inline_start = 0; char *litstart = 0, *litend = 0; char *identstart = 0, *identend = 0; bool execute = true; { cs = klscan_start; ts = 0; te = 0; act = 0; } while ( execute ) { char *p = buf + have; int space = bufsize - have; if ( space == 0 ) { /* We filled up the buffer trying to scan a token. Grow it. */ bufsize = bufsize * 2; char *newbuf = new char[bufsize]; //cout << "FULL BUFFER, NEW SIZE: " << bufsize << endl; /* Recompute p and space. */ p = newbuf + have; space = bufsize - have; /* Patch up pointers possibly in use. */ if ( ts != 0 ) ts = newbuf + ( ts - buf ); if ( inline_start != 0 ) inline_start = newbuf + ( inline_start - buf ); te = newbuf + ( te - buf ); litstart = newbuf + ( litstart - buf ); litend = newbuf + ( litend - buf ); identstart = newbuf + ( identstart - buf ); identend = newbuf + ( identend - buf ); /* Copy the new buffer in. */ memcpy( newbuf, buf, have ); delete[] buf; buf = newbuf; } input.read( p, space ); int len = input.gcount(); char *pe = p + len; /* Check for EOF. */ char *eof = 0; if ( len == 0 ) { eof = pe; execute = false; } { if ( p == pe ) goto _test_eof; switch ( cs ) { case 20: goto st_case_20; case 21: goto st_case_21; case 22: goto st_case_22; case 0: goto st_case_0; case 1: goto st_case_1; case 23: goto st_case_23; case 24: goto st_case_24; case 25: goto st_case_25; case 2: goto st_case_2; case 3: goto st_case_3; case 26: goto st_case_26; case 4: goto st_case_4; case 5: goto st_case_5; case 6: goto st_case_6; case 27: goto st_case_27; case 28: goto st_case_28; case 29: goto st_case_29; case 30: goto st_case_30; case 31: goto st_case_31; case 7: goto st_case_7; case 8: goto st_case_8; case 32: goto st_case_32; case 33: goto st_case_33; case 34: goto st_case_34; case 9: goto st_case_9; case 10: goto st_case_10; case 35: goto st_case_35; case 11: goto st_case_11; case 12: goto st_case_12; case 13: goto st_case_13; case 36: goto st_case_36; case 37: goto st_case_37; case 38: goto st_case_38; case 39: goto st_case_39; case 40: goto st_case_40; case 41: goto st_case_41; case 42: goto st_case_42; case 43: goto st_case_43; case 14: goto st_case_14; case 15: goto st_case_15; case 44: goto st_case_44; case 16: goto st_case_16; case 45: goto st_case_45; case 17: goto st_case_17; case 18: goto st_case_18; case 46: goto st_case_46; case 47: goto st_case_47; case 48: goto st_case_48; case 49: goto st_case_49; case 50: goto st_case_50; case 51: goto st_case_51; case 52: goto st_case_52; case 53: goto st_case_53; case 54: goto st_case_54; case 55: goto st_case_55; case 56: goto st_case_56; case 57: goto st_case_57; case 58: goto st_case_58; case 59: goto st_case_59; case 60: goto st_case_60; case 61: goto st_case_61; case 62: goto st_case_62; case 63: goto st_case_63; case 64: goto st_case_64; case 65: goto st_case_65; case 66: goto st_case_66; case 67: goto st_case_67; case 68: goto st_case_68; case 69: goto st_case_69; case 70: goto st_case_70; case 71: goto st_case_71; case 72: goto st_case_72; case 73: goto st_case_73; case 74: goto st_case_74; case 75: goto st_case_75; case 76: goto st_case_76; case 77: goto st_case_77; case 78: goto st_case_78; case 79: goto st_case_79; case 80: goto st_case_80; case 81: goto st_case_81; case 82: goto st_case_82; case 83: goto st_case_83; case 84: goto st_case_84; case 85: goto st_case_85; case 86: goto st_case_86; case 87: goto st_case_87; case 88: goto st_case_88; case 89: goto st_case_89; case 90: goto st_case_90; case 91: goto st_case_91; case 92: goto st_case_92; case 93: goto st_case_93; case 94: goto st_case_94; case 95: goto st_case_95; case 96: goto st_case_96; case 97: goto st_case_97; case 98: goto st_case_98; case 99: goto st_case_99; case 100: goto st_case_100; case 101: goto st_case_101; case 102: goto st_case_102; case 103: goto st_case_103; case 104: goto st_case_104; case 105: goto st_case_105; case 106: goto st_case_106; case 107: goto st_case_107; case 108: goto st_case_108; case 109: goto st_case_109; case 110: goto st_case_110; case 111: goto st_case_111; case 112: goto st_case_112; case 113: goto st_case_113; case 114: goto st_case_114; case 19: goto st_case_19; } goto st_out; ctr0: {{p = ((te))-1; {if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } }} goto st20; ctr2: {{te = p+1; {if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } }} goto st20; ctr9: {{te = p+1; {if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } }} goto st20; ctr11: {curline++; } {{te = p+1; {if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } }} goto st20; ctr33: {{te = p+1; {if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } }} goto st20; ctr34: {{te = p+1; }} goto st20; ctr43: {{te = p; p-= 1; {if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } }} goto st20; ctr44: {{te = p; p-= 1; {if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } }} goto st20; ctr46: {{te = p; p-= 1; {startSection( true ); {goto st41;}} }} goto st20; ctr47: {{te = p+1; {startSection( false ); {goto st41;}} }} goto st20; ctr48: {{te = p; p-= 1; {if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } }} goto st20; ctr49: {{te = p; p-= 1; {if ( !generateGraphviz && gblErrorCount == 0 && include_depth == 0 ) outStream->write( ts, te-ts ); } }} goto st20; st20: {{ts = 0; }} p+= 1; if ( p == pe ) goto _test_eof20; st_case_20: {{ts = p; }} switch ( ( (*( p )) ) ) { case 0: { goto ctr34; } case 9: { goto st21; } case 10: { goto ctr36; } case 13: { goto st21; } case 32: { goto st21; } case 33: { goto ctr33; } case 34: { goto ctr37; } case 37: { goto st23; } case 38: { goto ctr33; } case 39: { goto ctr39; } case 47: { goto ctr40; } case 95: { goto st28; } case 96: { goto ctr33; } } if ( ( (*( p )) ) < 48 ) { if ( ( (*( p )) ) < 14 ) { if ( ( (*( p )) ) > 8 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto ctr33; } } else if ( ( (*( p )) ) >= 1 ) { goto ctr33; } } else if ( ( (*( p )) ) > 31 ) { if ( ( (*( p )) ) > 36 ) { if ( 40 <= ( (*( p )) ) && ( (*( p )) ) <= 46 ) { goto ctr33; } } else if ( ( (*( p )) ) >= 35 ) { goto ctr33; } } else { goto ctr33; } } else if ( ( (*( p )) ) > 57 ) { if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) > 64 ) { { goto st28; } } else { goto ctr33; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) > 122 ) { { goto ctr33; } } else if ( ( (*( p )) ) >= 97 ) { goto st28; } } else { goto ctr33; } } else { goto st27; } { goto ctr33; } ctr36: {curline++; } goto st21; st21: p+= 1; if ( p == pe ) goto _test_eof21; st_case_21: switch ( ( (*( p )) ) ) { case 9: { goto st21; } case 10: { goto ctr36; } case 13: { goto st21; } case 32: { goto st21; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto ctr43; } } else if ( ( (*( p )) ) > 31 ) { if ( 33 <= ( (*( p )) ) ) { goto ctr43; } } else { goto ctr43; } { goto ctr43; } ctr37: {{te = p+1; }} goto st22; st22: p+= 1; if ( p == pe ) goto _test_eof22; st_case_22: switch ( ( (*( p )) ) ) { case 10: { goto ctr44; } case 13: { goto ctr44; } case 34: { goto ctr2; } case 92: { goto st1; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st0; } } else if ( ( (*( p )) ) > 33 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st0; } } else if ( ( (*( p )) ) >= 35 ) { goto st0; } } else { goto st0; } { goto st0; } st0: p+= 1; if ( p == pe ) goto _test_eof0; st_case_0: switch ( ( (*( p )) ) ) { case 10: { goto ctr0; } case 13: { goto ctr0; } case 34: { goto ctr2; } case 92: { goto st1; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st0; } } else if ( ( (*( p )) ) > 33 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st0; } } else if ( ( (*( p )) ) >= 35 ) { goto st0; } } else { goto st0; } { goto st0; } st1: p+= 1; if ( p == pe ) goto _test_eof1; st_case_1: if ( ( (*( p )) ) == 10 ) { goto ctr0; } if ( 11 <= ( (*( p )) ) ) { goto st0; } { goto st0; } st23: p+= 1; if ( p == pe ) goto _test_eof23; st_case_23: if ( ( (*( p )) ) == 37 ) { goto st24; } if ( 38 <= ( (*( p )) ) ) { goto ctr44; } { goto ctr44; } st24: p+= 1; if ( p == pe ) goto _test_eof24; st_case_24: if ( ( (*( p )) ) == 123 ) { goto ctr47; } if ( 124 <= ( (*( p )) ) ) { goto ctr46; } { goto ctr46; } ctr39: {{te = p+1; }} goto st25; st25: p+= 1; if ( p == pe ) goto _test_eof25; st_case_25: switch ( ( (*( p )) ) ) { case 10: { goto ctr44; } case 13: { goto ctr44; } case 39: { goto ctr2; } case 92: { goto st3; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st2; } } else if ( ( (*( p )) ) > 38 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st2; } } else if ( ( (*( p )) ) >= 40 ) { goto st2; } } else { goto st2; } { goto st2; } st2: p+= 1; if ( p == pe ) goto _test_eof2; st_case_2: switch ( ( (*( p )) ) ) { case 10: { goto ctr0; } case 13: { goto ctr0; } case 39: { goto ctr2; } case 92: { goto st3; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st2; } } else if ( ( (*( p )) ) > 38 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st2; } } else if ( ( (*( p )) ) >= 40 ) { goto st2; } } else { goto st2; } { goto st2; } st3: p+= 1; if ( p == pe ) goto _test_eof3; st_case_3: if ( ( (*( p )) ) == 10 ) { goto ctr0; } if ( 11 <= ( (*( p )) ) ) { goto st2; } { goto st2; } ctr40: {{te = p+1; }} goto st26; st26: p+= 1; if ( p == pe ) goto _test_eof26; st_case_26: switch ( ( (*( p )) ) ) { case 42: { goto st4; } case 47: { goto st6; } } if ( ( (*( p )) ) > 46 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr44; } } else if ( ( (*( p )) ) >= 43 ) { goto ctr44; } { goto ctr44; } ctr7: {curline++; } goto st4; st4: p+= 1; if ( p == pe ) goto _test_eof4; st_case_4: switch ( ( (*( p )) ) ) { case 10: { goto ctr7; } case 42: { goto st5; } } if ( ( (*( p )) ) > 41 ) { if ( 43 <= ( (*( p )) ) ) { goto st4; } } else if ( ( (*( p )) ) >= 11 ) { goto st4; } { goto st4; } st5: p+= 1; if ( p == pe ) goto _test_eof5; st_case_5: switch ( ( (*( p )) ) ) { case 10: { goto ctr7; } case 42: { goto st5; } case 47: { goto ctr9; } } if ( ( (*( p )) ) < 43 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 41 ) { goto st4; } } else if ( ( (*( p )) ) > 46 ) { if ( 48 <= ( (*( p )) ) ) { goto st4; } } else { goto st4; } { goto st4; } st6: p+= 1; if ( p == pe ) goto _test_eof6; st_case_6: if ( ( (*( p )) ) == 10 ) { goto ctr11; } if ( 11 <= ( (*( p )) ) ) { goto st6; } { goto st6; } st27: p+= 1; if ( p == pe ) goto _test_eof27; st_case_27: if ( ( (*( p )) ) > 57 ) { { goto ctr48; } } else if ( ( (*( p )) ) >= 48 ) { goto st27; } { goto ctr48; } st28: p+= 1; if ( p == pe ) goto _test_eof28; st_case_28: switch ( ( (*( p )) ) ) { case 95: { goto st28; } case 96: { goto ctr49; } } if ( ( (*( p )) ) < 65 ) { if ( ( (*( p )) ) > 57 ) { { goto ctr49; } } else if ( ( (*( p )) ) >= 48 ) { goto st28; } } else if ( ( (*( p )) ) > 90 ) { if ( ( (*( p )) ) < 97 ) { if ( ( (*( p )) ) <= 94 ) { goto ctr49; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr49; } } else { goto st28; } } else { goto st28; } { goto ctr49; } ctr12: {{p = ((te))-1; }} goto st29; ctr14: {{te = p+1; }} goto st29; ctr21: {{te = p+1; }} goto st29; ctr23: {curline++; } {{te = p+1; }} goto st29; ctr50: {{te = p+1; }} goto st29; ctr60: {{te = p+1; {curly_count += 1; } }} goto st29; ctr61: {{te = p+1; {if ( --curly_count == 0 ) { /* Send the entire block and free the inline_start pointer. */ try_token( TK_Inline, inline_start, te ); inline_start = 0; {goto st41;}} } }} goto st29; ctr62: {{te = p; p-= 1; }} goto st29; ctr63: {{te = p; p-= 1; }} goto st29; ctr64: {{te = p+1; {if ( inline_start < ts ) try_token( TK_Inline, inline_start, ts ); try_token( TK_Reference, ts, te ); inline_start = te; } }} goto st29; ctr66: {{te = p; p-= 1; {if ( inline_start < ts ) try_token( TK_Inline, inline_start, ts ); try_token( TK_Reference, ts, te ); inline_start = te; } }} goto st29; ctr67: {{te = p; p-= 1; }} goto st29; ctr68: {{te = p; p-= 1; }} goto st29; st29: {{ts = 0; }} p+= 1; if ( p == pe ) goto _test_eof29; st_case_29: {{ts = p; }} switch ( ( (*( p )) ) ) { case 9: { goto st30; } case 10: { goto ctr52; } case 13: { goto st30; } case 32: { goto st30; } case 33: { goto ctr50; } case 34: { goto ctr53; } case 35: { goto ctr50; } case 36: { goto st32; } case 39: { goto ctr55; } case 47: { goto ctr56; } case 64: { goto st37; } case 95: { goto st38; } case 96: { goto ctr50; } case 123: { goto ctr60; } case 124: { goto ctr50; } case 125: { goto ctr61; } } if ( ( (*( p )) ) < 48 ) { if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto ctr50; } } else if ( ( (*( p )) ) > 31 ) { if ( ( (*( p )) ) > 38 ) { if ( 40 <= ( (*( p )) ) && ( (*( p )) ) <= 46 ) { goto ctr50; } } else if ( ( (*( p )) ) >= 37 ) { goto ctr50; } } else { goto ctr50; } } else if ( ( (*( p )) ) > 57 ) { if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) > 63 ) { if ( 65 <= ( (*( p )) ) ) { goto st38; } } else { goto ctr50; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) > 122 ) { if ( 126 <= ( (*( p )) ) ) { goto ctr50; } } else if ( ( (*( p )) ) >= 97 ) { goto st38; } } else { goto ctr50; } } else { goto st36; } { goto ctr50; } ctr52: {curline++; } goto st30; st30: p+= 1; if ( p == pe ) goto _test_eof30; st_case_30: switch ( ( (*( p )) ) ) { case 9: { goto st30; } case 10: { goto ctr52; } case 13: { goto st30; } case 32: { goto st30; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto ctr62; } } else if ( ( (*( p )) ) > 31 ) { if ( 33 <= ( (*( p )) ) ) { goto ctr62; } } else { goto ctr62; } { goto ctr62; } ctr53: {{te = p+1; }} goto st31; st31: p+= 1; if ( p == pe ) goto _test_eof31; st_case_31: switch ( ( (*( p )) ) ) { case 10: { goto ctr63; } case 13: { goto ctr63; } case 34: { goto ctr14; } case 92: { goto st8; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st7; } } else if ( ( (*( p )) ) > 33 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st7; } } else if ( ( (*( p )) ) >= 35 ) { goto st7; } } else { goto st7; } { goto st7; } st7: p+= 1; if ( p == pe ) goto _test_eof7; st_case_7: switch ( ( (*( p )) ) ) { case 10: { goto ctr12; } case 13: { goto ctr12; } case 34: { goto ctr14; } case 92: { goto st8; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st7; } } else if ( ( (*( p )) ) > 33 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st7; } } else if ( ( (*( p )) ) >= 35 ) { goto st7; } } else { goto st7; } { goto st7; } st8: p+= 1; if ( p == pe ) goto _test_eof8; st_case_8: if ( ( (*( p )) ) == 10 ) { goto ctr12; } if ( 11 <= ( (*( p )) ) ) { goto st7; } { goto st7; } st32: p+= 1; if ( p == pe ) goto _test_eof32; st_case_32: if ( ( (*( p )) ) == 36 ) { goto ctr64; } if ( ( (*( p )) ) < 48 ) { if ( 37 <= ( (*( p )) ) ) { goto ctr63; } } else if ( ( (*( p )) ) > 57 ) { { goto ctr63; } } else { goto st33; } { goto ctr63; } st33: p+= 1; if ( p == pe ) goto _test_eof33; st_case_33: if ( ( (*( p )) ) > 57 ) { { goto ctr66; } } else if ( ( (*( p )) ) >= 48 ) { goto st33; } { goto ctr66; } ctr55: {{te = p+1; }} goto st34; st34: p+= 1; if ( p == pe ) goto _test_eof34; st_case_34: switch ( ( (*( p )) ) ) { case 10: { goto ctr63; } case 13: { goto ctr63; } case 39: { goto ctr14; } case 92: { goto st10; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st9; } } else if ( ( (*( p )) ) > 38 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st9; } } else if ( ( (*( p )) ) >= 40 ) { goto st9; } } else { goto st9; } { goto st9; } st9: p+= 1; if ( p == pe ) goto _test_eof9; st_case_9: switch ( ( (*( p )) ) ) { case 10: { goto ctr12; } case 13: { goto ctr12; } case 39: { goto ctr14; } case 92: { goto st10; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st9; } } else if ( ( (*( p )) ) > 38 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st9; } } else if ( ( (*( p )) ) >= 40 ) { goto st9; } } else { goto st9; } { goto st9; } st10: p+= 1; if ( p == pe ) goto _test_eof10; st_case_10: if ( ( (*( p )) ) == 10 ) { goto ctr12; } if ( 11 <= ( (*( p )) ) ) { goto st9; } { goto st9; } ctr56: {{te = p+1; }} goto st35; st35: p+= 1; if ( p == pe ) goto _test_eof35; st_case_35: switch ( ( (*( p )) ) ) { case 42: { goto st11; } case 47: { goto st13; } } if ( ( (*( p )) ) > 46 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr63; } } else if ( ( (*( p )) ) >= 43 ) { goto ctr63; } { goto ctr63; } ctr19: {curline++; } goto st11; st11: p+= 1; if ( p == pe ) goto _test_eof11; st_case_11: switch ( ( (*( p )) ) ) { case 10: { goto ctr19; } case 42: { goto st12; } } if ( ( (*( p )) ) > 41 ) { if ( 43 <= ( (*( p )) ) ) { goto st11; } } else if ( ( (*( p )) ) >= 11 ) { goto st11; } { goto st11; } st12: p+= 1; if ( p == pe ) goto _test_eof12; st_case_12: switch ( ( (*( p )) ) ) { case 10: { goto ctr19; } case 42: { goto st12; } case 47: { goto ctr21; } } if ( ( (*( p )) ) < 43 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 41 ) { goto st11; } } else if ( ( (*( p )) ) > 46 ) { if ( 48 <= ( (*( p )) ) ) { goto st11; } } else { goto st11; } { goto st11; } st13: p+= 1; if ( p == pe ) goto _test_eof13; st_case_13: if ( ( (*( p )) ) == 10 ) { goto ctr23; } if ( 11 <= ( (*( p )) ) ) { goto st13; } { goto st13; } st36: p+= 1; if ( p == pe ) goto _test_eof36; st_case_36: if ( ( (*( p )) ) > 57 ) { { goto ctr67; } } else if ( ( (*( p )) ) >= 48 ) { goto st36; } { goto ctr67; } st37: p+= 1; if ( p == pe ) goto _test_eof37; st_case_37: if ( ( (*( p )) ) == 64 ) { goto ctr64; } if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto st33; } } else if ( ( (*( p )) ) > 63 ) { if ( 65 <= ( (*( p )) ) ) { goto ctr63; } } else { goto ctr63; } { goto ctr63; } st38: p+= 1; if ( p == pe ) goto _test_eof38; st_case_38: switch ( ( (*( p )) ) ) { case 95: { goto st38; } case 96: { goto ctr68; } } if ( ( (*( p )) ) < 65 ) { if ( ( (*( p )) ) > 57 ) { { goto ctr68; } } else if ( ( (*( p )) ) >= 48 ) { goto st38; } } else if ( ( (*( p )) ) > 90 ) { if ( ( (*( p )) ) < 97 ) { if ( ( (*( p )) ) <= 94 ) { goto ctr68; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr68; } } else { goto st38; } } else { goto st38; } { goto ctr68; } ctr70: {{te = p+1; {try_token( ';' ); {goto st41;}} }} goto st39; ctr71: {{te = p; p-= 1; {try_token( TK_AccessData, ts, te ); } }} goto st39; st39: {{ts = 0; }} p+= 1; if ( p == pe ) goto _test_eof39; st_case_39: {{ts = p; }} if ( ( (*( p )) ) == 59 ) { goto ctr70; } if ( 60 <= ( (*( p )) ) ) { goto st40; } { goto st40; } st40: p+= 1; if ( p == pe ) goto _test_eof40; st_case_40: if ( ( (*( p )) ) == 59 ) { goto ctr71; } if ( 60 <= ( (*( p )) ) ) { goto st40; } { goto st40; } ctr24: {{p = ((te))-1; {try_token( *ts, 0, 0 ); } }} goto st41; ctr26: {{te = p+1; {try_token( TK_String, ts+1, te-1 ); } }} goto st41; ctr29: {curline++; } {{te = p+1; }} goto st41; ctr30: {{te = p+1; {try_token( TK_Literal, ts+1, te-1 ); } }} goto st41; ctr32: {{te = p+1; {endSection(); {goto st20;}} }} goto st41; ctr72: {{te = p+1; {try_token( *ts, 0, 0 ); } }} goto st41; ctr74: {curline++; } {{te = p+1; {if ( singleLineSpec ) { endSection(); {goto st20;}} } }} goto st41; ctr90: {{te = p+1; {inline_start_line = curline; inline_start = ts; curly_count = 1; {goto st29;}} }} goto st41; ctr92: {{te = p; p-= 1; }} goto st41; ctr93: {{te = p; p-= 1; {try_token( *ts, 0, 0 ); } }} goto st41; ctr95: {{te = p; p-= 1; {try_token( TK_Number, ts, te ); } }} goto st41; ctr96: {{switch ( act ) { case 12 : p = ((te))-1; {try_token( KW_Commit ); } break; case 13 : p = ((te))-1; {try_token( KW_Try ); } break; case 14 : p = ((te))-1; {try_token( KW_Undo ); } break; case 15 : p = ((te))-1; {try_token( KW_Final ); } break; case 16 : p = ((te))-1; {try_token( KW_Translate ); } break; case 17 : p = ((te))-1; {try_token( KW_Token ); } break; case 18 : p = ((te))-1; {try_token( KW_NonTerm ); } break; case 19 : p = ((te))-1; {try_token( KW_Uses ); } break; case 20 : p = ((te))-1; {try_token( KW_Type ); } break; case 21 : p = ((te))-1; {try_token( KW_Parser ); } break; case 22 : p = ((te))-1; {try_token( KW_Include ); } break; case 23 : p = ((te))-1; {try_token( KW_Pri ); } break; case 24 : p = ((te))-1; {try_token( KW_Write ); } break; case 25 : p = ((te))-1; {try_token( KW_Class ); } break; case 26 : p = ((te))-1; {try_token( KW_Shortest ); } break; case 28 : p = ((te))-1; {try_token( TK_Word, ts, te ); } break; } } } goto st41; ctr97: {{te = p; p-= 1; {try_token( TK_Word, ts, te ); } }} goto st41; ctr103: {{te = p; p-= 1; {try_token( KW_Access ); {goto st39;}} }} goto st41; st41: {{ts = 0; }} p+= 1; if ( p == pe ) goto _test_eof41; st_case_41: {{ts = p; }} switch ( ( (*( p )) ) ) { case 9: { goto st42; } case 10: { goto ctr74; } case 13: { goto st42; } case 32: { goto st42; } case 33: { goto ctr72; } case 34: { goto ctr75; } case 35: { goto ctr76; } case 39: { goto ctr77; } case 95: { goto ctr79; } case 96: { goto ctr72; } case 97: { goto st48; } case 98: { goto ctr79; } case 99: { goto st55; } case 102: { goto st63; } case 105: { goto st67; } case 110: { goto st73; } case 111: { goto ctr79; } case 112: { goto st79; } case 115: { goto st85; } case 116: { goto st92; } case 117: { goto st105; } case 118: { goto ctr79; } case 119: { goto st110; } case 123: { goto ctr90; } case 124: { goto ctr72; } case 125: { goto ctr91; } } if ( ( (*( p )) ) < 65 ) { if ( ( (*( p )) ) < 36 ) { if ( ( (*( p )) ) > 12 ) { if ( 14 <= ( (*( p )) ) && ( (*( p )) ) <= 31 ) { goto ctr72; } } else if ( ( (*( p )) ) >= 11 ) { goto ctr72; } } else if ( ( (*( p )) ) > 38 ) { if ( ( (*( p )) ) < 48 ) { if ( 40 <= ( (*( p )) ) ) { goto ctr72; } } else if ( ( (*( p )) ) > 57 ) { { goto ctr72; } } else { goto st46; } } else { goto ctr72; } } else if ( ( (*( p )) ) > 90 ) { if ( ( (*( p )) ) < 106 ) { if ( ( (*( p )) ) < 100 ) { if ( ( (*( p )) ) <= 94 ) { goto ctr72; } } else if ( ( (*( p )) ) > 101 ) { if ( 103 <= ( (*( p )) ) && ( (*( p )) ) <= 104 ) { goto ctr79; } } else { goto ctr79; } } else if ( ( (*( p )) ) > 109 ) { if ( ( (*( p )) ) < 120 ) { if ( 113 <= ( (*( p )) ) && ( (*( p )) ) <= 114 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { if ( 126 <= ( (*( p )) ) ) { goto ctr72; } } else { goto ctr79; } } else { goto ctr79; } } else { goto ctr79; } { goto ctr72; } st42: p+= 1; if ( p == pe ) goto _test_eof42; st_case_42: switch ( ( (*( p )) ) ) { case 9: { goto st42; } case 13: { goto st42; } case 32: { goto st42; } } if ( ( (*( p )) ) < 14 ) { if ( 10 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto ctr92; } } else if ( ( (*( p )) ) > 31 ) { if ( 33 <= ( (*( p )) ) ) { goto ctr92; } } else { goto ctr92; } { goto ctr92; } ctr75: {{te = p+1; }} goto st43; st43: p+= 1; if ( p == pe ) goto _test_eof43; st_case_43: switch ( ( (*( p )) ) ) { case 10: { goto ctr93; } case 13: { goto ctr93; } case 34: { goto ctr26; } case 92: { goto st15; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st14; } } else if ( ( (*( p )) ) > 33 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st14; } } else if ( ( (*( p )) ) >= 35 ) { goto st14; } } else { goto st14; } { goto st14; } st14: p+= 1; if ( p == pe ) goto _test_eof14; st_case_14: switch ( ( (*( p )) ) ) { case 10: { goto ctr24; } case 13: { goto ctr24; } case 34: { goto ctr26; } case 92: { goto st15; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st14; } } else if ( ( (*( p )) ) > 33 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st14; } } else if ( ( (*( p )) ) >= 35 ) { goto st14; } } else { goto st14; } { goto st14; } st15: p+= 1; if ( p == pe ) goto _test_eof15; st_case_15: if ( ( (*( p )) ) == 10 ) { goto ctr24; } if ( 11 <= ( (*( p )) ) ) { goto st14; } { goto st14; } ctr76: {{te = p+1; }} goto st44; st44: p+= 1; if ( p == pe ) goto _test_eof44; st_case_44: if ( ( (*( p )) ) == 10 ) { goto ctr29; } if ( 11 <= ( (*( p )) ) ) { goto st16; } { goto st16; } st16: p+= 1; if ( p == pe ) goto _test_eof16; st_case_16: if ( ( (*( p )) ) == 10 ) { goto ctr29; } if ( 11 <= ( (*( p )) ) ) { goto st16; } { goto st16; } ctr77: {{te = p+1; }} goto st45; st45: p+= 1; if ( p == pe ) goto _test_eof45; st_case_45: switch ( ( (*( p )) ) ) { case 10: { goto ctr93; } case 13: { goto ctr93; } case 39: { goto ctr93; } case 92: { goto st18; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto st17; } } else if ( ( (*( p )) ) > 38 ) { if ( ( (*( p )) ) > 91 ) { if ( 93 <= ( (*( p )) ) ) { goto st17; } } else if ( ( (*( p )) ) >= 40 ) { goto st17; } } else { goto st17; } { goto st17; } st17: p+= 1; if ( p == pe ) goto _test_eof17; st_case_17: if ( ( (*( p )) ) == 39 ) { goto ctr30; } if ( 40 <= ( (*( p )) ) ) { goto ctr24; } { goto ctr24; } st18: p+= 1; if ( p == pe ) goto _test_eof18; st_case_18: { goto st17; } st46: p+= 1; if ( p == pe ) goto _test_eof46; st_case_46: if ( ( (*( p )) ) > 57 ) { { goto ctr95; } } else if ( ( (*( p )) ) >= 48 ) { goto st46; } { goto ctr95; } ctr79: {{te = p+1; }} {{act = 28; }} goto st47; ctr110: {{te = p+1; }} {{act = 25; }} goto st47; ctr114: {{te = p+1; }} {{act = 12; }} goto st47; ctr118: {{te = p+1; }} {{act = 15; }} goto st47; ctr124: {{te = p+1; }} {{act = 22; }} goto st47; ctr130: {{te = p+1; }} {{act = 18; }} goto st47; ctr136: {{te = p+1; }} {{act = 21; }} goto st47; ctr137: {{te = p+1; }} {{act = 23; }} goto st47; ctr144: {{te = p+1; }} {{act = 26; }} goto st47; ctr150: {{te = p+1; }} {{act = 17; }} goto st47; ctr152: {{te = p+1; }} {{act = 13; }} goto st47; ctr158: {{te = p+1; }} {{act = 16; }} goto st47; ctr160: {{te = p+1; }} {{act = 20; }} goto st47; ctr164: {{te = p+1; }} {{act = 14; }} goto st47; ctr166: {{te = p+1; }} {{act = 19; }} goto st47; ctr170: {{te = p+1; }} {{act = 24; }} goto st47; st47: p+= 1; if ( p == pe ) goto _test_eof47; st_case_47: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr96; } } if ( ( (*( p )) ) < 65 ) { if ( ( (*( p )) ) > 57 ) { { goto ctr96; } } else if ( ( (*( p )) ) >= 48 ) { goto ctr79; } } else if ( ( (*( p )) ) > 90 ) { if ( ( (*( p )) ) < 97 ) { if ( ( (*( p )) ) <= 94 ) { goto ctr96; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr96; } } else { goto ctr79; } } else { goto ctr79; } { goto ctr96; } st48: p+= 1; if ( p == pe ) goto _test_eof48; st_case_48: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 99: { goto st49; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 100 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 98 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st49: p+= 1; if ( p == pe ) goto _test_eof49; st_case_49: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 99: { goto st50; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 100 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 98 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st50: p+= 1; if ( p == pe ) goto _test_eof50; st_case_50: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto st51; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st51: p+= 1; if ( p == pe ) goto _test_eof51; st_case_51: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 115: { goto st52; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 116 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 114 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st52: p+= 1; if ( p == pe ) goto _test_eof52; st_case_52: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 115: { goto st53; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 116 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 114 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st53: p+= 1; if ( p == pe ) goto _test_eof53; st_case_53: switch ( ( (*( p )) ) ) { case 9: { goto st54; } case 10: { goto ctr105; } case 13: { goto st54; } case 32: { goto st54; } case 95: { goto ctr79; } case 96: { goto ctr103; } } if ( ( (*( p )) ) < 58 ) { if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto ctr103; } } else if ( ( (*( p )) ) > 31 ) { if ( ( (*( p )) ) > 47 ) { { goto ctr79; } } else if ( ( (*( p )) ) >= 33 ) { goto ctr103; } } else { goto ctr103; } } else if ( ( (*( p )) ) > 64 ) { if ( ( (*( p )) ) < 91 ) { { goto ctr79; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) > 122 ) { { goto ctr103; } } else if ( ( (*( p )) ) >= 97 ) { goto ctr79; } } else { goto ctr103; } } else { goto ctr103; } { goto ctr103; } ctr105: {curline++; } goto st54; st54: p+= 1; if ( p == pe ) goto _test_eof54; st_case_54: switch ( ( (*( p )) ) ) { case 9: { goto st54; } case 10: { goto ctr105; } case 13: { goto st54; } case 32: { goto st54; } } if ( ( (*( p )) ) < 14 ) { if ( 11 <= ( (*( p )) ) && ( (*( p )) ) <= 12 ) { goto ctr103; } } else if ( ( (*( p )) ) > 31 ) { if ( 33 <= ( (*( p )) ) ) { goto ctr103; } } else { goto ctr103; } { goto ctr103; } st55: p+= 1; if ( p == pe ) goto _test_eof55; st_case_55: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 108: { goto st56; } case 111: { goto st59; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 109 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 107 ) { goto ctr79; } } else if ( ( (*( p )) ) > 110 ) { if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else if ( ( (*( p )) ) >= 112 ) { goto ctr79; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st56: p+= 1; if ( p == pe ) goto _test_eof56; st_case_56: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 97: { goto st57; } } if ( ( (*( p )) ) < 65 ) { if ( ( (*( p )) ) > 57 ) { { goto ctr97; } } else if ( ( (*( p )) ) >= 48 ) { goto ctr79; } } else if ( ( (*( p )) ) > 90 ) { if ( ( (*( p )) ) < 98 ) { if ( ( (*( p )) ) <= 94 ) { goto ctr97; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr79; } { goto ctr97; } st57: p+= 1; if ( p == pe ) goto _test_eof57; st_case_57: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 115: { goto st58; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 116 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 114 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st58: p+= 1; if ( p == pe ) goto _test_eof58; st_case_58: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 115: { goto ctr110; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 116 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 114 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st59: p+= 1; if ( p == pe ) goto _test_eof59; st_case_59: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 109: { goto st60; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 110 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 108 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st60: p+= 1; if ( p == pe ) goto _test_eof60; st_case_60: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 109: { goto st61; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 110 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 108 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st61: p+= 1; if ( p == pe ) goto _test_eof61; st_case_61: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 105: { goto st62; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 106 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 104 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st62: p+= 1; if ( p == pe ) goto _test_eof62; st_case_62: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 116: { goto ctr114; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 117 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 115 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st63: p+= 1; if ( p == pe ) goto _test_eof63; st_case_63: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 105: { goto st64; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 106 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 104 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st64: p+= 1; if ( p == pe ) goto _test_eof64; st_case_64: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 110: { goto st65; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 111 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 109 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st65: p+= 1; if ( p == pe ) goto _test_eof65; st_case_65: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 97: { goto st66; } } if ( ( (*( p )) ) < 65 ) { if ( ( (*( p )) ) > 57 ) { { goto ctr97; } } else if ( ( (*( p )) ) >= 48 ) { goto ctr79; } } else if ( ( (*( p )) ) > 90 ) { if ( ( (*( p )) ) < 98 ) { if ( ( (*( p )) ) <= 94 ) { goto ctr97; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr79; } { goto ctr97; } st66: p+= 1; if ( p == pe ) goto _test_eof66; st_case_66: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 108: { goto ctr118; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 109 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 107 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st67: p+= 1; if ( p == pe ) goto _test_eof67; st_case_67: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 110: { goto st68; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 111 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 109 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st68: p+= 1; if ( p == pe ) goto _test_eof68; st_case_68: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 99: { goto st69; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 100 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 98 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st69: p+= 1; if ( p == pe ) goto _test_eof69; st_case_69: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 108: { goto st70; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 109 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 107 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st70: p+= 1; if ( p == pe ) goto _test_eof70; st_case_70: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 117: { goto st71; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 118 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 116 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st71: p+= 1; if ( p == pe ) goto _test_eof71; st_case_71: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 100: { goto st72; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 101 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 99 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st72: p+= 1; if ( p == pe ) goto _test_eof72; st_case_72: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto ctr124; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st73: p+= 1; if ( p == pe ) goto _test_eof73; st_case_73: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 111: { goto st74; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 112 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 110 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st74: p+= 1; if ( p == pe ) goto _test_eof74; st_case_74: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 110: { goto st75; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 111 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 109 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st75: p+= 1; if ( p == pe ) goto _test_eof75; st_case_75: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 116: { goto st76; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 117 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 115 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st76: p+= 1; if ( p == pe ) goto _test_eof76; st_case_76: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto st77; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st77: p+= 1; if ( p == pe ) goto _test_eof77; st_case_77: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 114: { goto st78; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 115 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 113 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st78: p+= 1; if ( p == pe ) goto _test_eof78; st_case_78: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 109: { goto ctr130; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 110 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 108 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st79: p+= 1; if ( p == pe ) goto _test_eof79; st_case_79: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 97: { goto st80; } case 114: { goto st84; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 115 ) { if ( 98 <= ( (*( p )) ) && ( (*( p )) ) <= 113 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st80: p+= 1; if ( p == pe ) goto _test_eof80; st_case_80: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 114: { goto st81; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 115 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 113 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st81: p+= 1; if ( p == pe ) goto _test_eof81; st_case_81: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 115: { goto st82; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 116 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 114 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st82: p+= 1; if ( p == pe ) goto _test_eof82; st_case_82: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto st83; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st83: p+= 1; if ( p == pe ) goto _test_eof83; st_case_83: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 114: { goto ctr136; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 115 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 113 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st84: p+= 1; if ( p == pe ) goto _test_eof84; st_case_84: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 105: { goto ctr137; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 106 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 104 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st85: p+= 1; if ( p == pe ) goto _test_eof85; st_case_85: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 104: { goto st86; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 105 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 103 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st86: p+= 1; if ( p == pe ) goto _test_eof86; st_case_86: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 111: { goto st87; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 112 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 110 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st87: p+= 1; if ( p == pe ) goto _test_eof87; st_case_87: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 114: { goto st88; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 115 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 113 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st88: p+= 1; if ( p == pe ) goto _test_eof88; st_case_88: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 116: { goto st89; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 117 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 115 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st89: p+= 1; if ( p == pe ) goto _test_eof89; st_case_89: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto st90; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st90: p+= 1; if ( p == pe ) goto _test_eof90; st_case_90: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 115: { goto st91; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 116 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 114 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st91: p+= 1; if ( p == pe ) goto _test_eof91; st_case_91: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 116: { goto ctr144; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 117 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 115 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st92: p+= 1; if ( p == pe ) goto _test_eof92; st_case_92: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 111: { goto st93; } case 114: { goto st96; } case 121: { goto st103; } case 122: { goto ctr79; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 112 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 110 ) { goto ctr79; } } else if ( ( (*( p )) ) > 113 ) { if ( ( (*( p )) ) > 120 ) { if ( 123 <= ( (*( p )) ) ) { goto ctr97; } } else if ( ( (*( p )) ) >= 115 ) { goto ctr79; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st93: p+= 1; if ( p == pe ) goto _test_eof93; st_case_93: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 107: { goto st94; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 108 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 106 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st94: p+= 1; if ( p == pe ) goto _test_eof94; st_case_94: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto st95; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st95: p+= 1; if ( p == pe ) goto _test_eof95; st_case_95: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 110: { goto ctr150; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 111 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 109 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st96: p+= 1; if ( p == pe ) goto _test_eof96; st_case_96: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 97: { goto st97; } case 121: { goto ctr152; } case 122: { goto ctr79; } } if ( ( (*( p )) ) < 65 ) { if ( ( (*( p )) ) > 57 ) { { goto ctr97; } } else if ( ( (*( p )) ) >= 48 ) { goto ctr79; } } else if ( ( (*( p )) ) > 90 ) { if ( ( (*( p )) ) < 98 ) { if ( ( (*( p )) ) <= 94 ) { goto ctr97; } } else if ( ( (*( p )) ) > 120 ) { if ( 123 <= ( (*( p )) ) ) { goto ctr97; } } else { goto ctr79; } } else { goto ctr79; } { goto ctr97; } st97: p+= 1; if ( p == pe ) goto _test_eof97; st_case_97: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 110: { goto st98; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 111 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 109 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st98: p+= 1; if ( p == pe ) goto _test_eof98; st_case_98: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 115: { goto st99; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 116 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 114 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st99: p+= 1; if ( p == pe ) goto _test_eof99; st_case_99: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 108: { goto st100; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 109 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 107 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st100: p+= 1; if ( p == pe ) goto _test_eof100; st_case_100: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 97: { goto st101; } } if ( ( (*( p )) ) < 65 ) { if ( ( (*( p )) ) > 57 ) { { goto ctr97; } } else if ( ( (*( p )) ) >= 48 ) { goto ctr79; } } else if ( ( (*( p )) ) > 90 ) { if ( ( (*( p )) ) < 98 ) { if ( ( (*( p )) ) <= 94 ) { goto ctr97; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr79; } { goto ctr97; } st101: p+= 1; if ( p == pe ) goto _test_eof101; st_case_101: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 116: { goto st102; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 117 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 115 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st102: p+= 1; if ( p == pe ) goto _test_eof102; st_case_102: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto ctr158; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st103: p+= 1; if ( p == pe ) goto _test_eof103; st_case_103: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 112: { goto st104; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 113 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 111 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st104: p+= 1; if ( p == pe ) goto _test_eof104; st_case_104: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto ctr160; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st105: p+= 1; if ( p == pe ) goto _test_eof105; st_case_105: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 110: { goto st106; } case 115: { goto st108; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 111 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 109 ) { goto ctr79; } } else if ( ( (*( p )) ) > 114 ) { if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else if ( ( (*( p )) ) >= 116 ) { goto ctr79; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st106: p+= 1; if ( p == pe ) goto _test_eof106; st_case_106: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 100: { goto st107; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 101 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 99 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st107: p+= 1; if ( p == pe ) goto _test_eof107; st_case_107: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 111: { goto ctr164; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 112 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 110 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st108: p+= 1; if ( p == pe ) goto _test_eof108; st_case_108: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto st109; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st109: p+= 1; if ( p == pe ) goto _test_eof109; st_case_109: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 115: { goto ctr166; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 116 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 114 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st110: p+= 1; if ( p == pe ) goto _test_eof110; st_case_110: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 114: { goto st111; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 115 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 113 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st111: p+= 1; if ( p == pe ) goto _test_eof111; st_case_111: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 105: { goto st112; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 106 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 104 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st112: p+= 1; if ( p == pe ) goto _test_eof112; st_case_112: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 116: { goto st113; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 117 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 115 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } st113: p+= 1; if ( p == pe ) goto _test_eof113; st_case_113: switch ( ( (*( p )) ) ) { case 95: { goto ctr79; } case 96: { goto ctr97; } case 101: { goto ctr170; } } if ( ( (*( p )) ) < 91 ) { if ( ( (*( p )) ) < 58 ) { if ( 48 <= ( (*( p )) ) ) { goto ctr79; } } else if ( ( (*( p )) ) > 64 ) { { goto ctr79; } } else { goto ctr97; } } else if ( ( (*( p )) ) > 94 ) { if ( ( (*( p )) ) < 102 ) { if ( 97 <= ( (*( p )) ) && ( (*( p )) ) <= 100 ) { goto ctr79; } } else if ( ( (*( p )) ) > 122 ) { { goto ctr97; } } else { goto ctr79; } } else { goto ctr97; } { goto ctr97; } ctr91: {{te = p+1; }} goto st114; st114: p+= 1; if ( p == pe ) goto _test_eof114; st_case_114: if ( ( (*( p )) ) == 37 ) { goto st19; } if ( 38 <= ( (*( p )) ) ) { goto ctr93; } { goto ctr93; } st19: p+= 1; if ( p == pe ) goto _test_eof19; st_case_19: if ( ( (*( p )) ) == 37 ) { goto ctr32; } if ( 38 <= ( (*( p )) ) ) { goto ctr24; } { goto ctr24; } st_out: _test_eof20: cs = 20; goto _test_eof; _test_eof21: cs = 21; goto _test_eof; _test_eof22: cs = 22; goto _test_eof; _test_eof0: cs = 0; goto _test_eof; _test_eof1: cs = 1; goto _test_eof; _test_eof23: cs = 23; goto _test_eof; _test_eof24: cs = 24; goto _test_eof; _test_eof25: cs = 25; goto _test_eof; _test_eof2: cs = 2; goto _test_eof; _test_eof3: cs = 3; goto _test_eof; _test_eof26: cs = 26; goto _test_eof; _test_eof4: cs = 4; goto _test_eof; _test_eof5: cs = 5; goto _test_eof; _test_eof6: cs = 6; goto _test_eof; _test_eof27: cs = 27; goto _test_eof; _test_eof28: cs = 28; goto _test_eof; _test_eof29: cs = 29; goto _test_eof; _test_eof30: cs = 30; goto _test_eof; _test_eof31: cs = 31; goto _test_eof; _test_eof7: cs = 7; goto _test_eof; _test_eof8: cs = 8; goto _test_eof; _test_eof32: cs = 32; goto _test_eof; _test_eof33: cs = 33; goto _test_eof; _test_eof34: cs = 34; goto _test_eof; _test_eof9: cs = 9; goto _test_eof; _test_eof10: cs = 10; goto _test_eof; _test_eof35: cs = 35; goto _test_eof; _test_eof11: cs = 11; goto _test_eof; _test_eof12: cs = 12; goto _test_eof; _test_eof13: cs = 13; goto _test_eof; _test_eof36: cs = 36; goto _test_eof; _test_eof37: cs = 37; goto _test_eof; _test_eof38: cs = 38; goto _test_eof; _test_eof39: cs = 39; goto _test_eof; _test_eof40: cs = 40; goto _test_eof; _test_eof41: cs = 41; goto _test_eof; _test_eof42: cs = 42; goto _test_eof; _test_eof43: cs = 43; goto _test_eof; _test_eof14: cs = 14; goto _test_eof; _test_eof15: cs = 15; goto _test_eof; _test_eof44: cs = 44; goto _test_eof; _test_eof16: cs = 16; goto _test_eof; _test_eof45: cs = 45; goto _test_eof; _test_eof17: cs = 17; goto _test_eof; _test_eof18: cs = 18; goto _test_eof; _test_eof46: cs = 46; goto _test_eof; _test_eof47: cs = 47; goto _test_eof; _test_eof48: cs = 48; goto _test_eof; _test_eof49: cs = 49; goto _test_eof; _test_eof50: cs = 50; goto _test_eof; _test_eof51: cs = 51; goto _test_eof; _test_eof52: cs = 52; goto _test_eof; _test_eof53: cs = 53; goto _test_eof; _test_eof54: cs = 54; goto _test_eof; _test_eof55: cs = 55; goto _test_eof; _test_eof56: cs = 56; goto _test_eof; _test_eof57: cs = 57; goto _test_eof; _test_eof58: cs = 58; goto _test_eof; _test_eof59: cs = 59; goto _test_eof; _test_eof60: cs = 60; goto _test_eof; _test_eof61: cs = 61; goto _test_eof; _test_eof62: cs = 62; goto _test_eof; _test_eof63: cs = 63; goto _test_eof; _test_eof64: cs = 64; goto _test_eof; _test_eof65: cs = 65; goto _test_eof; _test_eof66: cs = 66; goto _test_eof; _test_eof67: cs = 67; goto _test_eof; _test_eof68: cs = 68; goto _test_eof; _test_eof69: cs = 69; goto _test_eof; _test_eof70: cs = 70; goto _test_eof; _test_eof71: cs = 71; goto _test_eof; _test_eof72: cs = 72; goto _test_eof; _test_eof73: cs = 73; goto _test_eof; _test_eof74: cs = 74; goto _test_eof; _test_eof75: cs = 75; goto _test_eof; _test_eof76: cs = 76; goto _test_eof; _test_eof77: cs = 77; goto _test_eof; _test_eof78: cs = 78; goto _test_eof; _test_eof79: cs = 79; goto _test_eof; _test_eof80: cs = 80; goto _test_eof; _test_eof81: cs = 81; goto _test_eof; _test_eof82: cs = 82; goto _test_eof; _test_eof83: cs = 83; goto _test_eof; _test_eof84: cs = 84; goto _test_eof; _test_eof85: cs = 85; goto _test_eof; _test_eof86: cs = 86; goto _test_eof; _test_eof87: cs = 87; goto _test_eof; _test_eof88: cs = 88; goto _test_eof; _test_eof89: cs = 89; goto _test_eof; _test_eof90: cs = 90; goto _test_eof; _test_eof91: cs = 91; goto _test_eof; _test_eof92: cs = 92; goto _test_eof; _test_eof93: cs = 93; goto _test_eof; _test_eof94: cs = 94; goto _test_eof; _test_eof95: cs = 95; goto _test_eof; _test_eof96: cs = 96; goto _test_eof; _test_eof97: cs = 97; goto _test_eof; _test_eof98: cs = 98; goto _test_eof; _test_eof99: cs = 99; goto _test_eof; _test_eof100: cs = 100; goto _test_eof; _test_eof101: cs = 101; goto _test_eof; _test_eof102: cs = 102; goto _test_eof; _test_eof103: cs = 103; goto _test_eof; _test_eof104: cs = 104; goto _test_eof; _test_eof105: cs = 105; goto _test_eof; _test_eof106: cs = 106; goto _test_eof; _test_eof107: cs = 107; goto _test_eof; _test_eof108: cs = 108; goto _test_eof; _test_eof109: cs = 109; goto _test_eof; _test_eof110: cs = 110; goto _test_eof; _test_eof111: cs = 111; goto _test_eof; _test_eof112: cs = 112; goto _test_eof; _test_eof113: cs = 113; goto _test_eof; _test_eof114: cs = 114; goto _test_eof; _test_eof19: cs = 19; goto _test_eof; _test_eof: {} if ( p == eof ) { switch ( cs ) { case 21: goto ctr43; case 22: goto ctr44; case 0: goto ctr0; case 1: goto ctr0; case 23: goto ctr44; case 24: goto ctr46; case 25: goto ctr44; case 2: goto ctr0; case 3: goto ctr0; case 26: goto ctr44; case 4: goto ctr0; case 5: goto ctr0; case 6: goto ctr0; case 27: goto ctr48; case 28: goto ctr49; case 30: goto ctr62; case 31: goto ctr63; case 7: goto ctr12; case 8: goto ctr12; case 32: goto ctr63; case 33: goto ctr66; case 34: goto ctr63; case 9: goto ctr12; case 10: goto ctr12; case 35: goto ctr63; case 11: goto ctr12; case 12: goto ctr12; case 13: goto ctr12; case 36: goto ctr67; case 37: goto ctr63; case 38: goto ctr68; case 40: goto ctr71; case 42: goto ctr92; case 43: goto ctr93; case 14: goto ctr24; case 15: goto ctr24; case 44: goto ctr93; case 16: goto ctr24; case 45: goto ctr93; case 17: goto ctr24; case 18: goto ctr24; case 46: goto ctr95; case 47: goto ctr96; case 48: goto ctr97; case 49: goto ctr97; case 50: goto ctr97; case 51: goto ctr97; case 52: goto ctr97; case 53: goto ctr103; case 54: goto ctr103; case 55: goto ctr97; case 56: goto ctr97; case 57: goto ctr97; case 58: goto ctr97; case 59: goto ctr97; case 60: goto ctr97; case 61: goto ctr97; case 62: goto ctr97; case 63: goto ctr97; case 64: goto ctr97; case 65: goto ctr97; case 66: goto ctr97; case 67: goto ctr97; case 68: goto ctr97; case 69: goto ctr97; case 70: goto ctr97; case 71: goto ctr97; case 72: goto ctr97; case 73: goto ctr97; case 74: goto ctr97; case 75: goto ctr97; case 76: goto ctr97; case 77: goto ctr97; case 78: goto ctr97; case 79: goto ctr97; case 80: goto ctr97; case 81: goto ctr97; case 82: goto ctr97; case 83: goto ctr97; case 84: goto ctr97; case 85: goto ctr97; case 86: goto ctr97; case 87: goto ctr97; case 88: goto ctr97; case 89: goto ctr97; case 90: goto ctr97; case 91: goto ctr97; case 92: goto ctr97; case 93: goto ctr97; case 94: goto ctr97; case 95: goto ctr97; case 96: goto ctr97; case 97: goto ctr97; case 98: goto ctr97; case 99: goto ctr97; case 100: goto ctr97; case 101: goto ctr97; case 102: goto ctr97; case 103: goto ctr97; case 104: goto ctr97; case 105: goto ctr97; case 106: goto ctr97; case 107: goto ctr97; case 108: goto ctr97; case 109: goto ctr97; case 110: goto ctr97; case 111: goto ctr97; case 112: goto ctr97; case 113: goto ctr97; case 114: goto ctr93; case 19: goto ctr24; } } } if ( cs == klscan_error ) { /* Machine failed before finding a token. */ cout << "PARSE ERROR" << endl; exit(1); } /* Decide if we need to preserve anything. */ char *preserve = ts; if ( inline_start != 0 && ( preserve == 0 || inline_start < preserve ) ) preserve = inline_start; /* Now set up the prefix. */ if ( preserve == 0 ) have = 0; else { /* There is data that needs to be shifted over. */ have = pe - preserve; memmove( buf, preserve, have ); unsigned int shiftback = preserve - buf; if ( ts != 0 ) ts -= shiftback; if ( inline_start != 0 ) inline_start -= shiftback; te -= shiftback; litstart -= shiftback; litend -= shiftback; identstart -= shiftback; identend -= shiftback; preserve = buf; } } delete[] buf; } void scan( const char *fileName, istream &input ) { ParserDict parserDict; Scanner scanner( fileName, input, parserDict, 0 ); scanner.do_scan(); /* This uses the most recent parser definition. */ if ( ::generateGraphviz && ::graphvizGenParser != 0 ) graphvizGenParser->pd.generateGraphviz(); } kelbt-0.16/src/fsmattach.cpp0000664000175000017500000001233212471720203012730 00000000000000/* * Copyright 2001, 2005, 2006 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include "fsmgraph.h" #include "kelbt.h" #include "parsedata.h" #include using namespace std; /* Insert a transition into an inlist. The head must be supplied. */ void FsmAp::attachToInList( StateAp *from, StateAp *to, TransAp *&head, TransAp *trans ) { trans->ilnext = head; trans->ilprev = 0; /* If in trans list is not empty, set the head->prev to trans. */ if ( head != 0 ) head->ilprev = trans; /* Now insert ourselves at the front of the list. */ head = trans; }; /* Detach a transition from an inlist. The head of the inlist must be supplied. */ void FsmAp::detachFromInList( StateAp *from, StateAp *to, TransAp *&head, TransAp *trans ) { /* Detach in the inTransList. */ if ( trans->ilprev == 0 ) head = trans->ilnext; else trans->ilprev->ilnext = trans->ilnext; if ( trans->ilnext != 0 ) trans->ilnext->ilprev = trans->ilprev; } /* Attach states on the default transition, range list or on out/in list key. * Type of attaching and is controlled by keyType. First makes a new * transition. If there is already a transition out from fromState on the * default, then will assertion fail. */ TransAp *FsmAp::attachNewTrans( StateAp *from, StateAp *to, long lowKey, long ) { /* Make the new transition. */ TransAp *retVal = new TransAp(); /* The transition is now attached. Remember the parties involved. */ retVal->fromState = from; retVal->toState = to; /* Make the entry in the out list for the transitions. */ from->transMap.append( TransMapEl( lowKey, retVal ) ); /* Set the the keys of the new trans. */ retVal->lowKey = lowKey; /* Attach using inRange as the head pointer. */ attachToInList( from, to, to->inRange.head, retVal ); return retVal; } /* Attach for range lists or for the default transition. Type of attaching is * controlled by the keyType parameter. This attach should be used when a * transition already is allocated and must be attached to a target state. * Does not handle adding the transition into the out list. */ void FsmAp::attachTrans( StateAp *from, StateAp *to, TransAp *trans ) { assert( trans->fromState == 0 && trans->toState == 0 ); trans->fromState = from; trans->toState = to; /* Attach using the inRange pointer as the head pointer. */ attachToInList( from, to, to->inRange.head, trans ); } /* Detach for out/in lists or for default transition. The type of detaching is * controlled by the keyType parameter. */ void FsmAp::detachTrans( StateAp *from, StateAp *to, TransAp *trans ) { assert( trans->fromState == from && trans->toState == to ); trans->fromState = 0; trans->toState = 0; /* Detach using to's inRange pointer as the head. */ detachFromInList( from, to, to->inRange.head, trans ); } /* Detach a state from the graph. Detaches and deletes transitions in and out * of the state. Empties inList and outList. Removes the state from the final * state set. A detached state becomes useless and should be deleted. */ void FsmAp::detachState( StateAp *state ) { /* Detach the in transitions from the inRange list of transitions. */ while ( state->inRange.head != 0 ) { /* Get pointers to the trans and the state. */ TransAp *trans = state->inRange.head; StateAp *fromState = trans->fromState; /* Detach the transitions from the source state. */ detachTrans( fromState, state, trans ); /* Ok to delete the transition. */ fromState->transMap.remove( trans->lowKey ); delete trans; } /* Detach out range transitions. */ for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { detachTrans( state, trans->value->toState, trans->value ); delete trans->value; } /* Delete all of the out range pointers. */ state->transMap.empty(); /* Unset final stateness before detaching from graph. */ if ( state->stateBits & SB_ISFINAL ) finStateSet.remove( state ); } /* Move all the transitions that go into src so that they go into dest. */ void FsmAp::inTransMove( StateAp *dest, StateAp *src ) { /* Do not try to move in trans to and from the same state. */ assert( dest != src ); /* If src is the start state, dest becomes the start state. */ assert( src != startState ); /* Move the transitions in inRange. */ while ( src->inRange.head != 0 ) { /* Get trans and from state. */ TransAp *trans = src->inRange.head; StateAp *fromState = trans->fromState; /* Detach from src, reattach to dest. */ detachTrans( fromState, src, trans ); attachTrans( fromState, dest, trans ); } } kelbt-0.16/src/fsmbase.cpp0000664000175000017500000001341212471720203012376 00000000000000/* * Copyright 2001, 2005 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include "fsmgraph.h" using std::cerr; using std::endl; /* Create a new fsm state. State has not out transitions or in transitions, not * out out transition data and not number. */ StateAp::StateAp() : /* No in transitions. */ inRange(), /* No entry points, or epsilon trans. */ pendingCommits(), stateSet(0), /* Only used during merging. Normally null. */ stateDictEl(0), /* No state identification bits. */ stateBits(0), onClosureQueue(false), inClosedMap(false), followMarked(false) { } /* Copy everything except actual the transitions. That is left up to the * FsmAp copy constructor. */ StateAp::StateAp(const StateAp &other) : inRange(), /* Duplicate the entry id set, epsilon transitions and context sets. These * are sets of integers and as such need no fixing. */ pendingCommits(other.pendingCommits), stateSet(0), /* This is only used during merging. Normally null. */ stateDictEl(0), /* Fsm state data. */ stateBits(other.stateBits), dotSet(other.dotSet), onClosureQueue(false), inClosedMap(false), followMarked(false), transMap() { /* Duplicate all the transitions. */ for ( TransMap::Iter trans = other.transMap; trans.lte(); trans++ ) { /* Dupicate and store the orginal target in the transition. This will * be corrected once all the states have been created. */ TransAp *newTrans = new TransAp(*trans->value); newTrans->toState = trans->value->toState; transMap.append( TransMapEl( newTrans->lowKey, newTrans ) ); } } /* If there is a state dict element, then delete it. Everything else is left * up to the FsmGraph destructor. */ StateAp::~StateAp() { if ( stateDictEl != 0 ) delete stateDictEl; } /* Graph constructor. */ FsmAp::FsmAp() : /* No start state. */ startState(0) { } /* Copy all graph data including transitions. */ FsmAp::FsmAp( const FsmAp &graph ) : /* Lists start empty. Will be filled by copy. */ stateList(), misfitList(), /* Copy in the entry points, * pointers will be resolved later. */ startState(graph.startState), /* Will be filled by copy. */ finStateSet() { /* Create the states and record their map in the original state. */ StateList::Iter origState = graph.stateList; for ( ; origState.lte(); origState++ ) { /* Make the new state. */ StateAp *newState = new StateAp( *origState ); /* Add the state to the list. */ stateList.append( newState ); /* Set the mapsTo item of the old state. */ origState->stateMap = newState; } /* Derefernce all the state maps. */ for ( StateList::Iter state = stateList; state.lte(); state++ ) { for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { /* The points to the original in the src machine. The taget's duplicate * is in the statemap. */ StateAp *toState = trans->value->toState != 0 ? trans->value->toState->stateMap : 0; /* Attach The transition to the duplicate. */ trans->value->toState = 0; attachTrans( state, toState, trans->value ); } } /* Fix the start state pointer and the new start state's count of in * transiions. */ startState = startState->stateMap; /* Build the final state set. */ StateSet::Iter st = graph.finStateSet; for ( ; st.lte(); st++ ) finStateSet.insert((*st)->stateMap); } /* Deletes all transition data then deletes each state. */ FsmAp::~FsmAp() { /* Delete all the transitions. */ StateList::Iter state = stateList; for ( ; state.lte(); state++ ) { for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) delete trans->value; } /* Delete all the states. */ stateList.empty(); } /* Set a state final. The state has its isFinState set to true and the state * is added to the finStateSet. */ void FsmAp::setFinState( StateAp *state ) { /* Is it already a fin state. */ if ( state->stateBits & SB_ISFINAL ) return; state->stateBits |= SB_ISFINAL; finStateSet.insert( state ); } void FsmAp::unsetAllFinStates( ) { for ( StateSet::Iter st = finStateSet; st.lte(); st++ ) { StateAp *state = *st; state->stateBits &= ~ SB_ISFINAL; } finStateSet.empty(); } /* Set and unset a state as the start state. */ void FsmAp::setStartState( StateAp *state ) { /* Sould change from unset to set. */ assert( startState == 0 ); startState = state; } /* Mark all states reachable from state. Traverses transitions forward. Used * for removing states that have no path into them. */ void FsmAp::markReachableFromHere( StateAp *state ) { /* Base case: return; */ if ( state->stateBits & SB_ISMARKED ) return; /* Set this state as processed. We are going to visit all states that this * state has a transition to. */ state->stateBits |= SB_ISMARKED; /* Recurse on all out transitions. */ for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { if ( trans->value->toState != 0 ) markReachableFromHere( trans->value->toState ); } } void FsmAp::setStateNumbers() { int curNum = 0; StateList::Iter state = stateList; for ( ; state.lte(); state++ ) state->stateNum = curNum++; } kelbt-0.16/src/fsmgraph.h0000664000175000017500000002672312471662307012255 00000000000000/* * Copyright 2001-2005 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _FSMGRAPH_H #define _FSMGRAPH_H #include #include "vector.h" #include "bstset.h" #include "compare.h" #include "avltree.h" #include "dlist.h" #include "bstmap.h" #include "sbstmap.h" #include "sbstset.h" #include "sbsttable.h" #include "avlset.h" #include "dlistmel.h" #include "avltree.h" /* Flags for states. */ #define SB_ISFINAL 0x04 #define SB_ISMARKED 0x08 #define SB_ISSTART 0x10 /* Flags for transitions. */ #define TB_ISMARKED 0x01 struct TransAp; struct StateAp; struct FsmAp; struct LongestMatchPart; struct Definition; struct KlangEl; typedef Vector ActDataList; struct ActionData { ActionData( int targ, ActDataList &actions, int commitLen ) : targ(targ), commitLen(commitLen), id(0), actions(actions) { } int targ; int commitLen; int id; ActDataList actions; }; struct CmpActionData { static int compare( const ActionData &ap1, const ActionData &ap2 ) { if ( ap1.targ < ap2.targ ) return -1; else if ( ap1.targ > ap2.targ ) return 1; else if ( ap1.commitLen < ap2.commitLen ) return -1; else if ( ap1.commitLen > ap2.commitLen ) return 1; else if ( ap1.id < ap2.id ) return -1; else if ( ap1.id > ap2.id ) return 1; return CmpTable< long, CmpOrd >:: compare( ap1.actions, ap2.actions ); } }; typedef AvlSet ActionSet; typedef AvlSetEl ActionSetEl; /* State list element for unambiguous access to list element. */ struct FsmListEl { StateAp *prev, *next; }; /* List pointers for the closure queue. Goes into state. */ struct ClosureQueueListEl { StateAp *prev, *next; }; /* Queue of states, transitions to be closed. */ typedef DListMel< StateAp, ClosureQueueListEl > StateClosureQueue; typedef DList TransClosureQueue; typedef BstSet< Definition*, CmpOrd > DefSet; typedef CmpTable< Definition*, CmpOrd > CmpDefSet; typedef BstSet< DefSet, CmpDefSet > DefSetSet; typedef Vector< Definition* > DefVect; typedef BstSet< long, CmpOrd > AlphSet; struct ExpandToEl { ExpandToEl( StateAp *state, int prodId ) : state(state), prodId(prodId) { } StateAp *state; int prodId; }; struct CmpExpandToEl { static inline int compare( const ExpandToEl &etel1, const ExpandToEl &etel2 ) { if ( etel1.state < etel2.state ) return -1; else if ( etel1.state > etel2.state ) return 1; else if ( etel1.prodId < etel2.prodId ) return -1; else if ( etel1.prodId > etel2.prodId ) return 1; else return 0; } }; typedef BstSet ExpandToSet; typedef BstSet< int, CmpOrd > IntSet; typedef CmpTable< int, CmpOrd > CmpIntSet; typedef BstSet< long, CmpOrd > LongSet; typedef CmpTable< long, CmpOrd > CmpLongSet; typedef BstMap< long, long, CmpOrd > LongMap; typedef BstMapEl< long, long > LongMapEl; typedef LongSet ProdIdSet; typedef CmpLongSet CmpProdIdSet; /* Set of states, list of states. */ typedef BstSet StateSet; typedef Vector StateVect; typedef DList StateList; typedef LongMap FollowToAdd; typedef LongMap ReductionMap; typedef LongMapEl ReductionMapEl; struct ProdIdPair { ProdIdPair( int onReduce, int length ) : onReduce(onReduce), length(length) {} int onReduce; int length; }; struct CmpProdIdPair { static inline int compare( const ProdIdPair &pair1, const ProdIdPair &pair2 ) { if ( pair1.onReduce < pair2.onReduce ) return -1; else if ( pair1.onReduce > pair2.onReduce ) return 1; else if ( pair1.length < pair2.length ) return -1; else if ( pair1.length > pair2.length ) return 1; else return 0; } }; typedef BstSet< ProdIdPair, CmpProdIdPair > ProdIdPairSet; /* Transition class that implements actions and priorities. */ struct TransAp { TransAp() : fromState(0), toState(0), isShift(false), isShiftReduce(false), shiftPrior(0) { } TransAp( const TransAp &other ) : lowKey(other.lowKey), fromState(0), toState(0), isShift(other.isShift), isShiftReduce(other.isShiftReduce), shiftPrior(other.shiftPrior), reductions(other.reductions), commits(other.commits) { } long lowKey; StateAp *fromState; StateAp *toState; /* Pointers for outlist. */ TransAp *prev, *next; /* Pointers for in-list. */ TransAp *ilprev, *ilnext; long maxPrior(); /* Parse Table construction data. */ bool isShift, isShiftReduce; int shiftPrior; ReductionMap reductions; ActDataList actions; ActDataList actOrds; ActDataList actPriors; ExpandToSet expandTo; ActionSetEl *actionSetEl; LongSet commits; LongSet afterShiftCommits; }; /* In transition list. Like DList except only has head pointers, which is all * that is required. Insertion and deletion is handled by the graph. This * class provides the iterator of a single list. */ struct TransInList { TransInList() : head(0) { } TransAp *head; struct Iter { /* Default construct. */ Iter() : ptr(0) { } /* Construct, assign from a list. */ Iter( const TransInList &il ) : ptr(il.head) { } Iter &operator=( const TransInList &dl ) { ptr = dl.head; return *this; } /* At the end */ bool lte() const { return ptr != 0; } bool end() const { return ptr == 0; } /* At the first, last element. */ bool first() const { return ptr && ptr->ilprev == 0; } bool last() const { return ptr && ptr->ilnext == 0; } /* Cast, dereference, arrow ops. */ operator TransAp*() const { return ptr; } TransAp &operator *() const { return *ptr; } TransAp *operator->() const { return ptr; } /* Increment, decrement. */ inline void operator++(int) { ptr = ptr->ilnext; } inline void operator--(int) { ptr = ptr->ilprev; } /* The iterator is simply a pointer. */ TransAp *ptr; }; }; typedef DList TransList; /* A element in a state dict. */ struct StateDictEl : public AvlTreeEl { StateDictEl(const StateSet &stateSet) : stateSet(stateSet) { } const StateSet &getKey() { return stateSet; } StateSet stateSet; StateAp *targState; }; /* Dictionary mapping a set of states to a target state. */ typedef AvlTree< StateDictEl, StateSet, CmpTable > StateDict; /* What items does a particular state encompass. */ typedef BstSet< long, CmpOrd > DotSet; typedef CmpTable< long, CmpOrd > CmpDotSet; /* Map of dot sets to states. */ typedef AvlTree< StateAp, DotSet, CmpDotSet > DotSetMap; typedef StateAp DotSetMapEl; typedef BstMap< long, TransAp* > TransMap; typedef BstMapEl< long, TransAp* > TransMapEl; /* State class that implements actions and priorities. */ struct StateAp : public ClosureQueueListEl, public AvlTreeEl< StateAp > { StateAp(); StateAp(const StateAp &other); ~StateAp(); /* Is the state final? */ bool isFinState() { return stateBits & SB_ISFINAL; } TransAp *findTrans( long key ) { TransMapEl *transMapEl = transMap.find( key ); if ( transMapEl == 0 ) return 0; return transMapEl->value; } /* In transition list. */ TransInList inRange; ProdIdPairSet pendingCommits; /* When duplicating the fsm we need to map each * state to the new state representing it. */ StateAp *stateMap; /* When merging states (state machine operations) this next pointer is * used for the list of states that need to be filled in. */ StateAp *alg_next; StateSet *stateSet; /* Identification for printing and stable minimization. */ int stateNum; /* A pointer to a dict element that contains the set of states this state * represents. This cannot go into alg, because alg.next is used during * the merging process. */ StateDictEl *stateDictEl; /* Bits controlling the behaviour of the state during collapsing to dfa. */ int stateBits; /* State list elements. */ StateAp *next, *prev; /* For dotset map. */ DotSet &getKey() { return dotSet; } /* Closure management. */ DotSet dotSet; DotSet dotSet2; bool onClosureQueue; bool inClosedMap; bool followMarked; bool onStateList; TransMap transMap; }; /* Compare lists of epsilon transitions. Entries are name ids of targets. */ typedef CmpTable< int, CmpOrd > CmpEpsilonTrans; /* Compare sets of context values. */ typedef CmpTable< int, CmpOrd > CmpContextSets; /* Graph class that implements actions and priorities. */ struct FsmAp { /* Constructors/Destructors. */ FsmAp(); FsmAp( const FsmAp &graph ); ~FsmAp(); /* The list of states. */ StateList stateList; StateList misfitList; /* The start state. */ StateAp *startState; /* The set of final states. */ StateSet finStateSet; /* Closure queues and maps. */ DotSetMap closedMap; StateClosureQueue stateClosureQueue; StateClosureQueue stateClosedList; TransClosureQueue transClosureQueue; StateAp *stateClosureHead; KlangEl **langElIndex; void setStartState( StateAp *state ); void unsetStartState( ); /* * Basic attaching and detaching. */ /* Common to attaching/detaching list and default. */ void attachToInList( StateAp *from, StateAp *to, TransAp *&head, TransAp *trans ); void detachFromInList( StateAp *from, StateAp *to, TransAp *&head, TransAp *trans ); /* Attach with a new transition. */ TransAp *attachNewTrans( StateAp *from, StateAp *to, long onChar1, long onChar2 ); /* Attach with an existing transition that already in an out list. */ void attachTrans( StateAp *from, StateAp *to, TransAp *trans ); /* Detach a transition from a target state. */ void detachTrans( StateAp *from, StateAp *to, TransAp *trans ); /* Detach a state from the graph. */ void detachState( StateAp *state ); /* * Callbacks. */ /* Add in the properties of srcTrans into this. */ void addInReduction( TransAp *dest, long prodId, long prior ); void addInTrans( TransAp *destTrans, TransAp *srcTrans ); void addInState( StateAp *destState, StateAp *srcState ); /* * Allocation. */ /* New up a state and add it to the graph. */ StateAp *addState(); /* * Fsm operators. */ /* Follow to the fin state of src fsm. */ StateAp *followFsm( StateAp *from, FsmAp *srcFsm ); /* * Final states */ /* Set and Unset a state as final. */ void setFinState( StateAp *state ); void unsetFinState( StateAp *state ); void unsetAllFinStates( ); /* Set State numbers starting at 0. */ void setStateNumbers(); /* * Path pruning */ /* Mark all states reachable from state. */ void markReachableFromHere( StateAp *state ); /* Removes states that cannot be reached by any path in the fsm and are * thus wasted silicon. */ void removeUnreachableStates(); /* Remove error actions from states on which the error transition will * never be taken. */ bool outListCovers( StateAp *state ); /* Remove states that are on the misfit list. */ void removeMisfits(); /* * Other */ /* Move the in trans into src into dest. */ void inTransMove(StateAp *dest, StateAp *src); int fsmLength( ); }; #endif /* _FSMGRAPH_H */ kelbt-0.16/src/gvdotgen.cpp0000664000175000017500000000543212471720203012576 00000000000000/* * Copyright 2001-2005 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "kelbt.h" #include "parsedata.h" using namespace std; void ParseData::writeTransList( StateAp *state ) { for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { /* Write out the from and to states. */ out << "\t" << state->stateNum << " -> " << trans->value->toState->stateNum; /* Begin the label. */ out << " [ label = \""; long key = trans->key; KlangEl *lel = langElIndex[key]; if ( lel != 0 ) out << lel->data; else out << (char)key; if ( trans->value->actions.length() > 0 ) { out << " / "; for ( ActDataList::Iter act = trans->value->actions; act.lte(); act++ ) { switch ( *act & 0x3 ) { case 1: out << "S(" << trans->value->actOrds[act.pos()] << ")"; break; case 2: { out << "R(" << prodIdIndex[(*act >> 2)]->data << ", " << trans->value->actOrds[act.pos()] << ")"; break; } case 3: { out << "SR(" << prodIdIndex[(*act >> 2)]->data << ", " << trans->value->actOrds[act.pos()] << ")"; break; }} if ( ! act.last() ) out << ", "; } } out << "\" ];\n"; } } void ParseData::writeDotFile( FsmAp *graph ) { out << "digraph " << parserName << " {\n" " rankdir=LR;\n" " ranksep=\"0\"\n" " nodesep=\"0.25\"\n" "\n"; /* Define the psuedo states. Transitions will be done after the states * have been defined as either final or not final. */ out << " node [ shape = point ];\n" " ENTRY [ label = \"\" ];\n" "\n" " node [ shape = circle, fixedsize = true, height = 0.2 ];\n"; /* Walk the states. */ for ( StateList::Iter st = graph->stateList; st.lte(); st++ ) out << " " << st->stateNum << " [ label = \"\" ];\n"; out << "\n"; /* Walk the states. */ for ( StateList::Iter st = graph->stateList; st.lte(); st++ ) writeTransList( st ); /* Transitions into the start state. */ out << " ENTRY -> " << graph->startState->stateNum << " [ label = \"\" ];\n"; out << "}\n"; } void ParseData::writeDotFile( ) { writeDotFile( graph ); } kelbt-0.16/src/codegen.cpp0000664000175000017500000007311312471720203012366 00000000000000/* * Copyright 2003-2012 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include "kelbt.h" #include "parsedata.h" #include "avlmap.h" #include "avlbasic.h" #include "avlset.h" #include "mergesort.h" using std::cerr; using std::endl; #define FRESH_BLOCK 8128 #define act_sb "0x1" #define act_rb "0x2" #define lower "0x0000ffff" #define upper "0xffff0000" void ParseData::startCodeGen() { if ( ! inhibitLineDirectives ) { /* Write the preprocessor line info for going to the output file. */ *outStream << "#line " << outFilter->line + 1 << " \"" << outputFile << "\"\n"; } } void ParseData::endCodeGen( int endLine ) { if ( ! inhibitLineDirectives ) { /* Write the preprocessor line info for to the input file. */ *outStream << "#line " << endLine << " \"" << fileName << "\"\n"; } } void ParseData::writeReferencePtr( InputLoc &loc, Definition *prod, char *data, int refNum ) { bool user = false, refThis = false; int rhsPos = -1; if ( data[0] == '$' ) user = true; if ( data[1] == '$' || data[1] == '@' ) refThis = true; else rhsPos = atoi(data+1); /* Get the language element. */ KlangEl *lel = refThis ? prod->prodName : prod->rhsLelVect[rhsPos-1]; if ( user ) { if ( lel == 0 || lel->type == KlangEl::Term ) { if ( tokenIsClass ) out << Token() << " *__ref" << refNum << " = (" << Token() << "*)"; else out << Token() << " *__ref" << refNum << " = (" << Token() << "*)&"; } else if ( lel != 0 && lel->type == KlangEl::NonTerm ) { if ( lel->typeDef != 0 && lel->typeDef->isClass ) out << Lel_() << lel->typeDef->data << " *__ref" << refNum << " = (" << Lel_() << lel->typeDef->data << "*)"; else out << Lel_() << lel->typeDef->data << " *__ref" << refNum << " = (" << Lel_() << lel->typeDef->data << "*)&"; } else { assert( false ); } } else { out << LangEl() << " *__ref" << refNum << " = (" << LangEl() << "*)"; } /* Write the access to the language element. */ if ( refThis ) out << "redLel"; else out << "rhs[" << (rhsPos-1) << "]"; if ( user ) { if ( lel == 0 || lel->type == KlangEl::Term ) { /* Terminal (maybe a lit). */ out << "->user.token"; } else if ( lel->type == KlangEl::NonTerm && lel->typeDef != 0 ) out << "->user." << lel->typeDef->data; else { error(loc) << "reference to " << data << " in code block " "does not have a user type" << endl; exit(1); } } out << ";\n"; } void ParseData::writeReference( InputLoc &loc, Definition *prod, char *data, int refNum ) { out << "(__ref" << refNum << ")"; } void ParseData::writeInlineBlock( Definition *prod, InlineBlock *block ) { int refNum = 0; for ( InlineList::Iter item = *block->inlineList; item.lte(); item++ ) { if ( item->type == InlineItem::Reference ) writeReferencePtr( item->loc, prod, item->data, refNum++ ); } if ( ! inhibitLineDirectives ) out << "#line " << block->loc.line << " \"" << fileName << "\"\n"; refNum = 0; for ( InlineList::Iter item = *block->inlineList; item.lte(); item++ ) { switch ( item->type ) { case InlineItem::Text: out << item->data; break; case InlineItem::Reference: writeReference( item->loc, prod, item->data, refNum++ ); break; } } if ( ! inhibitLineDirectives ) out << "\n\n#line " << outFilter->line + 1 << " \"" << outputFile << "\"\n"; } void ParseData::writeTokenIds() { out << "/*\n"; for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) { if ( lel->data != 0 ) out << " " << lel->data << " " << lel->id << endl; else out << " " << lel->id << endl; } out << "*/\n\n"; } /* Write the classes representing the non-terminal language elements. */ void ParseData::writeTypes() { for ( TypeDefMap::Iter td = typeDefMap; td.lte(); td++ ) { /* Start the class representing the non-terminal. */ out << "struct " << Lel_() << td->key << "\n" "{\n"; writeInlineBlock( 0, td->value->typeBlock ); /* Close the struct off. */ out << "};\n" "\n"; } out << "union " << UserData() << "\n" "{\n"; for ( TypeDefMap::Iter td = typeDefMap; td.lte(); td++ ) { if ( td->value->isClass ) out << " char " << td->key << "[sizeof(" << Lel_() << td->key << ")];\n"; else out << " struct " << Lel_() << td->key << " " << td->key << ";\n"; } if ( tokenIsClass ) out << " char token[sizeof(" << Token() << ")];\n"; else out << " struct " << Token() << " token;\n"; out << "};\n" "\n"; out << "struct " << LangEl() << "\n" "{\n" " char *file;\n" " int line;\n" " int type;\n" " int reduction;\n" /* Should be able to extract this from the FSM. */ " int state;\n" " int causeReduce;\n" " union " << UserData() << " user;\n"; if ( elementBlock != 0 ) writeInlineBlock( 0, elementBlock ); out << " unsigned int retry;\n" " struct " << LangEl() << " *next, *child, *prev;\n" "};\n" "\n"; out << "struct " << Block() << "\n" "{\n" " struct " << LangEl() << " data[" << FRESH_BLOCK << "];\n" " struct " << Block() << " *next;\n" "};\n" "\n"; } void ParseData::writeInstanceData() { out << " struct " << Block() << " *block;\n" " struct " << LangEl() << " *freshEl;\n" " int freshPos;\n" " struct " << LangEl() << " *pool;\n" " int numRetry;\n" " int numNodes;\n" " struct " << LangEl() << " *stackTop;\n" " struct " << LangEl() << " *lastFinal;\n" " int errCount;\n" " int curs;\n"; } void ParseData::writeTokenDefs() { for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) { if ( lel->isUserTerm || lel == eofKlangEl ) { /* Write out the token that will be generated by the scanner. */ out << "#define " << lel->data << " " << lel->id << "\n"; } } out << "\n"; } void ParseData::writeInit() { out << " " << curs() << " = " << startState() << ";\n" " " << pool() << " = 0;\n" " " << block() << " = (struct " << Block() << "*) " "malloc( sizeof(struct " << Block() << ") );\n" " " << block() << "->next = 0;\n" " " << freshEl() << " = " << block() << "->data;\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \"allocating " << FRESH_BLOCK << " LangEls\" << endl;\n" " #endif\n" " " << stackTop() << " = " << freshEl() << ";\n" " " << stackTop() << "->type = 0;\n" " " << stackTop() << "->state = -1;\n" " " << stackTop() << "->next = 0;\n" " " << stackTop() << "->child = 0;\n" " " << stackTop() << "->causeReduce = 0;\n" " " << freshPos() << " = 1;\n" " " << lastFinal() << " = " << stackTop() << ";\n" " " << numRetry() << " = 0;\n" " " << numNodes() << " = 0;\n" " " << errCount() << " = 0;\n"; } std::ostream &ParseData::UARRAY_TYPE( unsigned long long maxVal ) { ostream &out = *outStream; if ( maxVal <= UCHAR_MAX ) out << "unsigned char"; else if ( maxVal <= USHRT_MAX ) out << "unsigned short"; else if ( maxVal <= UINT_MAX ) out << "unsigned int"; else if ( maxVal <= ULONG_MAX ) out << "unsigned long"; else out << "unsigned long long"; return out; } std::ostream &ParseData::SARRAY_TYPE( signed long long maxVal ) { ostream &out = *outStream; if ( maxVal <= CHAR_MAX ) out << "char"; else if ( maxVal <= SHRT_MAX ) out << "short"; else if ( maxVal <= INT_MAX ) out << "int"; else if ( maxVal <= LONG_MAX ) out << "long"; else out << "long long"; return out; } void ParseData::writeData() { out << "unsigned int " << startState() << " = " << graph->startState->stateNum << ";\n\n"; SARRAY_TYPE(maxIndex) << " " << indicies() << "[] = {\n\t"; int totalItems = 0; for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { out << trans->value->actionSetEl->key.id; if ( !state.last() || !trans.last() ) { out << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } if ( ! trans.last() ) { TransMap::Iter next = trans.next(); for ( long key = trans->key+1; key < next->key; key++ ) { out << "-1, "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } } } } out << "\n};\n\n"; UARRAY_TYPE(maxLelId) << " " << keys() << "[] = {\n\t"; totalItems = 0; for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { if ( state->transMap.length() == 0 ) { out << "0, 0"; if ( !state.last() ) { out << ", "; totalItems += 2; if ( totalItems % 8 == 0 ) out << "\n\t"; } } else { TransMap::Iter first = state->transMap.first(); TransMap::Iter last = state->transMap.last(); out << first->key << ", " << last->key; if ( !state.last() ) { out << ", "; totalItems += 2; if ( totalItems % 8 == 0 ) out << "\n\t"; } } } out << "\n};\n\n"; UARRAY_TYPE(maxOffset) << " " << offsets() << "[] = {\n\t"; totalItems = 0; int curOffset = 0; for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { out << curOffset; if ( !state.last() ) { out << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } /* Increment the offset. */ if ( state->transMap.length() > 0 ) { TransMap::Iter first = state->transMap.first(); TransMap::Iter last = state->transMap.last(); curOffset += last->key - first->key + 1; } } out << "\n};\n\n"; UARRAY_TYPE(maxState) << " " << targs() << "[] = {\n\t"; totalItems = 0; for ( ActionSet::Iter asi = actionSet; asi.lte(); asi++ ) { out << asi->key.targ; if ( ! asi.last() ) { out << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } } out << "\n};\n\n"; out << "unsigned int " << actInds() << "[] = {\n\t"; totalItems = 0; int pos = 0; for ( ActionSet::Iter asi = actionSet; asi.lte(); asi++ ) { out << pos; if ( ! asi.last() ) { out << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } pos += asi->key.actions.length() + 1; } out << "\n};\n\n"; out << "unsigned int " << actions() << "[] = {\n\t"; totalItems = 0; for ( ActionSet::Iter asi = actionSet; asi.lte(); asi++ ) { for ( ActDataList::Iter ali = asi->key.actions; ali.lte(); ali++ ) { out << *ali << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } out << "0"; if ( ! asi.last() ) { out << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } } out << "\n};\n\n"; out << "int " << commitLen() << "[] = {\n\t"; totalItems = 0; for ( ActionSet::Iter asi = actionSet; asi.lte(); asi++ ) { out << asi->key.commitLen; if ( ! asi.last() ) { out << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } } out << "\n};\n\n"; SARRAY_TYPE(maxProdLen) << " " << prodLengths() << "[] = {\n\t"; totalItems = 0; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { int numFin = prod->fsm->finStateSet.length(); assert( numFin == 1 ); for ( int i = 0; i < numFin; i++ ) { out << prod->fsmLength; if ( !prod.last() || i < (numFin-1) ) { out << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } } } out << "\n};\n\n"; UARRAY_TYPE(maxLelId) << " " << prodLhsIds() << "[] = {\n\t"; totalItems = 0; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { out << prod->prodName->id; if ( ! prod.last() ) { out << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } } out << "\n};\n\n"; out << "const char *" << prodNames() << "[] = {\n"; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { out << "\t\"" << prod->data << "\""; if ( ! prod.last() ) out << ","; out << "\n"; } out << "};\n\n"; out << "const char *" << lelNames() << "[] = {\n"; for ( int i = 0; i < nextSymbolId; i++ ) { KlangEl *lel = langElIndex[i]; if ( lel != 0 ) out << "\t\"" << lel->data << "\""; else { out << "\t\""; if ( 33 <= i && i <= 126 ) { if ( i == '"' || i == '\\' ) out << "\\"; out << (char)i; } else out << "D-" << i; out << "\""; } if ( i < nextSymbolId-1 ) out << ","; out << "\n"; } out << "};\n\n"; #if 0 out << "char prodCommit[] = {\n\t"; totalItems = 0; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { out << ( prod->prodCommit ? '1' : '0' ); if ( ! prod.last() ) { out << ", "; if ( ++totalItems % 8 == 0 ) out << "\n\t"; } } out << "\n};\n\n"; #endif } void ParseData::writeReduceBlocks() { bool generate = false; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { TypeDef *typeDef = prod->prodName->typeDef; bool doConstruct = typeDef != 0 && typeDef->isClass; if ( doConstruct || prod->redBlock != 0 ) { generate = true; break; } } if ( generate ) { out << "switch ( reduction ) {\n"; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { TypeDef *typeDef = prod->prodName->typeDef; bool doConstruct = typeDef != 0 && typeDef->isClass; /* If there is reduction code, embed it here. */ if ( doConstruct || prod->redBlock != 0 ) { out << "case " << prod->prodId << ": {\n"; if ( doConstruct ) { out << " new(redLel->user." << typeDef->data << ") " << Lel_() << typeDef->data << "();\n"; } if ( prod->redBlock != 0 ) writeInlineBlock( prod, prod->redBlock ); out << "} break;\n"; } } out << "}\n"; } } void ParseData::writeUndoBlocks() { bool generate = false; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { TypeDef *typeDef = prod->prodName->typeDef; bool doDestruct = typeDef != 0 && typeDef->isClass; if ( doDestruct || prod->undoBlock != 0 ) { generate = true; break; } } if ( generate ) { out << "switch ( redLel->reduction ) {\n"; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { TypeDef *typeDef = prod->prodName->typeDef; bool doDestruct = typeDef != 0 && typeDef->isClass; /* If there is reduction code, embed it here. */ if ( doDestruct || prod->undoBlock != 0 ) { out << "case " << prod->prodId << ": {\n"; if ( prod->undoBlock != 0 ) writeInlineBlock( prod, prod->undoBlock ); if ( doDestruct ) { out << Lel_() << typeDef->data << " *dlel = " "((" << Lel_() << typeDef->data << "*)" "redLel->user." << typeDef->data << ");\n"; out << "dlel->~" << Lel_() << typeDef->data << "();\n"; } out << "} break;\n"; } } out << "}\n"; } } void ParseData::writeFinalBlocks() { bool generate = false; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { if ( prod->finalBlock != 0 ) { generate = true; break; } } if ( generate ) { out << "switch ( lel->reduction ) {\n"; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { /* If there is reduction code, embed it here. */ if ( prod->finalBlock != 0 ) { out << "case " << prod->prodId << ": {\n"; if ( prod->finalBlock != 0 ) writeInlineBlock( prod, prod->finalBlock ); out << "} break;\n"; } } out << "}\n"; } } void ParseData::writeNonTermDestructors() { bool generate = false; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { TypeDef *typeDef = prod->prodName->typeDef; bool doDestruct = typeDef != 0 && typeDef->isClass; if ( doDestruct ) { generate = true; break; } } if ( generate ) { out << "switch ( child->reduction ) {\n"; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { TypeDef *typeDef = prod->prodName->typeDef; bool doDestruct = typeDef != 0 && typeDef->isClass; /* If there is reduction code, embed it here. */ if ( doDestruct ) { out << "case " << prod->prodId << ": {\n"; out << Lel_() << typeDef->data << " *dlel = ((" << Lel_() << typeDef->data << "*)" "child->user." << typeDef->data << ");\n"; out << "dlel->~" << Lel_() << typeDef->data << "();\n"; out << "} break;\n"; } } out << "}\n"; } } void ParseData::writeFinishBlocks() { bool generate = false; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { TypeDef *typeDef = prod->prodName->typeDef; bool doDestruct = typeDef != 0 && typeDef->isClass; if ( doDestruct ) { generate = true; break; } } if ( generate ) { out << "switch ( lel->reduction ) {\n"; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { TypeDef *typeDef = prod->prodName->typeDef; bool doDestruct = typeDef != 0 && typeDef->isClass; /* If there is reduction code, embed it here. */ if ( doDestruct ) { out << "case " << prod->prodId << ": {\n"; out << Lel_() << typeDef->data << " *dlel =" "((" << Lel_() << typeDef->data << "*)\n"; out << "dlel->~" << Lel_() << typeDef->data << "();\n"; out << "} break;\n"; } } out << "}\n"; } } ostream &ParseData::ALLOCATE_EL( const char *name ) { out << " if ( " << pool() << " == 0 ) {\n" " if ( " << freshPos() << " == " << FRESH_BLOCK << " ) {\n" " struct " << Block() << "* newBlock = (struct " << Block() << "*) " "malloc( sizeof(struct " << Block() << ") );\n" " newBlock->next = " << block() << ";\n" " " << block() << " = newBlock;\n" " " << freshEl() << " = newBlock->data;\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \"allocating " << FRESH_BLOCK << " LangEls\" << endl;\n" " #endif\n" " " << freshPos() << " = 0;\n" " }\n" " " << name << " = " << freshEl() << " + " << freshPos() << "++;\n" " }\n" " else {\n" " " << name << " = " << pool() << ";\n" " " << pool() << " = " << pool() << "->next;\n" " }\n" " " << numNodes() << " += 1;\n"; return out; } void ParseData::writeExec() { out << "#define reject() induceReject = 1\n" "\n" " int pos, targState;\n" " unsigned int *action;\n" " int rhsLen;\n" " struct " << LangEl() << " *rhs[32];\n" " struct " << LangEl() << " *lel = 0;\n" " struct " << LangEl() << " *input = 0;\n" " struct " << LangEl() << " *queue = 0;\n" " char induceReject;\n" "\n" " if ( " << curs() << " < 0 )\n" " return 0;\n" "\n"; ALLOCATE_EL( "queue" ) << "\n" " queue->type = type;\n"; if ( tokenIsClass ) out << " new(queue->user.token) " << Token() << "(*token);\n"; else out << " queue->user.token = *token;\n"; out << " queue->next = 0;\n" " queue->retry = 0;\n" " queue->child = 0;\n" " queue->causeReduce = 0;\n" "\n" "again:\n" " if ( input == 0 ) {\n" " if ( queue == 0 )\n" " goto _out;\n" "\n" " input = queue;\n" " queue = queue->next;\n" " input->next = 0;\n"; if ( translateBlock != 0 ) writeInlineBlock( 0, translateBlock ); out << " }\n" "\n"; out << " lel = input;\n" " if ( lel->type < " << keys() << "[" << curs() << "<<1] || lel->type > " << keys() << "[(" << curs() << "<<1)+1] )\n" " goto parseError;\n" "\n" " pos = " << indicies() << "[" << offsets() << "[" << curs() << "] + (lel->type - " << keys() << "[" << curs() << "<<1])];\n" " if ( pos < 0 )\n" " goto parseError;\n" "\n" " induceReject = 0;\n" " targState = " << targs() << "[pos];\n" " action = " << actions() << " + " << actInds() << "[pos];\n" " if ( lel->retry & " << lower << " )\n" " action += (lel->retry & " << lower << ");\n" "\n" " if ( *action & " << act_sb << " ) {\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \"shifted: \" << " << lelNames() << "[lel->type];\n" " #endif\n" " input = input->next;\n" " lel->state = " << curs() << ";\n" " lel->next = " << stackTop() << ";\n" " " << stackTop() << " = lel;\n" "\n" " if ( action[1] == 0 )\n" " lel->retry &= " << upper << ";\n" " else {\n" " lel->retry += 1;\n" " " << numRetry() << " += 1;\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \" retry: \" << " << stackTop() << ";\n" " #endif\n" " }\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << endl;\n" " #endif\n" " }\n" "\n" " if ( " << commitLen() << "[pos] != 0 ) {\n" " struct " << LangEl() << " *commitHead = " << stackTop() << ", *lel;\n" " int sp = 0, doExec = 0;\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \"commit encountered, executing final actions\" << endl;\n" " #endif\n" " if ( " << commitLen() << "[pos] < 0 )\n" " commitHead = commitHead->next;\n" "\n" " lel = commitHead;\n" "\n" "commit_head:\n" " if ( lel == " << lastFinal() << " ) {\n" " doExec = 1;\n" " goto commit_base;\n" " }\n" "\n" " if ( lel->next != 0 ) {\n" " sp += 1;\n" " lel->next->prev = lel;\n" " lel = lel->next;\n" " lel->retry = 0;\n" " goto commit_head;\n" " }\n" "\n" "commit_reverse:\n" "\n" " if ( lel->child != 0 ) {\n" " sp += 1;\n" " lel->child->prev = lel;\n" " lel = lel->child;\n" " lel->retry = 1;\n" " goto commit_head;\n" " }\n" "\n" "commit_upwards:\n" "\n" " if ( doExec ) {\n" " if ( lel->type < " << firstNonTermId << " ) {\n"; if ( tokenFinalBlock != 0 ) writeInlineBlock( 0, tokenFinalBlock ); out << " }\n" " else {\n" " struct " << LangEl() << " *redLel = lel;\n" " if ( redLel->child != 0 ) {\n" " int r = " << prodLengths() << "[redLel->reduction] - 1;\n" " struct " << LangEl() << " *rhsEl = redLel->child;\n" " while ( rhsEl != 0 ) {\n" " rhs[r--] = rhsEl;\n" " rhsEl = rhsEl->next;\n" " }\n" " }\n"; writeFinalBlocks(); out << " }\n" "\n" " if ( lel->child != 0 ) {\n" " struct " << LangEl() << " *first = lel->child;\n" " struct " << LangEl() << " *child = lel->child;\n" " lel->child = 0;\n" " while ( 1 ) {\n" " if ( child->type < " << firstNonTermId << " ) {\n"; if ( tokenIsClass ) { out << Token() << " *dlel = ((" << Token() << "*)child->user.token);\n"; out << "dlel->~" << Token() << "();\n"; } out << " }\n" " else {\n"; writeNonTermDestructors(); out << " }\n" " " << numNodes() << " -= 1;\n" " if ( child->next == 0 )\n" " break;\n" " child = child->next;\n" " }\n" " child->next = " << pool() << ";\n" " " << pool() << " = first;\n" " }\n" " }\n" "\n" "commit_base:\n" " if ( sp > 0 ) {\n" " sp -= 1;\n" " if ( lel->retry == 0 ) {\n" " lel = lel->prev;\n" " goto commit_reverse;\n" " }\n" " else {\n" " lel->retry = 0;\n" " lel = lel->prev;\n" " goto commit_upwards;\n" " }\n" " }\n" " lel->retry = 0;\n" "\n" " " << lastFinal() << " = lel;\n" " " << numRetry() << " = 0;\n" " }\n" "\n" " if ( *action & " << act_rb << " ) {\n" " int reduction = *action >> 2;\n" " struct " << LangEl() << " *redLel;\n" "\n" " if ( input != 0 )\n" " input->causeReduce += 1;\n" "\n"; ALLOCATE_EL("redLel") << "\n" " redLel->type = " << prodLhsIds() << "[reduction];\n" " redLel->reduction = reduction;\n" " redLel->child = 0;\n" " redLel->next = 0;\n" " redLel->retry = (lel->retry << 16);\n" " redLel->causeReduce = 0;\n" " lel->retry &= " << upper << ";\n" "\n" " rhsLen = " << prodLengths() << "[reduction];\n" " if ( rhsLen > 0 ) {\n" " int r;\n" " for ( r = rhsLen-1; r > 0; r-- ) {\n" " rhs[r] = " << stackTop() << ";\n" " " << stackTop() << " = " << stackTop() << "->next;\n" " }\n" " rhs[0] = " << stackTop() << ";\n" " " << stackTop() << " = " << stackTop() << "->next;\n" " rhs[0]->next = 0;\n" " }\n"; writeReduceBlocks(); out << " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \"reduced: \"\n" " << " << prodNames() << "[reduction]\n" " << \" rhsLen: \" << rhsLen;\n" " #endif\n" " if ( action[1] == 0 )\n" " redLel->retry = 0;\n" " else {\n" " redLel->retry += 0x10000;\n" " " << numRetry() << " += 1;\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \" retry: \" << redLel;\n" " #endif\n" " }\n" "\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << endl;\n" " #endif\n" "\n" " if ( rhsLen == 0 ) {\n" " redLel->file = lel->file;\n" " redLel->line = lel->line;\n" " targState = " << curs() << ";\n" " }\n" " else {\n" " redLel->child = rhs[rhsLen-1];\n" " redLel->file = rhs[0]->file;\n" " redLel->line = rhs[0]->line;\n" " targState = rhs[0]->state;\n" " }\n" "\n" " if ( induceReject ) {\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \"error induced during reduction of \" <<\n" " " << lelNames() << "[redLel->type] << endl;\n" " #endif\n" " redLel->state = " << curs() << ";\n" " redLel->next = " << stackTop() << ";\n" " " << stackTop() << " = redLel;\n" " " << curs() << " = targState;\n" " goto parseError;\n" " }\n" " else {\n" " redLel->next = input;\n" " input = redLel;\n" " }\n" " }\n" "\n" "\n" " " << curs() << " = targState;\n" " goto again;\n" "\n" "parseError:\n" " #ifdef KELBT_LOG_BACKTRACK\n" " cerr << \"hit error\" << endl;\n" " #endif\n"; out << " if ( " << numRetry() << " > 0 ) {\n" " struct " << LangEl() << " *redLel;\n" "\n" " if ( input != 0 ) {\n" " redLel = input;\n" " goto have_undo_element;\n" " }\n" "\n" " while ( 1 ) {\n" " redLel = " << stackTop() << ";\n" " if ( " << stackTop() << "->type < " << firstNonTermId << " ) {\n" " #ifdef KELBT_LOG_BACKTRACK\n" " cerr << \"backing up over terminal: \" <<\n" " " << lelNames() << "[" << stackTop() << "->type] << endl;\n" " #endif\n" " " << stackTop() << " = " << stackTop() << "->next;\n" " redLel->next = input;\n" " input = redLel;\n" " }\n" " else {\n" " #ifdef KELBT_LOG_BACKTRACK\n" " cerr << \"backing up over non-terminal: \" <<\n" " " << lelNames() << "[" << stackTop() << "->type] << endl;\n" " #endif\n" " " << stackTop() << " = " << stackTop() << "->next;\n" " struct " << LangEl() << " *first = redLel->child;\n" " if ( first == 0 )\n" " rhsLen = 0;\n" " else {\n" " rhsLen = 1;\n" " while ( first->next != 0 ) {\n" " first = first->next;\n" " rhsLen += 1;\n" " }\n" " first->next = " << stackTop() << ";\n" " " << stackTop() << " = redLel->child;\n" "\n" " struct " << LangEl() << " *rhsEl = " << stackTop() << ";\n" " int p = rhsLen;\n" " while ( p > 0 ) {\n" " rhs[--p] = rhsEl;\n" " rhsEl = rhsEl->next;\n" " }\n" " }\n"; writeUndoBlocks(); out << " redLel->next = " << pool() << ";\n" " " << pool() << " = redLel;\n" " " << numNodes() << " -= 1;\n" "\n" " if ( input != 0 )\n" " input->causeReduce -= 1;\n" " }\n" "\n" "have_undo_element:\n" " if ( redLel->retry == 0 ) {\n" " if ( input != 0 && input->causeReduce == 0 ) {\n" " #ifdef KELBT_LOG_BACKTRACK\n" " cerr << \"pushing back: \" << " << lelNames() << "[input->type] << endl;\n" " #endif\n"; if ( undoTransBlock != 0 ) writeInlineBlock( 0, undoTransBlock ); out << " input->next = queue;\n" " queue = input;\n" " input = 0;\n" " }\n" " }\n" " else {\n" " #ifdef KELBT_LOG_BACKTRACK\n" " cerr << \"found retry targ: \" << redLel << endl;\n" " #endif\n" " " << numRetry() << " -= 1;\n" " #ifdef KELBT_LOG_BACKTRACK\n" " cerr << \"found retry: \" << redLel << endl;\n" " #endif\n" " if ( redLel->retry & " << lower << " )\n" " " << curs() << " = input->state;\n" " else {\n" " input->retry = redLel->retry >> 16;\n" " if ( " << stackTop() << "->state < 0 )\n" " " << curs() << " = " << startState() << ";\n" " else {\n" " " << curs() << " = " << targs() << "[(int)" << indicies() << "[" << offsets() << "[" << stackTop() << "->state] + (" << stackTop() << "->type - " << keys() << "[" << stackTop() << "->state<<1])]];\n" " }\n" " }\n" " goto again;\n" " }\n" " }\n" " }\n" " " << curs() << " = -1;\n" " " << errCount() << " += 1;\n" "_out: {}\n"; } void ParseData::writeFinish() { /* Clean up the stack and free memory. */ out << " struct " << Block() << " *todel = 0;\n" " struct " << LangEl() << " *lel = " << stackTop() << ";\n" " int sp = 0;\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \"cleaning up stack\" << endl;\n" " #endif\n" "\n" "clean_head:\n" " if ( lel->next != 0 ) {\n" " sp += 1;\n" " lel->next->prev = lel;\n" " lel = lel->next;\n" " lel->retry = 0;\n" " goto clean_head;\n" " }\n" "\n" "clean_reverse:\n" " if ( lel->child != 0 ) {\n" " sp += 1;\n" " lel->child->prev = lel;\n" " lel = lel->child;\n" " lel->retry = 1;\n" " goto clean_head;\n" " }\n" "\n" "clean_upwards:\n" " if ( lel->state != -1 ) {\n" " if ( lel->type < " << firstNonTermId << " ) {\n"; if ( tokenIsClass ) { out << Token() << " *dlel = ((" << Token() << "*)lel->user.token);\n"; out << "dlel->~" << Token() << "();\n"; } out << " }\n" " else {\n"; writeFinishBlocks(); out << " }\n" " #ifdef KELBT_LOG_ACTIONS\n" " cerr << \"deleted: \" << " << lelNames() << "[lel->type] << endl;\n" " #endif\n" " }\n" " if ( sp > 0 ) {\n" " sp -= 1;\n" " if ( lel->retry == 0 ) {\n" " lel = lel->prev;\n" " goto clean_reverse;\n" " }\n" " else {\n" " lel = lel->prev;\n" " goto clean_upwards;\n" " }\n" " }\n" "\n"; /* Now clean up the allocated blocks. */ out << " while ( " << block() << " != 0 ) {\n" " todel = " << block() << ";\n" " " << block() << " = " << block() << "->next;\n" " free( todel );\n" " }\n"; } kelbt-0.16/src/pcheck.cpp0000664000175000017500000000723112471720203012215 00000000000000/* * Copyright 2001, 2002, 2005 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "pcheck.h" /* Construct a new parameter checker with for paramSpec. */ ParamCheck::ParamCheck( const char *paramSpec, int argc, const char **argv ) : state(noparam), argOffset(0), curArg(0), iCurArg(1), paramSpec(paramSpec), argc(argc), argv(argv) { } /* Check a single option. Returns the index of the next parameter. Sets p to * the arg character if valid, 0 otherwise. Sets parg to the parameter arg if * there is one, NULL otherwise. */ bool ParamCheck::check() { bool requiresParam; if ( iCurArg >= argc ) { /* Off the end of the arg list. */ state = noparam; return false; } if ( argOffset != 0 && *argOffset == 0 ) { /* We are at the end of an arg string. */ iCurArg += 1; if ( iCurArg >= argc ) { state = noparam; return false; } argOffset = 0; } if ( argOffset == 0 ) { /* Set the current arg. */ curArg = argv[iCurArg]; /* We are at the beginning of an arg string. */ if ( argv[iCurArg] == 0 || /* Argv[iCurArg] is null. */ argv[iCurArg][0] != '-' || /* Not a param. */ argv[iCurArg][1] == 0 ) { /* Only a dash. */ parameter = 0; paramArg = 0; iCurArg += 1; state = noparam; return true; } argOffset = argv[iCurArg] + 1; } /* Get the arg char. */ char argChar = *argOffset; /* Loop over all the parms and look for a match. */ const char *pSpec = paramSpec; while ( *pSpec != 0 ) { char pSpecChar = *pSpec; /* If there is a ':' following the char then * it requires a parm. If a parm is required * then move ahead two in the parmspec. Otherwise * move ahead one in the parm spec. */ if ( pSpec[1] == ':' ) { requiresParam = true; pSpec += 2; } else { requiresParam = false; pSpec += 1; } /* Do we have a match. */ if ( argChar == pSpecChar ) { if ( requiresParam ) { if ( argOffset[1] == 0 ) { /* The param must follow. */ if ( iCurArg + 1 == argc ) { /* We are the last arg so there * cannot be a parameter to it. */ parameter = argChar; paramArg = 0; iCurArg += 1; argOffset = 0; state = invalid; return true; } else { /* the parameter to the arg is the next arg. */ parameter = pSpecChar; paramArg = argv[iCurArg + 1]; iCurArg += 2; argOffset = 0; state = match; return true; } } else { /* The param for the arg is built in. */ parameter = pSpecChar; paramArg = argOffset + 1; iCurArg += 1; argOffset = 0; state = match; return true; } } else { /* Good, we matched the parm and no * arg is required. */ parameter = pSpecChar; paramArg = 0; argOffset += 1; state = match; return true; } } } /* We did not find a match. Bad Argument. */ parameter = argChar; paramArg = 0; argOffset += 1; state = invalid; return true; } kelbt-0.16/src/Makefile.am0000664000175000017500000000303712472121476012320 00000000000000# # Copyright 2001-2015 Adrian Thurston # # This file is part of Kelbt # # Kelbt 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. # # Kelbt 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 Kelbt; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA RAGEL = @RAGEL@ KELBT = @KELBT@ bin_PROGRAMS = kelbt kelbt_SOURCES = \ pcheck.cpp main.cpp parsedata.cpp \ closure.cpp fsmbase.cpp fsmattach.cpp \ fsmgraph.cpp codegen.cpp gvdotgen.cpp \ klscan.cpp klparse.cpp \ buffer.h fsmgraph.h klparse.h pcheck.h \ kelbt.h parsedata.h version.h kelbt_CPPFLAGS = -I$(top_srcdir)/aapl BUILT_SOURCES = \ version.h klparse.cpp klparse.h klscan.cpp EXTRA_DIST = klscan.rl klparse.kh klparse.kl # GEN_BEGIN if BUILD_PARSERS klscan.cpp: klscan.rl klparse.h $(RAGEL) -G2 -o $@ $< klparse.h: klparse.kh $(KELBT) -o $@ $< klparse.cpp: klparse.kl klparse.kh $(KELBT) -o $@ $< endif version.h: Makefile echo '#define VERSION "$(VERSION)"' > version.h echo '#define PUBDATE "$(PUBDATE)"' >> version.h # GEN_END kelbt-0.16/src/fsmgraph.cpp0000664000175000017500000001153012471720203012564 00000000000000/* * Copyright 2001, 2002, 2005 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include using std::cerr; using std::endl; #include "fsmgraph.h" #include "mergesort.h" void FsmAp::addInReduction( TransAp *dest, long prodId, long prior ) { /* Look for the reduction. If not there insert it, otherwise take * the max of the priorities. */ ReductionMapEl *redMapEl = dest->reductions.find( prodId ); if ( redMapEl == 0 ) dest->reductions.insert( prodId, prior ); else if ( prior > redMapEl->value ) redMapEl->value = prior; } /* Callback invoked when another trans (or possibly this) is added into this * transition during the merging process. Draw in any properties of srcTrans * into this transition. AddInTrans is called when a new transitions is made * that will be a duplicate of another transition or a combination of several * other transitions. AddInTrans will be called for each transition that the * new transition is to represent. */ void FsmAp::addInTrans( TransAp *destTrans, TransAp *srcTrans ) { /* Protect against adding in from ourselves. */ if ( srcTrans != destTrans ) { /* Add in the shift priority. */ if ( destTrans->isShift && srcTrans->isShift ) { /* Both shifts are set. We want the max of the two. */ if ( srcTrans->shiftPrior > destTrans->shiftPrior ) destTrans->shiftPrior = srcTrans->shiftPrior; } else if ( srcTrans->isShift ) { /* Just the source is set, copy the source prior over. */ destTrans->shiftPrior = srcTrans->shiftPrior; } /* If either is a shift, dest is a shift. */ destTrans->isShift = destTrans->isShift || srcTrans->isShift; /* Add in the reductions. */ for ( ReductionMap::Iter red = srcTrans->reductions; red.lte(); red++ ) addInReduction( destTrans, red->key, red->value ); /* Add in the commit points. */ destTrans->commits.insert( srcTrans->commits ); } } void FsmAp::addInState( StateAp *destState, StateAp *srcState ) { /* Draw in any properties of srcState into destState. */ if ( srcState != destState ) { /* Get the epsilons, context, out priorities. */ destState->pendingCommits.insert( srcState->pendingCommits ); if ( srcState->pendingCommits.length() > 0 ) cerr << "THERE ARE PENDING COMMITS DRAWN IN" << endl; /* Parser generation data. */ destState->dotSet.insert( srcState->dotSet ); if ( srcState->onClosureQueue && !destState->onClosureQueue ) { stateClosureQueue.append( destState ); destState->onClosureQueue = true; } } } /* Make a new state. The new state will be put on the graph's * list of state. The new state can be created final or non final. */ StateAp *FsmAp::addState() { /* Make the new state to return. */ StateAp *state = new StateAp(); /* Create the new state. */ stateList.append( state ); return state; } /* Follow from to the final state of srcFsm. */ StateAp *FsmAp::followFsm( StateAp *from, FsmAp *srcFsm ) { StateAp *followSrc = srcFsm->startState; while ( ! followSrc->isFinState() ) { assert( followSrc->transMap.length() == 1 ); TransAp *followTrans = followSrc->transMap[0].value; TransAp *inTrans = from->findTrans( followTrans->lowKey ); assert( inTrans != 0 ); from = inTrans->toState; followSrc = followTrans->toState; } return from; } int FsmAp::fsmLength( ) { int length = 0; StateAp *state = startState; while ( ! state->isFinState() ) { length += 1; state = state->transMap[0].value->toState; } return length; } /* Remove states that have no path to them from the start state. Recursively * traverses the graph marking states that have paths into them. Then removes * all states that did not get marked. */ void FsmAp::removeUnreachableStates() { /* Mark all the states that can be reached * through the existing set of entry points. */ markReachableFromHere( startState ); /* Delete all states that are not marked * and unmark the ones that are marked. */ StateAp *state = stateList.head; while ( state ) { StateAp *next = state->next; if ( state->stateBits & SB_ISMARKED ) state->stateBits &= ~ SB_ISMARKED; else { detachState( state ); stateList.detach( state ); delete state; } state = next; } } kelbt-0.16/src/parsedata.cpp0000664000175000017500000010065712471720203012732 00000000000000/* * Copyright 2001-2007 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include /* Parsing. */ #include "kelbt.h" #include "parsedata.h" /* Dumping the fsm. */ #include "mergesort.h" using namespace std; char startDefName[] = "start"; void ParseData::printDotSet( ostream &out, long dotItem ) { long pos = 0, base = dotItem; DotItemIndexEl *iel; for (;;) { iel = dotItemIndex.find( base ); if ( iel != 0 ) break; base -= 1; } out << " " << iel->value->data << ":"; for ( ProdElList::Iter pli = *iel->value->prodElList; pli.lte(); pli++, pos++ ) { if ( pos == dotItem - base ) out << " ."; if ( pli->type == Factor::LiteralType ) out << " '" << (char)pli->literal->value << "'"; else out << " " << pli->langEl->data; } if ( pos == dotItem - base ) out << " ."; out << endl; } /* Count the transitions in the fsm by walking the state list. */ int countTransitions( FsmAp *fsm ) { int numTrans = 0; StateAp *state = fsm->stateList.head; while ( state != 0 ) { numTrans += state->transMap.length(); state = state->next; } return numTrans; } KlangEl::KlangEl( char *data, Type type ) : type(type), id(-1), isUserTerm(false), isContext(false), typeDef(0), displayString(0), numAppearances(0), isShortest(false) { /* If there is a data, take a copy. */ this->data = strdup(data); } /* Return a string that describes what the lang el is. * literal-term, term, regular, non-term */ const char *KlangEl::typeString() { switch ( type ) { case Term: return "term"; case NonTerm: return "non-term"; default: return 0; } } FsmAp *ProdElList::walk( ParseData *pd ) { FsmAp *prodFsm = new FsmAp(); StateAp *last = prodFsm->addState(); prodFsm->setStartState( last ); int prodLength = 0; for ( Iter prodEl = first(); prodEl.lte(); prodEl++, prodLength++ ) { //FsmAp *itemFsm = prodEl->walk( pd ); long value = 0; if ( prodEl->type == Factor::LiteralType ) value = prodEl->literal->value; else if ( Factor::ReferenceType ) value = prodEl->langEl->id; StateAp *newState = prodFsm->addState(); TransAp *newTrans = prodFsm->attachNewTrans( last, newState, value, value ); newTrans->isShift = true; newTrans->shiftPrior = prodEl->priorVal; //cerr << "PRIOR VAL: " << newTrans->shiftPrior << endl; if ( prodEl->commit ) { //cout << "COMMIT: inserting commit of length: " << pd->prodLength << endl; /* Insert the commit into transitions out of last */ for ( TransMap::Iter trans = last->transMap; trans.lte(); trans++ ) trans->value->commits.insert( prodLength ); } last = newState; } /* Make the last state the final state. */ prodFsm->setFinState( last ); return prodFsm; } /* * ParseData */ /* Initialize the structure that will collect info during the parse of a * machine. */ ParseData::ParseData( const char *fileName, char *parserName, ostream &out ) : /* 0 is reserved for global error actions. */ fileName(fileName), parserName(parserName), out(out), access(0), tokenStruct(0), startKlangEl(0), eofKlangEl(0), errorKlangEl(0), userStartKlangEl(0), startDef(0), nextSymbolId(0), firstNonTermId(0), elementBlock(0), tokenBlock(0), preReduceBlock(0), postReduceBlock(0), translateBlock(0), undoTransBlock(0), tokenFinalBlock(0), prodIdIndex(0), didTokens(false), didGraph(false), tokenIsClass(false) {} KlangEl *getKlangEl( ParseData *pd, char *data, KlangEl::Type defType ) { /* If the id is already in the dict, it will be placed in last found. If * it is not there then it will be inserted and last found will be set to it. */ SymbolMapEl *inDict = pd->symbolMap.find( data ); if ( inDict == 0 ) { /* Language element not there. Make the new lang el and insert.. */ KlangEl *langEl = new KlangEl( data, defType ); inDict = pd->symbolMap.insert( langEl->data, langEl ); pd->langEls.append( langEl ); } return inDict->value; } ProdElList *makeProdElList( char *name, KlangEl *langEl ) { ProdElList *prodElList = new ProdElList(); prodElList->append( new Factor( InputLoc(), false, langEl, 0 ) ); return prodElList; } void ParseData::makeDefinitionNames() { for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) { int prodNum = 1; for ( LelDefList::Iter def = lel->defList; def.lte(); def++ ) { def->data = new char[strlen(lel->data) + 30]; sprintf( def->data, "%s-%i", lel->data, prodNum++ ); } } } /* Make sure there there are no language elements whose type is unkonwn. This * can happen when an id is used on the rhs of a definition but is not defined * as anything. */ void ParseData::noUndefinedKlangEls() { for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) { if ( lel->type == KlangEl::Unknown ) error() << "'" << lel->data << "' was not defined as anything" << endl; } } void ParseData::noUndefinedUses() { for ( TypeDefMap::Iter tmel = typeDefMap; tmel.lte(); tmel++ ) { if ( tmel->value->typeBlock == 0 ) error() << "'" << tmel->value->data << "' is an undefined type" << endl; } } void ParseData::makeTokens( ) { if ( didTokens ) return; didTokens = true; /* Make an EOF language element. */ char *eofName = new char[strlen(parserName) + 16]; sprintf( eofName, "%s_tk_eof", parserName ); eofKlangEl = new KlangEl( eofName, KlangEl::Term ); langEls.append( eofKlangEl ); SymbolMapEl *eofMapEl = symbolMap.insert( eofKlangEl->data, eofKlangEl ); assert( eofMapEl != 0 ); nextSymbolId = 128; /* First pass assigns to the user terminals. */ for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) { /* Must be a term, and not any of the special reserved terminals. * Remember if the non terminal is a user non terminal. */ if ( lel->type == KlangEl::Term && lel != eofKlangEl && lel != errorKlangEl ) { lel->isUserTerm = true; lel->id = nextSymbolId++; } } /* Next assign to the eof token, which we always create. */ eofKlangEl->id = nextSymbolId++; } void ParseData::makeKlangElIds() { /* First pass assigns to the user terminals. */ for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) { if ( lel->id < 0 ) { /* Must be a term, and not any of the special reserved terminals. * Remember if the non terminal is a user non terminal. */ if ( lel->type == KlangEl::Term && lel != eofKlangEl && lel != errorKlangEl ) { lel->isUserTerm = true; lel->id = nextSymbolId++; } } } /* Possibly assign to the error language element. */ if ( errorKlangEl != 0 ) errorKlangEl->id = nextSymbolId++; /* Save this for for the code generation. */ firstNonTermId = nextSymbolId; /* A third and final pass assigns to everything else. */ for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) { /* Anything else not yet assigned gets assigned now. */ if ( lel->id < 0 ) lel->id = nextSymbolId++; } } void ParseData::checkInlineListReferences( Definition *prod, InlineBlock *inlineBlock ) { for ( InlineList::Iter ili = *inlineBlock->inlineList; ili.lte(); ili++ ) { if ( ili->type == InlineItem::Reference ) { if ( ili->data[1] != '$' && ili->data[1] != '@' ) { int refPos = atoi( ili->data+1 ) - 1; if ( refPos < 0 || refPos >= prod->rhsFactorVect.length() ) { error( ili->loc ) << "reference " << ili->data << " is out range for production" << endl; } } } } } void ParseData::checkReferences( Definition *prod ) { if ( prod->redBlock != 0 ) checkInlineListReferences( prod, prod->redBlock ); if ( prod->undoBlock != 0 ) checkInlineListReferences( prod, prod->undoBlock ); if ( prod->finalBlock != 0 ) checkInlineListReferences( prod, prod->finalBlock ); } /* Set up dot sets, shift info, and prod sets. */ void ParseData::makeProdFsms() { /* There are two items in the index for each production (high and low). */ int indexLen = prodList.length() * 2; dotItemIndex.setAsNew( indexLen ); int dsiLow = 0, indexPos = 0; /* Build FSMs for all production language elements. */ for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { /* Verify that rhs references are legal. */ checkReferences( prod ); prod->fsm = prod->prodElList->walk( this ); } makeNonTermFirstSets(); makeFirstSets(); /* Build FSMs for all production language elements. */ for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { if ( addUniqueEmptyProductions ) { /* This must be re-implemented. */ assert( false ); //if ( !prod->isLeftRec && prod->uniqueEmptyLeader != 0 ) { // FsmAp *emptyLeader = prod->uniqueEmptyLeader->walk( this ); // emptyLeader->concatOp( prod->fsm ); // prod->fsm = emptyLeader; //} } /* Compute the machine's length. */ prod->fsmLength = prod->fsm->fsmLength( ); /* Productions have a unique production id for each final state. * This lets us use a production length specific to each final state. * Start states are always isolated therefore if the start state is * final then reductions from it will always have a fixed production * length. This is a simple method for determining the length * of zero-length derivations when reducing. */ /* Number of dot items needed for the production is elements + 1 * because the dot can be before the first and after the last element. */ int numForProd = prod->fsm->stateList.length() + 1; /* Set up the low and high values in the index for this production. */ dotItemIndex.data[indexPos].key = dsiLow; dotItemIndex.data[indexPos].value = prod; dotItemIndex.data[indexPos+1].key = dsiLow + numForProd - 1; dotItemIndex.data[indexPos+1].value = prod; int dsi = dsiLow; for ( StateList::Iter state = prod->fsm->stateList; state.lte(); state++, dsi++ ) { /* All transitions are shifts. */ for ( TransMap::Iter out = state->transMap; out.lte(); out++ ) assert( out->value->isShift ); state->dotSet.insert( dsi ); } /* Move over the production. */ dsiLow += numForProd; indexPos += 2; if ( prod->prodCommit ) { for ( StateSet::Iter fin = prod->fsm->finStateSet; fin.lte(); fin++ ) { int length = prod->fsmLength; //cerr << "PENDING COMMIT IN FINAL STATE of " << prod->prodId << // " with len: " << length << endl; (*fin)->pendingCommits.insert( ProdIdPair( prod->prodId, length ) ); } } } /* Make the final state specific prod id to prod id mapping. */ prodIdIndex = new Definition*[prodList.length()]; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) prodIdIndex[prod->prodId] = prod; } /* Want the first set of over src. If the first set contains epsilon, go over * it and over tab. If overSrc is the end of the production, find the follow * from the table, taking only the characters on which the parent is reduced. * */ void ParseData::findFollow( AlphSet &result, StateAp *overTab, StateAp *overSrc, Definition *parentDef ) { if ( overSrc->isFinState() ) { assert( overSrc->transMap.length() == 0 ); /* At the end of the production. Turn to the table. */ long redCode = makeReduceCode( parentDef->prodId, false ); for ( TransMap::Iter tabTrans = overTab->transMap; tabTrans.lte(); tabTrans++ ) { for ( ActDataList::Iter adl = tabTrans->value->actions; adl.lte(); adl++ ) { if ( *adl == redCode ) { result.insert( tabTrans->key ); } } } } else { /* Get the first set of the item. If the first set contains epsilon * then move over overSrc and overTab and recurse. */ assert( overSrc->transMap.length() == 1 ); TransMap::Iter pastTrans = overSrc->transMap; KlangEl *langEl = langElIndex[pastTrans->key]; if ( langEl != 0 && langEl->type == KlangEl::NonTerm ) { bool hasEpsilon = false; for ( LelDefList::Iter def = langEl->defList; def.lte(); def++ ) { result.insert( def->firstSet ); if ( def->firstSet.find( -1 ) ) hasEpsilon = true; } /* Find the equivalent state in the parser. */ if ( hasEpsilon ) { TransAp *tabTrans = overTab->findTrans( pastTrans->key ); findFollow( result, tabTrans->toState, pastTrans->value->toState, parentDef ); } } else { result.insert( pastTrans->key ); } } } StateAp *ParseData::followProd( StateAp *tabState, StateAp *prodState ) { while ( prodState->transMap.length() == 1 ) { TransMap::Iter prodTrans = prodState->transMap; TransAp *tabTrans = tabState->findTrans( prodTrans->key ); prodState = prodTrans->value->toState; tabState = tabTrans->toState; } return tabState; } /* Go down a defintiion and then handle the follow actions. */ void ParseData::actionOrdsFollow( StateAp *tabState, TransAp *tabTrans, TransAp *srcTrans, Definition *parentDef, Definition *definition, long &time ) { /* We need the follow from tabState/srcState over the defintion we are * currently processing. */ StateAp *overTab = tabTrans->toState; StateAp *overSrc = srcTrans->toState; AlphSet alphSet; if ( parentDef == startDef ) alphSet.insert( eofKlangEl->id ); else findFollow( alphSet, overTab, overSrc, parentDef ); /* Now follow the production to find out where it expands to. */ StateAp *expandToState = followProd( tabState, definition->fsm->startState ); /* Find the reduce item. */ long redCode = makeReduceCode( definition->prodId, false ); for ( TransMap::Iter tt = expandToState->transMap; tt.lte(); tt++ ) { if ( alphSet.find( tt->key ) ) { for ( ActDataList::Iter adl = tt->value->actions; adl.lte(); adl++ ) { if ( *adl == redCode ) { if ( tt->value->actOrds[adl.pos()] == 0 ) { // cerr << "setting reduction(" << redCode << "): state = " // << expandToState->stateNum // << ", trans = " << tt->key // << ", time = " << time << endl; tt->value->actOrds[adl.pos()] = time++; } } } } } } void ParseData::actionOrdsProd( StateAp *tabState, StateAp *srcState, Definition *parentDef, long &time ) { assert( srcState->dotSet.length() == 1 ); if ( tabState->dotSet2.find( srcState->dotSet[0] ) ) return; tabState->dotSet2.insert( srcState->dotSet[0] ); assert( srcState->transMap.length() == 0 || srcState->transMap.length() == 1 ); if ( srcState->transMap.length() == 1 ) { TransMap::Iter srcTrans = srcState->transMap; /* Find the equivalent state in the parser. */ TransAp *tabTrans = tabState->findTrans( srcTrans->key ); /* Recurse into the transition if it is a non-terminal. */ KlangEl *langEl = langElIndex[srcTrans->key]; if ( langEl != 0 ) { if ( langEl->isShortest ) { /* Use a shortest match ordering for the contents of this * nonterminal. Does follows for all productions first, then * goes down the productions. */ for ( LelDefList::Iter expDef = langEl->defList; expDef.lte(); expDef++ ) { actionOrdsFollow( tabState, tabTrans, srcTrans->value, parentDef, expDef, time ); } for ( LelDefList::Iter expDef = langEl->defList; expDef.lte(); expDef++ ) actionOrdsProd( tabState, expDef->fsm->startState, expDef, time ); } else { /* The default action ordering. For each prod, goes down the * prod then sets the follow before going to the next prod. */ for ( LelDefList::Iter expDef = langEl->defList; expDef.lte(); expDef++ ) { actionOrdsProd( tabState, expDef->fsm->startState, expDef, time ); actionOrdsFollow( tabState, tabTrans, srcTrans->value, parentDef, expDef, time ); } } } /* Find the shift item. */ ActDataList::Iter adl = tabTrans->actions; for ( ; adl.lte(); adl++ ) { if ( *adl == SHIFT_CODE ) break; } /* If the time of the shift is not already set, set it. */ if ( tabTrans->actOrds[adl.pos()] == 0 ) { //cerr << "setting shift: state = " << tabState->stateNum // << ", trans = " << tabTrans->lowKey // << ", time = " << time << endl; tabTrans->actOrds[adl.pos()] = time++; } /* Go over one in the production. */ actionOrdsProd( tabTrans->toState, srcTrans->value->toState, parentDef, time ); } } long ParseData::computeActOrds() { for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { assert( (state->stateBits & SB_ISMARKED) == 0 ); /* Traverse the src state's transitions. */ long last = 0; for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { if ( ! trans.first() ) assert( last < trans->key ); last = trans->key; } } /* Compute the action orderings, record the max value. */ long time = 1; StateAp *startState = startDef->fsm->startState; actionOrdsProd( graph->startState, startState, startDef, time ); /* Walk over the start lang el and set the time for shift of * the eof action that completes the parse. This could use some cleanup, * in particular a find routine. */ TransAp *overStart = graph->startState->findTrans( userStartKlangEl->id ); TransAp *eofTrans = overStart->toState->findTrans( eofKlangEl->id ); eofTrans->actOrds[0] = time++; for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { assert( CmpDotSet::compare( state->dotSet, state->dotSet2 ) == 0 ); for ( TransMap::Iter tel = state->transMap; tel.lte(); tel++ ) { TransAp *trans = tel->value; /* Check every action has an ordering. */ for ( ActDataList::Iter adl = trans->actOrds; adl.lte(); adl++ ) { if ( *adl == 0 ) { warning() << "action ordering for " << trans->actions[adl.pos()] << " is unset, state: " << state->stateNum << ", trans: "; KlangEl *lel = langElIndex[trans->lowKey]; if ( lel == 0 ) cerr << (char)trans->lowKey << endl; else cerr << lel->data << endl; *adl = time++; } } } } return time; } long min( Vector &v ) { Vector::Iter i = v; long m = *i; i++; for ( ; i.lte(); i++ ) { if ( *i < m ) m = *i; } return m; } void ParseData::advanceReductions( long nextTime ) { /* Loop all states. */ for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { bool outHasShift = false; long minTime = nextTime; ReductionMap outReds; LongSet outCommits; for ( TransMap::Iter out = state->transMap; out.lte(); out++ ) { /* Get the transition from the trans el. */ if ( out->value->isShift ) outHasShift = true; outReds.insert( out->value->reductions ); outCommits.insert( out->value->commits ); long nmt = min( out->value->actOrds ); if ( nmt < minTime ) minTime = nmt; } bool inHasShift = false; ReductionMap inReds; for ( TransInList::Iter in = state->inRange; in.lte(); in++ ) { /* Get the transition from the trans el. */ if ( in->isShift ) inHasShift = true; inReds.insert( in->reductions ); } if ( !outHasShift && outReds.length() == 1 && inHasShift && inReds.length() == 0 ) { //cerr << "moving reduction to shift" << endl; /* Move the reduction to all in transitions. */ for ( TransInList::Iter in = state->inRange; in.lte(); in++ ) { assert( in->actions.length() == 1 ); assert( in->actions[0] == SHIFT_CODE ); in->actions[0] = makeReduceCode( outReds[0].key, true ); in->actOrds[0] = minTime; in->afterShiftCommits.insert( outCommits ); } /* * Remove all transitions out of the state. */ /* Detach out range transitions. */ for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { graph->detachTrans( state, trans->value->toState, trans->value ); delete trans->value; } state->transMap.empty(); /* Redirect all the in transitions to the actionDestState. */ graph->inTransMove( actionDestState, state ); } } graph->removeUnreachableStates(); long *map = new long[nextTime]; memset( map, 0, sizeof(long)*nextTime ); for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { for ( ActDataList::Iter t = trans->value->actOrds; t.lte(); t++ ) map[*t] = 1; } } for ( int i = 0, j = 1; i < nextTime; i++ ) { if ( map[i] ) map[i] = j++; } for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { for ( ActDataList::Iter t = trans->value->actOrds; t.lte(); t++ ) *t = map[*t]; } } delete[] map; } void ParseData::sortActions() { /* Sort the actions. */ for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { assert( CmpDotSet::compare( state->dotSet, state->dotSet2 ) == 0 ); for ( TransMap::Iter tel = state->transMap; tel.lte(); tel++ ) { TransAp *trans = tel->value; /* Sort by the action ords. */ ActDataList actions( trans->actions ); ActDataList actOrds( trans->actOrds ); ActDataList actPriors( trans->actPriors ); trans->actions.empty(); trans->actOrds.empty(); trans->actPriors.empty(); while ( actOrds.length() > 0 ) { int min = 0; for ( int i = 1; i < actOrds.length(); i++ ) { if ( actPriors[i] > actPriors[min] || (actPriors[i] == actPriors[min] && actOrds[i] < actOrds[min] ) ) { min = i; } } trans->actions.append( actions[min] ); trans->actOrds.append( actOrds[min] ); trans->actPriors.append( actPriors[min] ); actions.remove(min); actOrds.remove(min); actPriors.remove(min); } if ( branchPointInfo && trans->actions.length() > 1 ) { cout << "info: branch point" << " state: " << state->stateNum << " trans: "; KlangEl *lel = langElIndex[trans->lowKey]; if ( lel == 0 ) cout << (char)trans->lowKey << endl; else cout << lel->data << endl; cout << " actions:" << endl; for ( ActDataList::Iter act = trans->actions; act.lte(); act++ ) { switch ( *act & 0x3 ) { case 1: cout << " shift" << endl; break; case 2: cout << " reduce " << prodIdIndex[(*act >> 2)]->data << endl; break; case 3: cout << " shift-reduce" << endl; break; } } cout << " dot set of state:" << endl; for ( DotSet::Iter dsi = state->dotSet; dsi.lte(); dsi++ ) printDotSet( cout, *dsi ); } /* Verify that shifts of nonterminals don't have any branch * points or commits. */ if ( trans->lowKey >= firstNonTermId ) { if ( trans->actions.length() != 1 || (trans->actions[0] & 0x3) != 1 ) { error() << "TRANS ON NONTERMINAL is something " "other than a shift" << endl; } if ( trans->commits.length() > 0 ) error() << "TRANS ON NONTERMINAL has a commit" << endl; } /* TODO: Shift-reduces are optimizations. Verify that * shift-reduces exist only if they don't entail a conflict. */ } } } void ParseData::reduceActions() { /* Reduce the actions. */ for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { for ( TransMap::Iter tel = state->transMap; tel.lte(); tel++ ) { TransAp *trans = tel->value; ActionSetEl *inSet; int commitLen = trans->commits.length() > 0 ? trans->commits[trans->commits.length()-1] : 0; if ( trans->afterShiftCommits.length() > 0 ) { int afterShiftCommit = trans->afterShiftCommits[ trans->afterShiftCommits.length()-1]; if ( commitLen > 0 && commitLen+1 > afterShiftCommit ) commitLen = ( commitLen + 1 ); else commitLen = afterShiftCommit; } else { commitLen = commitLen * -1; } // if ( commitLen != 0 ) { // cerr << "FINAL ACTION COMMIT LEN: " << commitLen << endl; // } actionSet.insert( ActionData( trans->toState->stateNum, trans->actions, commitLen ), &inSet ); trans->actionSetEl = inSet; } } } void ParseData::analyzeMachine() { maxState = graph->stateList.length() - 1; maxLelId = nextSymbolId - 1; maxOffset = graph->stateList.length() * maxLelId; for ( StateList::Iter state = graph->stateList; state.lte(); state++ ) { for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { if ( trans->value->isShift ) { trans->value->actions.append( SHIFT_CODE ); trans->value->actPriors.append( trans->value->shiftPrior ); } for ( ReductionMap::Iter red = trans->value->reductions; red.lte(); red++ ) { trans->value->actions.append( makeReduceCode( red->key, false ) ); trans->value->actPriors.append( red->value ); } trans->value->actOrds.appendDup( 0, trans->value->actions.length() ); } } long nextTime = computeActOrds(); sortActions(); advanceReductions( nextTime ); graph->setStateNumbers(); reduceActions(); /* Set the action ids. */ int actionSetId = 0; for ( ActionSet::Iter asi = actionSet; asi.lte(); asi++ ) asi->key.id = actionSetId++; /* Get the max index. */ maxIndex = actionSetId - 1; /* Compute the max prod length. */ maxProdLen = 0; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { if ( (unsigned)prod->fsmLength > maxProdLen ) maxProdLen = prod->fsmLength; } } void ParseData::wrapUserStartSymbol() { SymbolMapEl *startMapEl = symbolMap.find( startDefName ); if ( startMapEl == 0 ) { /* No recovery action, fsm is skipped. */ error(sectionLoc) << "start non-terminal not defined in \"" << parserName << "\"" << endl; return; } userStartKlangEl = startMapEl->value; /* Make a language element that will go to the start symbol only. This will * guarantee a start symbol with only one production. A name with an underscore * at the beginning will never clash with any user name. */ startKlangEl = new KlangEl( strdup("_start"), KlangEl::NonTerm ); langEls.append( startKlangEl ); startMapEl = symbolMap.insert( startKlangEl->data, startKlangEl ); assert( startMapEl != 0 ); /* Make a single production for the start element. */ ProdElList *startProdElList = makeProdElList( startKlangEl->data, userStartKlangEl ); startDef = new Definition( InputLoc(), startKlangEl, startProdElList, false, 0, 0, 0, prodList.length(), Definition::Production ); prodList.append( startDef ); startKlangEl->defList.append( startDef ); } bool ParseData::makeNonTermFirstSetProd( Definition *prod, StateAp *state ) { bool modified = false; for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { if ( trans->key >= firstNonTermId ) { long *inserted = prod->nonTermFirstSet.insert( trans->key ); if ( inserted != 0 ) modified = true; bool hasEpsilon = false; KlangEl *lel = langElIndex[trans->key]; for ( LelDefList::Iter ldef = lel->defList; ldef.lte(); ldef++ ) { for ( ProdIdSet::Iter pid = ldef->nonTermFirstSet; pid.lte(); pid++ ) { if ( *pid == -1 ) hasEpsilon = true; else { long *inserted = prod->nonTermFirstSet.insert( *pid ); if ( inserted != 0 ) modified = true; } } } if ( hasEpsilon ) { if ( trans->value->toState->isFinState() ) { long *inserted = prod->nonTermFirstSet.insert( -1 ); if ( inserted != 0 ) modified = true; } bool lmod = makeNonTermFirstSetProd( prod, trans->value->toState ); if ( lmod ) modified = true; } } } return modified; } void ParseData::makeNonTermFirstSets() { // cerr << "MAKING NONTERM FIRST SETS" << endl; bool modified = true; while ( modified ) { modified = false; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { if ( prod->fsm->startState->isFinState() ) { long *inserted = prod->nonTermFirstSet.insert( -1 ); if ( inserted != 0 ) modified = true; } bool lmod = makeNonTermFirstSetProd( prod, prod->fsm->startState ); if ( lmod ) modified = true; } } for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { // cerr << prod->data << ": "; // for ( ProdIdSet::Iter pid = prod->nonTermFirstSet; pid.lte(); pid++ ) // { // if ( *pid < 0 ) // cerr << " "; // else { // KlangEl *lel = langElIndex[*pid]; // cerr << " " << lel->data; // } // } // cerr << endl; if ( prod->nonTermFirstSet.find( prod->prodName->id ) ) { // cerr << "PROD IS LEFT REC: " << prod->data << endl; prod->isLeftRec = true; } } } bool ParseData::makeFirstSetProd( Definition *prod, StateAp *state ) { bool modified = false; for ( TransMap::Iter trans = state->transMap; trans.lte(); trans++ ) { if ( trans->key < firstNonTermId ) { long *inserted = prod->firstSet.insert( trans->key ); if ( inserted != 0 ) modified = true; } else { long *inserted = prod->firstSet.insert( trans->key ); if ( inserted != 0 ) modified = true; bool hasEpsilon = false; KlangEl *lel = langElIndex[trans->key]; for ( LelDefList::Iter ldef = lel->defList; ldef.lte(); ldef++ ) { for ( ProdIdSet::Iter pid = ldef->firstSet; pid.lte(); pid++ ) { if ( *pid == -1 ) hasEpsilon = true; else { long *inserted = prod->firstSet.insert( *pid ); if ( inserted != 0 ) modified = true; } } } if ( hasEpsilon ) { if ( trans->value->toState->isFinState() ) { long *inserted = prod->firstSet.insert( -1 ); if ( inserted != 0 ) modified = true; } bool lmod = makeFirstSetProd( prod, trans->value->toState ); if ( lmod ) modified = true; } } } return modified; } void ParseData::makeFirstSets() { // cerr << "MAKING TERM FIRST SETS" << endl; bool modified = true; while ( modified ) { modified = false; for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { if ( prod->fsm->startState->isFinState() ) { long *inserted = prod->firstSet.insert( -1 ); if ( inserted != 0 ) modified = true; } bool lmod = makeFirstSetProd( prod, prod->fsm->startState ); if ( lmod ) modified = true; } } // for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { // cerr << prod->data << ": "; // for ( ProdIdSet::Iter pid = prod->firstSet; pid.lte(); pid++ ) // { // if ( *pid < 0 ) // cerr << " "; // else { // KlangEl *lel = langElIndex[*pid]; // if ( lel != 0 ) // cerr << endl << " " << lel->data; // else // cerr << endl << " " << *pid; // } // } // cerr << endl; // } } void ParseData::uniqueEmptyProductions() { if ( addUniqueEmptyProductions ) { int limit = prodList.length(); for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) { if ( prod->prodId == limit ) break; /* Get a language element. */ char name[20]; sprintf(name, "U%li", prodList.length()); KlangEl *prodName = getKlangEl( this, name, KlangEl::NonTerm ); Definition *newDef = new Definition( InputLoc(), prodName, 0 /* FIXME new VarDef( name, 0 )*/, false, 0, 0, 0, prodList.length(), Definition::Production ); prodName->defList.append( newDef ); prodList.append( newDef ); prod->uniqueEmptyLeader = prodName; } } } void ParseData::makeGraph() { if ( didGraph ) return; didGraph = true; makeTokens(); uniqueEmptyProductions(); wrapUserStartSymbol(); if ( gblErrorCount > 0 ) return; makeKlangElIds(); makeDefinitionNames(); noUndefinedKlangEls(); noUndefinedUses(); /* Put the language elements in an index by language element id. */ langElIndex = new KlangEl*[nextSymbolId+1]; memset( langElIndex, 0, sizeof(KlangEl*)*(nextSymbolId+1) ); for ( LelList::Iter lel = langEls; lel.lte(); lel++ ) langElIndex[lel->id] = lel; //for ( DefList::Iter prod = prodList; prod.lte(); prod++ ) // cerr << prod->prodId << " " << prod->data << endl; makeProdFsms(); lalr1GenerateParser(); graph->setStateNumbers(); analyzeMachine(); //cerr << "NUMBER OF STATES: " << graph->stateList.length() << endl; } void ParseData::generateInstanceData() { makeTokens( ); startCodeGen(); writeInstanceData(); } void ParseData::generateTokenDefs() { makeTokens( ); startCodeGen(); writeTokenDefs(); } void ParseData::generateTypes() { makeGraph(); if ( gblErrorCount > 0 ) return; startCodeGen(); writeTypes(); } void ParseData::generateData() { makeGraph(); if ( gblErrorCount > 0 ) return; startCodeGen(); writeData(); } void ParseData::generateInit() { makeGraph(); if ( gblErrorCount > 0 ) return; startCodeGen(); writeInit(); } void ParseData::generateExec() { makeGraph(); if ( gblErrorCount > 0 ) return; startCodeGen(); writeExec(); } void ParseData::generateFinish() { makeGraph(); if ( gblErrorCount > 0 ) return; startCodeGen(); writeFinish(); } void ParseData::generateGraphviz( ) { makeGraph(); if ( gblErrorCount > 0 ) return; writeDotFile(); } kelbt-0.16/src/kelbt.h0000664000175000017500000000406612471723342011540 00000000000000/* * Copyright 2001-2003,2005 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _KELBT_H #define _KELBT_H #include #include #include #include "avltree.h" #include "vector.h" #include "config.h" #define PROGNAME "kelbt" struct Parser; /* Filter on the output stream that keeps track of the number of lines * output. */ class output_filter : public std::filebuf { public: output_filter() : line(1) { } virtual int sync(); virtual std::streamsize xsputn(const char* s, std::streamsize n); int line; }; /* IO filenames and stream. */ extern const char *outputFile; extern std::ostream *outStream; extern output_filter *outFilter; extern bool generateGraphviz; extern Parser *graphvizGenParser; extern bool branchPointInfo; extern bool addUniqueEmptyProductions; extern bool inhibitLineDirectives; extern int gblErrorCount; extern char startDefName[]; typedef Vector ArgsVector; extern ArgsVector includePaths; /* Error reporting. */ struct InputLoc; std::ostream &error(); std::ostream &error( const InputLoc &loc ); std::ostream &error( int first_line, int first_column ); std::ostream &warning( ); std::ostream &warning( const InputLoc &loc ); std::ostream &warning( int first_line, int first_column ); /* Size of the include stack. */ #define INCLUDE_STACK_SIZE 32 #endif /* _KELBT_H */ kelbt-0.16/src/parsedata.h0000664000175000017500000003073512471662307012410 00000000000000/* * Copyright 2001-2005 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PARSEDATA_H #define _PARSEDATA_H #include #include #include #include "avlmap.h" #include "bstmap.h" #include "dlist.h" #include "fsmgraph.h" #include "compare.h" #include "vector.h" #include "dlistmel.h" using std::ostream; using std::string; /* Forwards. */ struct RedFsmAp; struct KlangEl; #define SHIFT_CODE 0x1 #define REDUCE_CODE 0x2 #define SHIFT_REDUCE_CODE 0x3 inline long makeReduceCode( long reduction, bool isShiftReduce ) { return ( isShiftReduce ? SHIFT_REDUCE_CODE : REDUCE_CODE ) | ( reduction << 2 ); } /* Location in an input file. */ struct InputLoc { int line; int col; }; /* * Inline code tree */ struct InlineItem { enum Type { Text, Reference }; InlineItem( const InputLoc &loc, char *data, Type type ) : loc(loc), data(data), type(type) { } InlineItem( const InputLoc &loc, Type type ) : loc(loc), data(0), type(type) { } InputLoc loc; char *data; Type type; InlineItem *prev, *next; }; typedef DList InlineList; /* Element in a list of strings used for storing inline code blocks. */ struct InlineBlock { InlineBlock( const InputLoc &loc, InlineList *inlineList ) : loc(loc), inlineList(inlineList) { inlineList->head->data++; inlineList->tail->data[strlen(inlineList->tail->data)-1] = 0; } InputLoc loc; InlineList *inlineList; InlineBlock *prev, *next; }; /* List of inline code blocks. */ typedef DList InlineBlockList; /* Structure for reverse action mapping. */ struct RevActionMapEl { char *name; InputLoc location; }; struct Factor; struct ProdElList; struct Literal; struct Definition; struct DefListEl { Definition *prev, *next; }; struct LelDefListEl { Definition *prev, *next; }; typedef Vector< KlangEl* > KlangElVect; typedef Vector< Factor* > FactorVect; struct TypeDef { TypeDef( char *data ) : data(data), typeBlock(0), isClass(false) {} TypeDef( char *data, InlineBlock *typeBlock, bool isClass ) : data(data), typeBlock(typeBlock), isClass(isClass) {} char *data; InlineBlock *typeBlock; bool isClass; }; typedef BstMap< char*, TypeDef*, CmpStr > TypeDefMap; typedef BstMapEl< char*, TypeDef* > TypeDefMapEl; /* Graph dictionary. */ struct Definition : public DefListEl, public LelDefListEl { enum Type { Production }; Definition( const InputLoc &loc, KlangEl *prodName, ProdElList *prodElList, bool prodCommit, InlineBlock *redBlock, InlineBlock *undoBlock, InlineBlock *finalBlock, int prodId, Type type ) : loc(loc), prodName(prodName), prodElList(prodElList), prodCommit(prodCommit), redBlock(redBlock), undoBlock(undoBlock), finalBlock(finalBlock), prodId(prodId), type(type), fsm(0), fsmLength(0), data(0), uniqueEmptyLeader(0), isLeftRec(false) {} InputLoc loc; KlangEl *prodName; ProdElList *prodElList; bool prodCommit; InlineBlock *redBlock; InlineBlock *undoBlock; InlineBlock *finalBlock; int prodId; Type type; FsmAp *fsm; int fsmLength; char *data; KlangElVect rhsLelVect; FactorVect rhsFactorVect; LongSet reducesTo; KlangEl *uniqueEmptyLeader; ProdIdSet nonTermFirstSet; AlphSet firstSet; bool isLeftRec; }; struct CmpDefById { static int compare( Definition *d1, Definition *d2 ) { if ( d1->prodId < d2->prodId ) return -1; else if ( d1->prodId > d2->prodId ) return 1; else return 0; } }; /* Map dotItems to productions. */ typedef BstMap< int, Definition*, CmpOrd > DotItemIndex; typedef BstMapEl< int, Definition*> DotItemIndexEl; /* Symbol Map. */ typedef AvlMap< char*, KlangEl*, CmpStr > SymbolMap; typedef AvlMapEl< char*, KlangEl* > SymbolMapEl; /* A vector of production vectors. Each non terminal can have many productions. */ typedef DListMel DefList; typedef DListMel LelDefList; /* A set of machines made during a closure round. */ typedef Vector< FsmAp* > Machines; /* List of language elements. */ typedef DList LelList; /* Class to collect information about the machine during the * parse of input. */ struct ParseData { /* Create a new parse data object. This is done at the beginning of every * fsm specification. */ ParseData( const char *fileName, char *parserName, ostream &out ); void wrapUserStartSymbol(); void makeTokens(); void makeDefinitionNames(); void noUndefinedKlangEls(); void noUndefinedUses(); void makeKlangElIds(); /* Parser generation. */ void advanceReductions( long nextTime ); void sortActions(); void linkExpansions(); void lalr1FollowEpsilonOp(); void transferCommits( TransAp *trans, StateAp *state, long prodId ); void lalr1AddFollow2( TransAp *trans, FollowToAdd &followKeys ); void lalr1AddFollow1( StateAp *state ); void lalr1AddFollow2( TransAp *trans, long followKey, long prior ); void lalr1AddFollow1( TransAp *trans ); void lalr1AddFollowSets(); void lr0BringInItem( StateAp *dest, StateAp *prodState, TransAp *expandFrom, Definition *prod ); void lr0InvokeClosure( StateAp *state ); void lr0CloseAllStates(); void lalr1GenerateParser(); void reduceActions(); bool makeNonTermFirstSetProd( Definition *prod, StateAp *state ); void makeNonTermFirstSets(); bool makeFirstSetProd( Definition *prod, StateAp *state ); void makeFirstSets(); StateAp *followProd( StateAp *tabState, StateAp *prodState ); void findFollow( AlphSet &result, StateAp *overTab, StateAp *overSrc, Definition *parentDef ); long computeActOrds(); void actionOrdsFollow( StateAp *tabState, TransAp *tabTrans, TransAp *srcTrans, Definition *parentDef, Definition *definition, long &time ); void actionOrdsProd( StateAp *tabState, StateAp *srcState, Definition *parentDef, long &time ); void analyzeMachine(); void checkInlineListReferences( Definition *prod, InlineBlock *inlineBlock ); void checkReferences( Definition *prod ); void makeProdFsms(); void uniqueEmptyProductions(); void makeGraph(); /* Generate and write out the fsm. */ void generateInstanceData(); void generateTokenDefs(); void generateTypes(); void generateData(); void generateInit(); void generateExec(); void generateFinish(); void generateGraphviz(); /* * Querying the parse data */ /* * Code Generation. */ void startCodeGen(); void endCodeGen( int endLine ); void writeNonTermDestructors(); void writeFinishBlocks(); void writeFinalBlocks(); void writeReduceBlocks(); void writeUndoBlocks(); void writeTokenIds(); void writeLangEls(); void writeReferencePtr( InputLoc &loc, Definition *prod, char *data, int refNum ); void writeReference( InputLoc &loc, Definition *prod, char *data, int refNum ); void writeUndoReference( Definition *prod, char *data ); void writeFinalReference( Definition *prod, char *data ); void writeInlineBlock( Definition *prod, InlineBlock *inlineBlock ); void writeFirstLocate( Definition *prod ); void writeRhsLocate( Definition *prod ); ostream &UARRAY_TYPE( unsigned long long maxVal ); ostream &SARRAY_TYPE( signed long long maxVal ); ostream &ALLOCATE_EL( const char *name ); void writeInstanceData(); void writeTokenDefs(); void writeTypes(); void writeData(); void writeInit(); void writeExec(); void writeFinish(); string PARSER() { string ret = parserName; ret += "_"; return ret; } string Block() { return PARSER() + "Block"; } string LangEl() { return PARSER() + "LangEl"; } string Token() { string ret; if ( tokenStruct != 0 ) ret = tokenStruct; else ret = "Token"; return ret; } string Lel_() { return PARSER() + "Lel_"; } string UserData() { return PARSER() + "UserData"; } string startState() { return PARSER() + "startState"; } string indicies() { return PARSER() + "indicies"; } string keys() { return PARSER() + "keys"; } string offsets() { return PARSER() + "offsets"; } string targs() { return PARSER() + "targs"; } string actInds() { return PARSER() + "actInds"; } string actions() { return PARSER() + "actions"; } string commitLen() { return PARSER() + "commitLen"; } string prodLengths() { return PARSER() + "prodLengths"; } string prodLhsIds() { return PARSER() + "prodLhsIds"; } string prodNames() { return PARSER() + "prodNames"; } string lelNames() { return PARSER() + "lelNames"; } string ACCESS() { string ret; if ( access != 0 ) ret = access; return ret; } string curs() { return ACCESS() + "curs"; } string pool() { return ACCESS() + "pool"; } string freshEl() { return ACCESS() + "freshEl"; } string block() { return ACCESS() + "block"; } string stackTop() { return ACCESS() + "stackTop"; } string freshPos() { return ACCESS() + "freshPos"; } string lastFinal() { return ACCESS() + "lastFinal"; } string numRetry() { return ACCESS() + "numRetry"; } string numNodes() { return ACCESS() + "numNodes"; } string errCount() { return ACCESS() + "errCount"; } void printDotSet( ostream &out, long dotItem ); /* * Graphviz Generation */ void writeTransList(StateAp *state ); void writeDotFile(FsmAp *graph ); void writeDotFile( ); /* * Data collected during the parse. */ /* Dictionary of graphs. Both instances and non-instances go here. */ SymbolMap symbolMap; LelList langEls; /* The list of instances. */ DefList prodList; /* Dumping. */ DotItemIndex dotItemIndex; /* The name of the file the fsm is from, and the spec name. */ const char *fileName; char *parserName; ostream &out; InputLoc sectionLoc; /* How to access the instance data. */ char *access; /* The name of the token structure. */ char *tokenStruct; KlangEl *startKlangEl; KlangEl *eofKlangEl; KlangEl *errorKlangEl; KlangEl *userStartKlangEl; Definition *startDef; int nextSymbolId; int firstNonTermId; KlangEl **langElIndex; FsmAp *graph; StateAp *actionDestState; DefSetSet prodSetSet; ActionSet actionSet; /* Collected machine information. */ unsigned long long maxState; unsigned long long maxAction; unsigned long long maxLelId; unsigned long long maxOffset; unsigned long long maxIndex; unsigned long long maxProdLen; InlineBlock *elementBlock; InlineBlock *tokenBlock; InlineBlock *preReduceBlock; InlineBlock *postReduceBlock; InlineBlock *translateBlock; InlineBlock *undoTransBlock; InlineBlock *tokenFinalBlock; Definition **prodIdIndex; AlphSet literalSet; TypeDefMap typeDefMap; bool didTokens, didGraph, tokenIsClass; }; /* A language element class. Can be a nonTerm or a term. */ struct KlangEl : public DListEl { enum Type { Unknown, Term, NonTerm }; KlangEl( char *data, Type type ); ~KlangEl(); char *data; Type type; long id; bool isUserTerm; bool isContext; TypeDef *typeDef; char *displayString; int numAppearances; bool isShortest; /* Return a string that describes what the lang el is. * literal-term, term, regular, non-term */ const char *typeString(); /* Productions from the language element if it is a non-terminal. */ LelDefList defList; }; KlangEl *getKlangEl( ParseData *pd, char *data, KlangEl::Type defType ); struct Factor { /* Language elements a factor node can be. */ enum Type { LiteralType, ReferenceType }; /* Construct with a literal fsm. */ Factor( const InputLoc &loc, bool commit, Literal *literal, int priorVal ) : loc(loc), commit(commit), literal(literal), priorVal(priorVal), type(LiteralType) {} /* Construct with a reference to a var def. */ Factor( const InputLoc &loc, bool commit, KlangEl *langEl, int priorVal ) : loc(loc), commit(commit), langEl(langEl), priorVal(priorVal), type(ReferenceType) {} InputLoc loc; bool commit; Literal *literal; KlangEl *langEl; int priorVal; Type type; Factor *prev, *next; }; struct ProdElList : public DList { FsmAp *walk( ParseData *pd ); }; /* Some literal machine. Can be a number or literal string. */ struct Literal { Literal( const InputLoc &loc, long value ) : loc(loc), value(value) { } InputLoc loc; long value; }; #endif /* _PARSEDATA_H */ kelbt-0.16/src/klparse.kl0000664000175000017500000002010412471720163012244 00000000000000/* * Copyright 2006 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "klparse.h" #include "kelbt.h" #include using std::cout; using std::cerr; using std::endl; %%{ parser Parser; include "klparse.kh"; start: statement_list; statement_list: statement_list statement; statement_list: ; statement: production_stmt commit; statement: token_stmt commit; statement: token_uses_stmt commit; statement: translate_stmt commit; statement: nonterm_stmt commit; statement: type_stmt commit; statement: access_stmt commit; statement: shortest_stmt commit; access_stmt: KW_Access TK_AccessData ';' final { pd.access = $2->data; }; production_stmt: TK_Word ':' prod_el_list opt_commit opt_reduction opt_undo opt_final ';' final { /* Get the language element. */ KlangEl *prodName = getKlangEl( &pd, $1->data, KlangEl::NonTerm ); /* Check that the element wasn't previously defined as something else. */ if ( prodName->type != KlangEl::Unknown && prodName->type != KlangEl::NonTerm ) { error($1->loc) << "'" << $1->data << "' already defined as something else" << endl; } else { prodName->type = KlangEl::NonTerm; Definition *newDef = new Definition( $1->loc, prodName, $3->prodElList, $4->commit, $5->inlineBlock, $6->inlineBlock, $7->inlineBlock, pd.prodList.length(), Definition::Production ); prodName->defList.append( newDef ); pd.prodList.append( newDef ); /* Start machine will trigger code generation. */ if ( strcmp($1->data, startDefName) == 0 ) sawStart = true; newDef->rhsLelVect = langElVect; newDef->rhsFactorVect = factorVect; langElVect.empty(); factorVect.empty(); } }; token_stmt: KW_Token token_list ';'; token_list: token_list ',' token_list_word; token_list: token_list_word; token_list_word: TK_Word final { /* Token name must be unique. */ KlangEl *tokName = getKlangEl( &pd, $1->data, KlangEl::Term ); if ( tokName->type != KlangEl::Unknown && tokName->type != KlangEl::Term ) error($1->loc) << "'" << $1 << "' already defined as something else" << endl; tokName->type = KlangEl::Term; }; token_uses_stmt: KW_Token KW_Uses opt_class TK_Word ';' final { pd.tokenStruct = $4->data; pd.tokenIsClass = $3->isClass; }; translate_stmt: KW_Token opt_translate opt_undo opt_final ';' final { pd.translateBlock = $2->inlineBlock; pd.undoTransBlock = $3->inlineBlock; pd.tokenFinalBlock = $4->inlineBlock; }; nonterm_stmt: KW_NonTerm opt_class TK_Word inline_list ';' final { /* Create/get the nonterminal. */ KlangEl *nonTerm = getKlangEl( &pd, $3->data, KlangEl::NonTerm ); /* Make a new inline block. */ InlineBlock *typeBlock = new InlineBlock( $3->loc, $4->inlineList ); /* Create/get the typedef. */ TypeDef *typeDef = getTypeDef( $3->data ); nonTerm->typeDef = typeDef; /* The typeDef should not already exist. */ if ( typeDef->typeBlock != 0 ) error($3->loc) << "redefintion of nonterminal type " << $3->data << endl; else { typeDef->typeBlock = typeBlock; typeDef->isClass = $2->isClass; } }; nonterm_stmt: KW_NonTerm TK_Word KW_Uses TK_Word ';' final { KlangEl *nonTerm = getKlangEl( &pd, $2->data, KlangEl::NonTerm ); nonTerm->typeDef = getTypeDef( $4->data ); }; nonterm opt_class { bool isClass; }; opt_class: KW_Class final { $$->isClass = true; }; opt_class: final { $$->isClass = false; }; type_stmt: KW_Type opt_class TK_Word inline_list ';' final { /* Create the inline block and create/get the typedef. */ InlineBlock *typeBlock = new InlineBlock( InputLoc($4->loc), $4->inlineList ); TypeDef *typeDef = getTypeDef( $3->data ); /* The typeDef should not already exist. */ if ( typeDef->typeBlock != 0 ) error($3->loc) << "redefintion of nonterminal type " << $3->data << endl; else { typeDef->typeBlock = typeBlock; typeDef->isClass = $2->isClass; } }; shortest_stmt: KW_Shortest TK_Word ';' final { KlangEl *nonTerm = getKlangEl( &pd, $2->data, KlangEl::NonTerm ); nonTerm->isShortest = true; }; nonterm inline_list { InlineList *inlineList; InputLoc loc; }; inline_list: inline_list inline_block_item final { $1->inlineList->append( $2->inlineItem ); $$->inlineList = $1->inlineList; $$->loc = $1->loc; }; inline_list: inline_block_item final { $$->inlineList = new InlineList; $$->inlineList->append( $1->inlineItem ); $$->loc = $1->loc; }; nonterm inline_block_item { InlineItem *inlineItem; InputLoc loc; }; inline_block_item: TK_Inline final { $$->inlineItem = new InlineItem( $1->loc, $1->data, InlineItem::Text ); $$->loc = $1->loc; }; inline_block_item: TK_Reference final { $$->inlineItem = new InlineItem( $1->loc, $1->data, InlineItem::Reference ); $$->loc = $1->loc; }; nonterm prod_el_list { ProdElList *prodElList; }; prod_el_list: prod_el_list prod_el final { $1->prodElList->append( $2->factor ); $$->prodElList = $1->prodElList; }; prod_el_list: final { $$->prodElList = new ProdElList; }; nonterm prod_el { Factor *factor; }; prod_el: opt_prior opt_commit TK_Word final { KlangEl *langEl = getKlangEl( &pd, $3->data, KlangEl::Unknown ); $$->factor = new Factor( $3->loc, $2->commit, langEl, $1->priorVal ); langElVect.append( langEl ); factorVect.append( $$->factor ); }; prod_el: opt_prior opt_commit TK_Literal final { /* Create a new factor node going to a concat literal. */ Literal *literal = new Literal( $3->loc, $3->data[0] ); $$->factor = new Factor( $3->loc, $2->commit, literal, $1->priorVal ); langElVect.append( 0 ); factorVect.append( $$->factor ); }; nonterm opt_commit { bool commit; }; opt_commit: final { $$->commit = false; }; opt_commit: KW_Commit final { $$->commit = true; }; nonterm opt_prior { int priorVal; }; opt_prior: KW_Pri '(' TK_Number ')' final { $$->priorVal = atoi( $3->data ); }; opt_prior: final { $$->priorVal = 0; }; type opt_inline_block { InlineBlock *inlineBlock; }; nonterm opt_reduction uses opt_inline_block; nonterm opt_undo uses opt_inline_block; nonterm opt_final uses opt_inline_block; nonterm opt_translate uses opt_inline_block; opt_reduction: final { $$->inlineBlock = 0; }; opt_reduction: KW_Try inline_list final { $$->inlineBlock = new InlineBlock( $2->loc, $2->inlineList ); }; opt_undo: final { $$->inlineBlock = 0; }; opt_undo: KW_Undo inline_list final { $$->inlineBlock = new InlineBlock( $2->loc, $2->inlineList ); }; opt_final: final { $$->inlineBlock = 0; }; opt_final: KW_Final inline_list final { $$->inlineBlock = new InlineBlock( $2->loc, $2->inlineList ); }; opt_translate: final { $$->inlineBlock = 0; }; opt_translate: KW_Translate inline_list final { $$->inlineBlock = new InlineBlock( $2->loc, $2->inlineList ); }; }%% %%{ write types; write data; }%% void Parser::init() { %% write init; } TypeDef *Parser::getTypeDef( char *data ) { TypeDefMapEl *inMap = 0, *inserted; inserted = pd.typeDefMap.insert( data, &inMap ); if ( inserted != 0 ) inserted->value = new TypeDef( data ); return inMap->value; } int Parser::parseLangEl( int type, const Token *token ) { %% write exec; return errCount == 0 ? 0 : -1; } int Parser::token( int line, int tokid, char *data ) { Token token; token.data = data; token.loc.line = line; token.loc.col = 1; //cout << "SENDING TOKEN: " << lelNames[tokid]; //if ( token.data != 0 ) // cout << " data: " << token.data; //cout << endl; return parseLangEl( tokid, &token ); } kelbt-0.16/src/config.h.in0000664000175000017500000000116512472121237012302 00000000000000/* src/config.h.in. Generated from configure.ac by autoheader. */ /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Version number of package */ #undef VERSION kelbt-0.16/src/klparse.cpp0000664000175000017500000011700212471720203012417 00000000000000/* Automatically generated by Kelbt from "klparse.kl". * * Parts of this file are copied from Kelbt source covered by the GNU * GPL. As a special exception, you may use the parts of this file copied * from Kelbt source without restriction. The remainder is derived from * "klparse.kl" and inherits the copyright status of that file. */ #line 1 "klparse.kl" /* * Copyright 2006 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "klparse.h" #include "kelbt.h" #include using std::cout; using std::cerr; using std::endl; #line 49 "klparse.kh" #line 69 "klparse.kh" #line 318 "klparse.kl" #line 45 "klparse.cpp" struct Parser_Lel_inline_block_item { #line 193 "klparse.kl" InlineItem *inlineItem; InputLoc loc; #line 52 "klparse.cpp" }; struct Parser_Lel_inline_list { #line 171 "klparse.kl" InlineList *inlineList; InputLoc loc; #line 63 "klparse.cpp" }; struct Parser_Lel_opt_class { #line 140 "klparse.kl" bool isClass; #line 73 "klparse.cpp" }; struct Parser_Lel_opt_commit { #line 250 "klparse.kl" bool commit; #line 83 "klparse.cpp" }; struct Parser_Lel_opt_inline_block { #line 280 "klparse.kl" InlineBlock *inlineBlock; #line 93 "klparse.cpp" }; struct Parser_Lel_opt_prior { #line 265 "klparse.kl" int priorVal; #line 103 "klparse.cpp" }; struct Parser_Lel_prod_el { #line 232 "klparse.kl" Factor *factor; #line 113 "klparse.cpp" }; struct Parser_Lel_prod_el_list { #line 214 "klparse.kl" ProdElList *prodElList; #line 123 "klparse.cpp" }; union Parser_UserData { struct Parser_Lel_inline_block_item inline_block_item; struct Parser_Lel_inline_list inline_list; struct Parser_Lel_opt_class opt_class; struct Parser_Lel_opt_commit opt_commit; struct Parser_Lel_opt_inline_block opt_inline_block; struct Parser_Lel_opt_prior opt_prior; struct Parser_Lel_prod_el prod_el; struct Parser_Lel_prod_el_list prod_el_list; struct Token token; }; struct Parser_LangEl { char *file; int line; int type; int reduction; int state; int causeReduce; union Parser_UserData user; unsigned int retry; struct Parser_LangEl *next, *child, *prev; }; struct Parser_Block { struct Parser_LangEl data[8128]; struct Parser_Block *next; }; #line 160 "klparse.cpp" unsigned int Parser_startState = 0; char Parser_indicies[] = { 50, 50, -1, 50, -1, 50, 50, -1, -1, -1, -1, -1, 50, -1, 50, 1, 0, 93, 3, 4, -1, 5, -1, 7, 2, -1, -1, -1, -1, -1, 6, -1, 48, -1, -1, 49, 85, 86, 87, 88, 89, 90, 91, 92, 16, 83, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 83, 83, 11, -1, -1, 9, -1, -1, -1, 56, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 8, 55, -1, 10, 61, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 12, 61, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 14, 17, 15, 20, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 53, 61, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 19, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 21, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 18, 66, 24, 23, 25, 64, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 70, 70, 70, 70, -1, -1, -1, -1, -1, 70, -1, 70, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 51, 84, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 84, 84, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 27, 56, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 54, 81, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 29, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 28, 66, 31, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 32, 66, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 66, 73, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -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, 73, 73, 73, -1, -1, -1, -1, -1, 38, -1, 76, -1, -1, -1, -1, 76, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 34, -1, -1, -1, -1, -1, -1, -1, -1, -1, 69, 37, 57, 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 58, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 39, 66, 60, 59, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 63, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 77, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 42, 77, 77, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 41, 74, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 74, 74, -1, -1, -1, -1, -1, -1, -1, 74, -1, -1, -1, -1, 74, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 73, -1, -1, -1, -1, 73, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 43, 40, 82, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 44, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 22, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 45, 66, 71, -1, -1, -1, -1, 72, 75, 78, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 78, 78, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 67, 68, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 65, 81, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 30, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 47, 52, }; unsigned char Parser_keys[] = { 137, 153, 151, 151, 137, 162, 58, 58, 59, 171, 131, 170, 131, 170, 150, 150, 143, 143, 44, 59, 131, 170, 59, 166, 146, 173, 143, 143, 139, 139, 143, 143, 59, 59, 59, 163, 59, 59, 59, 173, 143, 143, 143, 169, 59, 167, 146, 173, 143, 143, 146, 173, 146, 173, 59, 175, 59, 59, 59, 173, 59, 59, 146, 173, 59, 59, 59, 173, 59, 173, 59, 165, 59, 148, 132, 164, 40, 40, 59, 173, 145, 145, 59, 166, 146, 173, 143, 148, 41, 41, 59, 173, 59, 167, 59, 59, 0, 0 }; unsigned short Parser_offsets[] = { 0, 17, 18, 44, 45, 158, 198, 238, 239, 240, 256, 296, 404, 432, 433, 434, 435, 436, 541, 542, 657, 658, 685, 794, 822, 823, 851, 879, 996, 997, 1112, 1113, 1141, 1142, 1257, 1372, 1479, 1569, 1602, 1603, 1718, 1719, 1827, 1855, 1861, 1862, 1977, 2086, 2087 }; unsigned char Parser_targs[] = { 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, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48 }; unsigned int Parser_actInds[] = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188 }; unsigned int Parser_actions[] = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 90, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 146, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 2, 0, 7, 0, 10, 0, 47, 0, 51, 0, 55, 0, 59, 0, 63, 0, 67, 0, 71, 0, 75, 0, 79, 0, 83, 0, 87, 0, 90, 0, 95, 0, 99, 0, 103, 0, 107, 0, 111, 0, 115, 0, 119, 0, 122, 0, 127, 0, 131, 0, 134, 0, 138, 0, 143, 0, 146, 0, 150, 0, 154, 0, 158, 0, 162, 0, 166, 0, 170, 0, 174, 0, 178, 0, 15, 0, 19, 0, 23, 0, 27, 0, 31, 0, 35, 0, 39, 0, 43, 0, 1, 0 }; int Parser_commitLen[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2 }; char Parser_prodLengths[] = { 1, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 3, 8, 3, 3, 1, 1, 5, 5, 5, 5, 1, 0, 5, 3, 2, 1, 1, 1, 2, 0, 3, 3, 0, 1, 4, 0, 0, 2, 0, 2, 0, 2, 0, 2, 1 }; unsigned char Parser_prodLhsIds[] = { 153, 152, 152, 154, 154, 154, 154, 154, 154, 154, 154, 161, 155, 156, 168, 168, 169, 157, 158, 159, 159, 170, 170, 160, 162, 172, 172, 173, 173, 163, 163, 174, 174, 164, 164, 175, 175, 165, 165, 166, 166, 167, 167, 171, 171, 176 }; const char *Parser_prodNames[] = { "start-1", "statement_list-1", "statement_list-2", "statement-1", "statement-2", "statement-3", "statement-4", "statement-5", "statement-6", "statement-7", "statement-8", "access_stmt-1", "production_stmt-1", "token_stmt-1", "token_list-1", "token_list-2", "token_list_word-1", "token_uses_stmt-1", "translate_stmt-1", "nonterm_stmt-1", "nonterm_stmt-2", "opt_class-1", "opt_class-2", "type_stmt-1", "shortest_stmt-1", "inline_list-1", "inline_list-2", "inline_block_item-1", "inline_block_item-2", "prod_el_list-1", "prod_el_list-2", "prod_el-1", "prod_el-2", "opt_commit-1", "opt_commit-2", "opt_prior-1", "opt_prior-2", "opt_reduction-1", "opt_reduction-2", "opt_undo-1", "opt_undo-2", "opt_final-1", "opt_final-2", "opt_translate-1", "opt_translate-2", "_start-1" }; const char *Parser_lelNames[] = { "D-0", "D-1", "D-2", "D-3", "D-4", "D-5", "D-6", "D-7", "D-8", "D-9", "D-10", "D-11", "D-12", "D-13", "D-14", "D-15", "D-16", "D-17", "D-18", "D-19", "D-20", "D-21", "D-22", "D-23", "D-24", "D-25", "D-26", "D-27", "D-28", "D-29", "D-30", "D-31", "D-32", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", "@", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "[", "\\", "]", "^", "_", "`", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "{", "|", "}", "~", "D-127", "KW_Parser", "KW_Include", "KW_Write", "KW_Class", "KW_Commit", "KW_Try", "KW_Undo", "KW_Final", "KW_Translate", "KW_Token", "KW_NonTerm", "KW_Uses", "KW_Type", "KW_Pri", "KW_Shortest", "TK_Word", "TK_String", "TK_Number", "TK_Inline", "TK_Reference", "TK_Literal", "KW_Access", "TK_AccessData", "Parser_tk_eof", "statement_list", "start", "statement", "production_stmt", "token_stmt", "token_uses_stmt", "translate_stmt", "nonterm_stmt", "type_stmt", "access_stmt", "shortest_stmt", "prod_el_list", "opt_commit", "opt_reduction", "opt_undo", "opt_final", "token_list", "token_list_word", "opt_class", "opt_translate", "inline_list", "inline_block_item", "prod_el", "opt_prior", "_start" }; #line 323 "klparse.kl" void Parser::init() { #line 777 "klparse.cpp" curs = Parser_startState; pool = 0; block = (struct Parser_Block*) malloc( sizeof(struct Parser_Block) ); block->next = 0; freshEl = block->data; #ifdef KELBT_LOG_ACTIONS cerr << "allocating 8128 LangEls" << endl; #endif stackTop = freshEl; stackTop->type = 0; stackTop->state = -1; stackTop->next = 0; stackTop->child = 0; stackTop->causeReduce = 0; freshPos = 1; lastFinal = stackTop; numRetry = 0; numNodes = 0; errCount = 0; #line 328 "klparse.kl" } TypeDef *Parser::getTypeDef( char *data ) { TypeDefMapEl *inMap = 0, *inserted; inserted = pd.typeDefMap.insert( data, &inMap ); if ( inserted != 0 ) inserted->value = new TypeDef( data ); return inMap->value; } int Parser::parseLangEl( int type, const Token *token ) { #line 811 "klparse.cpp" #define reject() induceReject = 1 int pos, targState; unsigned int *action; int rhsLen; struct Parser_LangEl *rhs[32]; struct Parser_LangEl *lel = 0; struct Parser_LangEl *input = 0; struct Parser_LangEl *queue = 0; char induceReject; if ( curs < 0 ) return 0; if ( pool == 0 ) { if ( freshPos == 8128 ) { struct Parser_Block* newBlock = (struct Parser_Block*) malloc( sizeof(struct Parser_Block) ); newBlock->next = block; block = newBlock; freshEl = newBlock->data; #ifdef KELBT_LOG_ACTIONS cerr << "allocating 8128 LangEls" << endl; #endif freshPos = 0; } queue = freshEl + freshPos++; } else { queue = pool; pool = pool->next; } numNodes += 1; queue->type = type; queue->user.token = *token; queue->next = 0; queue->retry = 0; queue->child = 0; queue->causeReduce = 0; again: if ( input == 0 ) { if ( queue == 0 ) goto _out; input = queue; queue = queue->next; input->next = 0; } lel = input; if ( lel->type < Parser_keys[curs<<1] || lel->type > Parser_keys[(curs<<1)+1] ) goto parseError; pos = Parser_indicies[Parser_offsets[curs] + (lel->type - Parser_keys[curs<<1])]; if ( pos < 0 ) goto parseError; induceReject = 0; targState = Parser_targs[pos]; action = Parser_actions + Parser_actInds[pos]; if ( lel->retry & 0x0000ffff ) action += (lel->retry & 0x0000ffff); if ( *action & 0x1 ) { #ifdef KELBT_LOG_ACTIONS cerr << "shifted: " << Parser_lelNames[lel->type]; #endif input = input->next; lel->state = curs; lel->next = stackTop; stackTop = lel; if ( action[1] == 0 ) lel->retry &= 0xffff0000; else { lel->retry += 1; numRetry += 1; #ifdef KELBT_LOG_ACTIONS cerr << " retry: " << stackTop; #endif } #ifdef KELBT_LOG_ACTIONS cerr << endl; #endif } if ( Parser_commitLen[pos] != 0 ) { struct Parser_LangEl *commitHead = stackTop, *lel; int sp = 0, doExec = 0; #ifdef KELBT_LOG_ACTIONS cerr << "commit encountered, executing final actions" << endl; #endif if ( Parser_commitLen[pos] < 0 ) commitHead = commitHead->next; lel = commitHead; commit_head: if ( lel == lastFinal ) { doExec = 1; goto commit_base; } if ( lel->next != 0 ) { sp += 1; lel->next->prev = lel; lel = lel->next; lel->retry = 0; goto commit_head; } commit_reverse: if ( lel->child != 0 ) { sp += 1; lel->child->prev = lel; lel = lel->child; lel->retry = 1; goto commit_head; } commit_upwards: if ( doExec ) { if ( lel->type < 152 ) { } else { struct Parser_LangEl *redLel = lel; if ( redLel->child != 0 ) { int r = Parser_prodLengths[redLel->reduction] - 1; struct Parser_LangEl *rhsEl = redLel->child; while ( rhsEl != 0 ) { rhs[r--] = rhsEl; rhsEl = rhsEl->next; } } switch ( lel->reduction ) { case 11: { Token *__ref0 = (Token*)&rhs[1]->user.token; #line 52 "klparse.kl" pd.access = (__ref0)->data; #line 955 "klparse.cpp" } break; case 12: { Token *__ref0 = (Token*)&rhs[0]->user.token; Token *__ref1 = (Token*)&rhs[0]->user.token; Token *__ref2 = (Token*)&rhs[0]->user.token; Token *__ref3 = (Token*)&rhs[0]->user.token; Parser_Lel_prod_el_list *__ref4 = (Parser_Lel_prod_el_list*)&rhs[2]->user.prod_el_list; Parser_Lel_opt_commit *__ref5 = (Parser_Lel_opt_commit*)&rhs[3]->user.opt_commit; Parser_Lel_opt_inline_block *__ref6 = (Parser_Lel_opt_inline_block*)&rhs[4]->user.opt_inline_block; Parser_Lel_opt_inline_block *__ref7 = (Parser_Lel_opt_inline_block*)&rhs[5]->user.opt_inline_block; Parser_Lel_opt_inline_block *__ref8 = (Parser_Lel_opt_inline_block*)&rhs[6]->user.opt_inline_block; Token *__ref9 = (Token*)&rhs[0]->user.token; #line 59 "klparse.kl" /* Get the language element. */ KlangEl *prodName = getKlangEl( &pd, (__ref0)->data, KlangEl::NonTerm ); /* Check that the element wasn't previously defined as something else. */ if ( prodName->type != KlangEl::Unknown && prodName->type != KlangEl::NonTerm ) { error((__ref1)->loc) << "'" << (__ref2)->data << "' already defined as something else" << endl; } else { prodName->type = KlangEl::NonTerm; Definition *newDef = new Definition( (__ref3)->loc, prodName, (__ref4)->prodElList, (__ref5)->commit, (__ref6)->inlineBlock, (__ref7)->inlineBlock, (__ref8)->inlineBlock, pd.prodList.length(), Definition::Production ); prodName->defList.append( newDef ); pd.prodList.append( newDef ); /* Start machine will trigger code generation. */ if ( strcmp((__ref9)->data, startDefName) == 0 ) sawStart = true; newDef->rhsLelVect = langElVect; newDef->rhsFactorVect = factorVect; langElVect.empty(); factorVect.empty(); } #line 998 "klparse.cpp" } break; case 16: { Token *__ref0 = (Token*)&rhs[0]->user.token; Token *__ref1 = (Token*)&rhs[0]->user.token; Token *__ref2 = (Token*)&rhs[0]->user.token; #line 94 "klparse.kl" /* Token name must be unique. */ KlangEl *tokName = getKlangEl( &pd, (__ref0)->data, KlangEl::Term ); if ( tokName->type != KlangEl::Unknown && tokName->type != KlangEl::Term ) error((__ref1)->loc) << "'" << (__ref2) << "' already defined as something else" << endl; tokName->type = KlangEl::Term; #line 1013 "klparse.cpp" } break; case 17: { Token *__ref0 = (Token*)&rhs[3]->user.token; Parser_Lel_opt_class *__ref1 = (Parser_Lel_opt_class*)&rhs[2]->user.opt_class; #line 103 "klparse.kl" pd.tokenStruct = (__ref0)->data; pd.tokenIsClass = (__ref1)->isClass; #line 1024 "klparse.cpp" } break; case 18: { Parser_Lel_opt_inline_block *__ref0 = (Parser_Lel_opt_inline_block*)&rhs[1]->user.opt_inline_block; Parser_Lel_opt_inline_block *__ref1 = (Parser_Lel_opt_inline_block*)&rhs[2]->user.opt_inline_block; Parser_Lel_opt_inline_block *__ref2 = (Parser_Lel_opt_inline_block*)&rhs[3]->user.opt_inline_block; #line 110 "klparse.kl" pd.translateBlock = (__ref0)->inlineBlock; pd.undoTransBlock = (__ref1)->inlineBlock; pd.tokenFinalBlock = (__ref2)->inlineBlock; #line 1037 "klparse.cpp" } break; case 19: { Token *__ref0 = (Token*)&rhs[2]->user.token; Token *__ref1 = (Token*)&rhs[2]->user.token; Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&rhs[3]->user.inline_list; Token *__ref3 = (Token*)&rhs[2]->user.token; Token *__ref4 = (Token*)&rhs[2]->user.token; Token *__ref5 = (Token*)&rhs[2]->user.token; Parser_Lel_opt_class *__ref6 = (Parser_Lel_opt_class*)&rhs[1]->user.opt_class; #line 118 "klparse.kl" /* Create/get the nonterminal. */ KlangEl *nonTerm = getKlangEl( &pd, (__ref0)->data, KlangEl::NonTerm ); /* Make a new inline block. */ InlineBlock *typeBlock = new InlineBlock( (__ref1)->loc, (__ref2)->inlineList ); /* Create/get the typedef. */ TypeDef *typeDef = getTypeDef( (__ref3)->data ); nonTerm->typeDef = typeDef; /* The typeDef should not already exist. */ if ( typeDef->typeBlock != 0 ) error((__ref4)->loc) << "redefintion of nonterminal type " << (__ref5)->data << endl; else { typeDef->typeBlock = typeBlock; typeDef->isClass = (__ref6)->isClass; } #line 1068 "klparse.cpp" } break; case 20: { Token *__ref0 = (Token*)&rhs[1]->user.token; Token *__ref1 = (Token*)&rhs[3]->user.token; #line 140 "klparse.kl" KlangEl *nonTerm = getKlangEl( &pd, (__ref0)->data, KlangEl::NonTerm ); nonTerm->typeDef = getTypeDef( (__ref1)->data ); #line 1079 "klparse.cpp" } break; case 21: { Parser_Lel_opt_class *__ref0 = (Parser_Lel_opt_class*)&redLel->user.opt_class; #line 150 "klparse.kl" (__ref0)->isClass = true; #line 1086 "klparse.cpp" } break; case 22: { Parser_Lel_opt_class *__ref0 = (Parser_Lel_opt_class*)&redLel->user.opt_class; #line 151 "klparse.kl" (__ref0)->isClass = false; #line 1093 "klparse.cpp" } break; case 23: { Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&rhs[3]->user.inline_list; Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[3]->user.inline_list; Token *__ref2 = (Token*)&rhs[2]->user.token; Token *__ref3 = (Token*)&rhs[2]->user.token; Token *__ref4 = (Token*)&rhs[2]->user.token; Parser_Lel_opt_class *__ref5 = (Parser_Lel_opt_class*)&rhs[1]->user.opt_class; #line 155 "klparse.kl" /* Create the inline block and create/get the typedef. */ InlineBlock *typeBlock = new InlineBlock( InputLoc((__ref0)->loc), (__ref1)->inlineList ); TypeDef *typeDef = getTypeDef( (__ref2)->data ); /* The typeDef should not already exist. */ if ( typeDef->typeBlock != 0 ) error((__ref3)->loc) << "redefintion of nonterminal type " << (__ref4)->data << endl; else { typeDef->typeBlock = typeBlock; typeDef->isClass = (__ref5)->isClass; } #line 1117 "klparse.cpp" } break; case 24: { Token *__ref0 = (Token*)&rhs[1]->user.token; #line 171 "klparse.kl" KlangEl *nonTerm = getKlangEl( &pd, (__ref0)->data, KlangEl::NonTerm ); nonTerm->isShortest = true; #line 1127 "klparse.cpp" } break; case 25: { Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&rhs[0]->user.inline_list; Parser_Lel_inline_block_item *__ref1 = (Parser_Lel_inline_block_item*)&rhs[1]->user.inline_block_item; Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&redLel->user.inline_list; Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&rhs[0]->user.inline_list; Parser_Lel_inline_list *__ref4 = (Parser_Lel_inline_list*)&redLel->user.inline_list; Parser_Lel_inline_list *__ref5 = (Parser_Lel_inline_list*)&rhs[0]->user.inline_list; #line 185 "klparse.kl" (__ref0)->inlineList->append( (__ref1)->inlineItem ); (__ref2)->inlineList = (__ref3)->inlineList; (__ref4)->loc = (__ref5)->loc; #line 1143 "klparse.cpp" } break; case 26: { Parser_Lel_inline_list *__ref0 = (Parser_Lel_inline_list*)&redLel->user.inline_list; Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&redLel->user.inline_list; Parser_Lel_inline_block_item *__ref2 = (Parser_Lel_inline_block_item*)&rhs[0]->user.inline_block_item; Parser_Lel_inline_list *__ref3 = (Parser_Lel_inline_list*)&redLel->user.inline_list; Parser_Lel_inline_block_item *__ref4 = (Parser_Lel_inline_block_item*)&rhs[0]->user.inline_block_item; #line 193 "klparse.kl" (__ref0)->inlineList = new InlineList; (__ref1)->inlineList->append( (__ref2)->inlineItem ); (__ref3)->loc = (__ref4)->loc; #line 1158 "klparse.cpp" } break; case 27: { Parser_Lel_inline_block_item *__ref0 = (Parser_Lel_inline_block_item*)&redLel->user.inline_block_item; Token *__ref1 = (Token*)&rhs[0]->user.token; Token *__ref2 = (Token*)&rhs[0]->user.token; Parser_Lel_inline_block_item *__ref3 = (Parser_Lel_inline_block_item*)&redLel->user.inline_block_item; Token *__ref4 = (Token*)&rhs[0]->user.token; #line 207 "klparse.kl" (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, (__ref2)->data, InlineItem::Text ); (__ref3)->loc = (__ref4)->loc; #line 1172 "klparse.cpp" } break; case 28: { Parser_Lel_inline_block_item *__ref0 = (Parser_Lel_inline_block_item*)&redLel->user.inline_block_item; Token *__ref1 = (Token*)&rhs[0]->user.token; Token *__ref2 = (Token*)&rhs[0]->user.token; Parser_Lel_inline_block_item *__ref3 = (Parser_Lel_inline_block_item*)&redLel->user.inline_block_item; Token *__ref4 = (Token*)&rhs[0]->user.token; #line 214 "klparse.kl" (__ref0)->inlineItem = new InlineItem( (__ref1)->loc, (__ref2)->data, InlineItem::Reference ); (__ref3)->loc = (__ref4)->loc; #line 1186 "klparse.cpp" } break; case 29: { Parser_Lel_prod_el_list *__ref0 = (Parser_Lel_prod_el_list*)&rhs[0]->user.prod_el_list; Parser_Lel_prod_el *__ref1 = (Parser_Lel_prod_el*)&rhs[1]->user.prod_el; Parser_Lel_prod_el_list *__ref2 = (Parser_Lel_prod_el_list*)&redLel->user.prod_el_list; Parser_Lel_prod_el_list *__ref3 = (Parser_Lel_prod_el_list*)&rhs[0]->user.prod_el_list; #line 226 "klparse.kl" (__ref0)->prodElList->append( (__ref1)->factor ); (__ref2)->prodElList = (__ref3)->prodElList; #line 1199 "klparse.cpp" } break; case 30: { Parser_Lel_prod_el_list *__ref0 = (Parser_Lel_prod_el_list*)&redLel->user.prod_el_list; #line 232 "klparse.kl" (__ref0)->prodElList = new ProdElList; #line 1206 "klparse.cpp" } break; case 31: { Token *__ref0 = (Token*)&rhs[2]->user.token; Parser_Lel_prod_el *__ref1 = (Parser_Lel_prod_el*)&redLel->user.prod_el; Token *__ref2 = (Token*)&rhs[2]->user.token; Parser_Lel_opt_commit *__ref3 = (Parser_Lel_opt_commit*)&rhs[1]->user.opt_commit; Parser_Lel_opt_prior *__ref4 = (Parser_Lel_opt_prior*)&rhs[0]->user.opt_prior; Parser_Lel_prod_el *__ref5 = (Parser_Lel_prod_el*)&redLel->user.prod_el; #line 241 "klparse.kl" KlangEl *langEl = getKlangEl( &pd, (__ref0)->data, KlangEl::Unknown ); (__ref1)->factor = new Factor( (__ref2)->loc, (__ref3)->commit, langEl, (__ref4)->priorVal ); langElVect.append( langEl ); factorVect.append( (__ref5)->factor ); #line 1223 "klparse.cpp" } break; case 32: { Token *__ref0 = (Token*)&rhs[2]->user.token; Token *__ref1 = (Token*)&rhs[2]->user.token; Parser_Lel_prod_el *__ref2 = (Parser_Lel_prod_el*)&redLel->user.prod_el; Token *__ref3 = (Token*)&rhs[2]->user.token; Parser_Lel_opt_commit *__ref4 = (Parser_Lel_opt_commit*)&rhs[1]->user.opt_commit; Parser_Lel_opt_prior *__ref5 = (Parser_Lel_opt_prior*)&rhs[0]->user.opt_prior; Parser_Lel_prod_el *__ref6 = (Parser_Lel_prod_el*)&redLel->user.prod_el; #line 250 "klparse.kl" /* Create a new factor node going to a concat literal. */ Literal *literal = new Literal( (__ref0)->loc, (__ref1)->data[0] ); (__ref2)->factor = new Factor( (__ref3)->loc, (__ref4)->commit, literal, (__ref5)->priorVal ); langElVect.append( 0 ); factorVect.append( (__ref6)->factor ); #line 1242 "klparse.cpp" } break; case 33: { Parser_Lel_opt_commit *__ref0 = (Parser_Lel_opt_commit*)&redLel->user.opt_commit; #line 264 "klparse.kl" (__ref0)->commit = false; #line 1249 "klparse.cpp" } break; case 34: { Parser_Lel_opt_commit *__ref0 = (Parser_Lel_opt_commit*)&redLel->user.opt_commit; #line 265 "klparse.kl" (__ref0)->commit = true; #line 1256 "klparse.cpp" } break; case 35: { Parser_Lel_opt_prior *__ref0 = (Parser_Lel_opt_prior*)&redLel->user.opt_prior; Token *__ref1 = (Token*)&rhs[2]->user.token; #line 273 "klparse.kl" (__ref0)->priorVal = atoi( (__ref1)->data ); #line 1266 "klparse.cpp" } break; case 36: { Parser_Lel_opt_prior *__ref0 = (Parser_Lel_opt_prior*)&redLel->user.opt_prior; #line 277 "klparse.kl" (__ref0)->priorVal = 0; #line 1273 "klparse.cpp" } break; case 37: { Parser_Lel_opt_inline_block *__ref0 = (Parser_Lel_opt_inline_block*)&redLel->user.opt_inline_block; #line 290 "klparse.kl" (__ref0)->inlineBlock = 0; #line 1280 "klparse.cpp" } break; case 38: { Parser_Lel_opt_inline_block *__ref0 = (Parser_Lel_opt_inline_block*)&redLel->user.opt_inline_block; Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; #line 293 "klparse.kl" (__ref0)->inlineBlock = new InlineBlock( (__ref1)->loc, (__ref2)->inlineList ); #line 1291 "klparse.cpp" } break; case 39: { Parser_Lel_opt_inline_block *__ref0 = (Parser_Lel_opt_inline_block*)&redLel->user.opt_inline_block; #line 297 "klparse.kl" (__ref0)->inlineBlock = 0; #line 1298 "klparse.cpp" } break; case 40: { Parser_Lel_opt_inline_block *__ref0 = (Parser_Lel_opt_inline_block*)&redLel->user.opt_inline_block; Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; #line 300 "klparse.kl" (__ref0)->inlineBlock = new InlineBlock( (__ref1)->loc, (__ref2)->inlineList ); #line 1309 "klparse.cpp" } break; case 41: { Parser_Lel_opt_inline_block *__ref0 = (Parser_Lel_opt_inline_block*)&redLel->user.opt_inline_block; #line 304 "klparse.kl" (__ref0)->inlineBlock = 0; #line 1316 "klparse.cpp" } break; case 42: { Parser_Lel_opt_inline_block *__ref0 = (Parser_Lel_opt_inline_block*)&redLel->user.opt_inline_block; Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; #line 307 "klparse.kl" (__ref0)->inlineBlock = new InlineBlock( (__ref1)->loc, (__ref2)->inlineList ); #line 1327 "klparse.cpp" } break; case 43: { Parser_Lel_opt_inline_block *__ref0 = (Parser_Lel_opt_inline_block*)&redLel->user.opt_inline_block; #line 311 "klparse.kl" (__ref0)->inlineBlock = 0; #line 1334 "klparse.cpp" } break; case 44: { Parser_Lel_opt_inline_block *__ref0 = (Parser_Lel_opt_inline_block*)&redLel->user.opt_inline_block; Parser_Lel_inline_list *__ref1 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; Parser_Lel_inline_list *__ref2 = (Parser_Lel_inline_list*)&rhs[1]->user.inline_list; #line 314 "klparse.kl" (__ref0)->inlineBlock = new InlineBlock( (__ref1)->loc, (__ref2)->inlineList ); #line 1345 "klparse.cpp" } break; } } if ( lel->child != 0 ) { struct Parser_LangEl *first = lel->child; struct Parser_LangEl *child = lel->child; lel->child = 0; while ( 1 ) { if ( child->type < 152 ) { } else { } numNodes -= 1; if ( child->next == 0 ) break; child = child->next; } child->next = pool; pool = first; } } commit_base: if ( sp > 0 ) { sp -= 1; if ( lel->retry == 0 ) { lel = lel->prev; goto commit_reverse; } else { lel->retry = 0; lel = lel->prev; goto commit_upwards; } } lel->retry = 0; lastFinal = lel; numRetry = 0; } if ( *action & 0x2 ) { int reduction = *action >> 2; struct Parser_LangEl *redLel; if ( input != 0 ) input->causeReduce += 1; if ( pool == 0 ) { if ( freshPos == 8128 ) { struct Parser_Block* newBlock = (struct Parser_Block*) malloc( sizeof(struct Parser_Block) ); newBlock->next = block; block = newBlock; freshEl = newBlock->data; #ifdef KELBT_LOG_ACTIONS cerr << "allocating 8128 LangEls" << endl; #endif freshPos = 0; } redLel = freshEl + freshPos++; } else { redLel = pool; pool = pool->next; } numNodes += 1; redLel->type = Parser_prodLhsIds[reduction]; redLel->reduction = reduction; redLel->child = 0; redLel->next = 0; redLel->retry = (lel->retry << 16); redLel->causeReduce = 0; lel->retry &= 0xffff0000; rhsLen = Parser_prodLengths[reduction]; if ( rhsLen > 0 ) { int r; for ( r = rhsLen-1; r > 0; r-- ) { rhs[r] = stackTop; stackTop = stackTop->next; } rhs[0] = stackTop; stackTop = stackTop->next; rhs[0]->next = 0; } #ifdef KELBT_LOG_ACTIONS cerr << "reduced: " << Parser_prodNames[reduction] << " rhsLen: " << rhsLen; #endif if ( action[1] == 0 ) redLel->retry = 0; else { redLel->retry += 0x10000; numRetry += 1; #ifdef KELBT_LOG_ACTIONS cerr << " retry: " << redLel; #endif } #ifdef KELBT_LOG_ACTIONS cerr << endl; #endif if ( rhsLen == 0 ) { redLel->file = lel->file; redLel->line = lel->line; targState = curs; } else { redLel->child = rhs[rhsLen-1]; redLel->file = rhs[0]->file; redLel->line = rhs[0]->line; targState = rhs[0]->state; } if ( induceReject ) { #ifdef KELBT_LOG_ACTIONS cerr << "error induced during reduction of " << Parser_lelNames[redLel->type] << endl; #endif redLel->state = curs; redLel->next = stackTop; stackTop = redLel; curs = targState; goto parseError; } else { redLel->next = input; input = redLel; } } curs = targState; goto again; parseError: #ifdef KELBT_LOG_BACKTRACK cerr << "hit error" << endl; #endif if ( numRetry > 0 ) { struct Parser_LangEl *redLel; if ( input != 0 ) { redLel = input; goto have_undo_element; } while ( 1 ) { redLel = stackTop; if ( stackTop->type < 152 ) { #ifdef KELBT_LOG_BACKTRACK cerr << "backing up over terminal: " << Parser_lelNames[stackTop->type] << endl; #endif stackTop = stackTop->next; redLel->next = input; input = redLel; } else { #ifdef KELBT_LOG_BACKTRACK cerr << "backing up over non-terminal: " << Parser_lelNames[stackTop->type] << endl; #endif stackTop = stackTop->next; struct Parser_LangEl *first = redLel->child; if ( first == 0 ) rhsLen = 0; else { rhsLen = 1; while ( first->next != 0 ) { first = first->next; rhsLen += 1; } first->next = stackTop; stackTop = redLel->child; struct Parser_LangEl *rhsEl = stackTop; int p = rhsLen; while ( p > 0 ) { rhs[--p] = rhsEl; rhsEl = rhsEl->next; } } redLel->next = pool; pool = redLel; numNodes -= 1; if ( input != 0 ) input->causeReduce -= 1; } have_undo_element: if ( redLel->retry == 0 ) { if ( input != 0 && input->causeReduce == 0 ) { #ifdef KELBT_LOG_BACKTRACK cerr << "pushing back: " << Parser_lelNames[input->type] << endl; #endif input->next = queue; queue = input; input = 0; } } else { #ifdef KELBT_LOG_BACKTRACK cerr << "found retry targ: " << redLel << endl; #endif numRetry -= 1; #ifdef KELBT_LOG_BACKTRACK cerr << "found retry: " << redLel << endl; #endif if ( redLel->retry & 0x0000ffff ) curs = input->state; else { input->retry = redLel->retry >> 16; if ( stackTop->state < 0 ) curs = Parser_startState; else { curs = Parser_targs[(int)Parser_indicies[Parser_offsets[stackTop->state] + (stackTop->type - Parser_keys[stackTop->state<<1])]]; } } goto again; } } } curs = -1; errCount += 1; _out: {} #line 342 "klparse.kl" return errCount == 0 ? 0 : -1; } int Parser::token( int line, int tokid, char *data ) { Token token; token.data = data; token.loc.line = line; token.loc.col = 1; //cout << "SENDING TOKEN: " << lelNames[tokid]; //if ( token.data != 0 ) // cout << " data: " << token.data; //cout << endl; return parseLangEl( tokid, &token ); } kelbt-0.16/src/klparse.kh0000664000175000017500000000363312471720163012250 00000000000000/* * Copyright 2006 Adrian Thurston */ /* This file is part of Kelbt. * * Kelbt 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. * * Kelbt 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 Kelbt; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef KLPARSE_H #define KLPARSE_H #include #include "avltree.h" #include "parsedata.h" struct LangEl; struct Token { char *data; InputLoc loc; }; struct Parser { %%{ parser Parser; token KW_Parser, KW_Include, KW_Write, KW_Class, KW_Commit, KW_Try, KW_Undo, KW_Final, KW_Translate, KW_Token, KW_NonTerm, KW_Uses, KW_Type, KW_Pri, KW_Shortest; token TK_Word, TK_String, TK_Number, TK_Inline, TK_Reference, TK_Literal, KW_Access, TK_AccessData; write instance_data; }%% Parser( const char *fileName, char *parserName, std::ostream &out ) : pd( fileName, parserName, out ), sawStart(false), sawInterface(false) {} void init(); int parseLangEl( int type, const Token *token ); int token( int line, int tokid, char *data ); TypeDef *getTypeDef( char *data ); ParseData pd; bool sawStart; bool sawInterface; KlangElVect langElVect; FactorVect factorVect; }; %% write token_defs; struct ParserDictEl : public AvlTreeEl { char *name; Parser *parser; char *getKey() const { return name; }; }; typedef AvlTree ParserDict; #endif kelbt-0.16/configure0000775000175000017500000041667512472121235011415 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.69 for kelbt 0.16. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # Use a proper internal environment variable to ensure we don't fall # into an infinite loop, continuously re-executing ourselves. if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then _as_can_reexec=no; export _as_can_reexec; # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 as_fn_exit 255 fi # We don't want this to propagate to other subprocesses. { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1 test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : export CONFIG_SHELL # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} # Admittedly, this is quite paranoid, since all the known shells bail # out after a failed `exec'. $as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 exit 255 fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # If we had to re-execute with $CONFIG_SHELL, we're ensured to have # already done that, so ensure we don't try to do so again and fall # in an infinite loop. This has already happened in practice. _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME='kelbt' PACKAGE_TARNAME='kelbt' PACKAGE_VERSION='0.16' PACKAGE_STRING='kelbt 0.16' PACKAGE_BUGREPORT='' PACKAGE_URL='' ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS am__fastdepCXX_FALSE am__fastdepCXX_TRUE CXXDEPMODE am__nodep AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CXX CPPFLAGS LDFLAGS CXXFLAGS CXX KELBT RAGEL BUILD_PARSERS_FALSE BUILD_PARSERS_TRUE PUBDATE AM_BACKSLASH AM_DEFAULT_VERBOSITY AM_DEFAULT_V AM_V am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_silent_rules enable_dependency_tracking ' ac_precious_vars='build_alias host_alias target_alias CXX CXXFLAGS LDFLAGS LIBS CPPFLAGS CCC' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures kelbt 0.16 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/kelbt] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names _ACEOF fi if test -n "$ac_init_help"; then case $ac_init_help in short | recursive ) echo "Configuration of kelbt 0.16:";; esac cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-silent-rules less verbose build output (undo: "make V=1") --disable-silent-rules verbose build output (undo: "make V=0") --enable-dependency-tracking do not reject slow dependency extractors --disable-dependency-tracking speeds up one-time build Some influential environment variables: CXX C++ compiler command CXXFLAGS C++ compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF kelbt configure 0.16 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_cxx_try_compile LINENO # ---------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_cxx_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_cxx_try_compile cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by kelbt $as_me 0.16, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu PUBDATE="February 2015" am__api_version='1.14' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi if test "$2" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi rm -f conftest.file test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # Check whether --enable-silent-rules was given. if test "${enable_silent_rules+set}" = set; then : enableval=$enable_silent_rules; fi case $enable_silent_rules in # ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=1;; esac am_make=${MAKE-make} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5 $as_echo_n "checking whether $am_make supports nested variables... " >&6; } if ${am_cv_make_support_nested_variables+:} false; then : $as_echo_n "(cached) " >&6 else if $as_echo 'TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5 $as_echo "$am_cv_make_support_nested_variables" >&6; } if test $am_cv_make_support_nested_variables = yes; then AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AM_BACKSLASH='\' if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE='kelbt' VERSION='0.16' cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # mkdir_p='$(MKDIR_P)' # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AMTAR='$${TAR-tar}' # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar pax cpio none' am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -' # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 fi fi ac_config_headers="$ac_config_headers src/config.h" : ${CFLAGS="-Wall -g"} : ${CXXFLAGS="-Wall -g"} if test -r $srcdir/DIST; then : . $srcdir/DIST else build_parsers=yes; fi if test "x$build_parsers" = "xyes"; then BUILD_PARSERS_TRUE= BUILD_PARSERS_FALSE='#' else BUILD_PARSERS_TRUE='#' BUILD_PARSERS_FALSE= fi if test "x$build_parsers" = "xyes"; then # Extract the first word of "ragel", so it can be a program name with args. set dummy ragel; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RAGEL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RAGEL"; then ac_cv_prog_RAGEL="$RAGEL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RAGEL="ragel" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RAGEL=$ac_cv_prog_RAGEL if test -n "$RAGEL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RAGEL" >&5 $as_echo "$RAGEL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$RAGEL"; then echo echo "error: ragel is required to build the parsers" echo exit 1 fi # Extract the first word of "kelbt", so it can be a program name with args. set dummy kelbt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_KELBT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$KELBT"; then ac_cv_prog_KELBT="$KELBT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_KELBT="kelbt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi KELBT=$ac_cv_prog_KELBT if test -n "$KELBT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $KELBT" >&5 $as_echo "$KELBT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$KELBT"; then echo echo "error: kelbt is required to build the parsers" echo exit 1 fi fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5 $as_echo "$CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CXX+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5 $as_echo "$ac_ct_CXX" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5 $as_echo_n "checking whether the C++ compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C++ compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5 $as_echo_n "checking for C++ compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C++ compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5 $as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; } if ${ac_cv_cxx_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5 $as_echo "$ac_cv_cxx_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GXX=yes else GXX= fi ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5 $as_echo_n "checking whether $CXX accepts -g... " >&6; } if ${ac_cv_prog_cxx_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes else CXXFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : else ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : ac_cv_prog_cxx_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5 $as_echo "$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CXX" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CXX_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5 $as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi ac_config_files="$ac_config_files Makefile src/Makefile aapl/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs { $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5 $as_echo_n "checking that generated files are newer than configure... " >&6; } if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5 $as_echo "done" >&6; } if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${BUILD_PARSERS_TRUE}" && test -z "${BUILD_PARSERS_FALSE}"; then as_fn_error $? "conditional \"BUILD_PARSERS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -pR' fi else as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi # as_fn_executable_p FILE # ----------------------- # Test if FILE is an executable regular file. as_fn_executable_p () { test -f "$1" && test -x "$1" } # as_fn_executable_p as_test_x='test -x' as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by kelbt $as_me 0.16, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ kelbt config.status 0.16 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "aapl/Makefile") CONFIG_FILES="$CONFIG_FILES aapl/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi echo "configuration of kelbt complete" kelbt-0.16/aapl/0000775000175000017500000000000012603513714010463 500000000000000kelbt-0.16/aapl/Makefile.in0000664000175000017500000003205112472121235012446 00000000000000# Makefile.in generated by automake 1.14.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994-2013 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ 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@ pkgincludedir = $(includedir)/@PACKAGE@ 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 = : subdir = aapl DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(noinst_HEADERS) COPYING README 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)/src/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false am__v_P_1 = : AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; am__v_GEN_1 = AM_V_at = $(am__v_at_@AM_V@) am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) am__v_at_0 = @ am__v_at_1 = SOURCES = DIST_SOURCES = 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@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EXEEXT = @EXEEXT@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ KELBT = @KELBT@ LDFLAGS = @LDFLAGS@ 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@ PUBDATE = @PUBDATE@ RAGEL = @RAGEL@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CXX = @ac_ct_CXX@ 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@ noinst_HEADERS = \ avlbasic.h avlimel.h avlmap.h bstcommon.h compare.h insertsort.h \ sbstset.h avlcommon.h avlimelkey.h avlmel.h bstmap.h dlcommon.h \ mergesort.h sbsttable.h avlibasic.h avliset.h avlmelkey.h bstset.h \ dlist.h quicksort.h svector.h avlikeyless.h avlitree.h avlset.h \ bsttable.h dlistmel.h resize.h table.h avlimap.h avlkeyless.h avltree.h \ bubblesort.h dlistval.h sbstmap.h vector.h EXTRA_DIST = README COPYING all: all-am .SUFFIXES: $(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) --foreign aapl/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --foreign aapl/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): ID: $(am__tagged_files) $(am__define_uniq_tagged_files); mkid -fID $$unique tags: tags-am TAGS: tags tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) set x; \ here=`pwd`; \ $(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 GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @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 \ 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" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(HEADERS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 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: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: 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 -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ cscopelist-am ctags ctags-am distclean distclean-generic \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am 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-generic pdf pdf-am ps ps-am tags tags-am uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: kelbt-0.16/aapl/dlcommon.h0000664000175000017500000005304612471662307012402 00000000000000/* * Copyright 2001 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* This header is not wrapped in ifndef becuase it is not intended to * be included by the user. */ #ifdef AAPL_NAMESPACE namespace Aapl { #endif #if defined( DOUBLELIST_VALUE ) /** * \brief Double list element for DListVal. * * DListValEl stores the type T of DListVal by value. */ template struct DListValEl { /** * \brief Construct a DListValEl with a given value. * * The only constructor available initializes the value element. This * enforces that DListVal elements are never created without having their * value intialzed by the user. T's copy constructor is used to copy the * value in. */ DListValEl( const T &val ) : value(val) { } /** * \brief Value stored by the list element. * * Value is always copied into new list elements using the copy * constructor. */ T value; /** * \brief List previous pointer. * * Points to the previous item in the list. If this is the first item in * the list, then prev is NULL. If this element is not in a list then * prev is undefined. */ DListValEl *prev; /** * \brief List next pointer. * * Points to the next item in the list. If this is the list item in the * list, then next is NULL. If this element is not in a list then next is * undefined. */ DListValEl *next; }; #else #ifndef __AAPL_DOUBLE_LIST_EL #define __AAPL_DOUBLE_LIST_EL /** * \brief Double list element properties. * * This class can be inherited to make a class suitable to be a double list * element. It simply provides the next and previous pointers. An alternative * is to put the next and previous pointers in the class directly. */ template struct DListEl { /** * \brief List previous pointer. * * Points to the previous item in the list. If this is the first item in * the list, then prev is NULL. If this element is not in a list then * prev is undefined. */ Element *prev; /** * \brief List next pointer. * * Points to the next item in the list. If this is the list item in the * list, then next is NULL. If this element is not in a list then next is * undefined. */ Element *next; }; #endif /* __AAPL_DOUBLE_LIST_EL */ #endif /* Doubly Linked List */ template class DList { public: /** \brief Initialize an empty list. */ DList() : head(0), tail(0), listLen(0) {} /** * \brief Perform a deep copy of the list. * * The elements of the other list are duplicated and put into this list. * Elements are copied using the copy constructor. */ DList(const DList &other); #ifdef DOUBLELIST_VALUE /** * \brief Clear the double list contents. * * All elements are deleted. */ ~DList() { empty(); } /** * \brief Assign another list into this list using a deep copy. * * The elements of the other list are duplicated and put into this list. * Each list item is created using the copy constructor. If this list * contains any elements before the copy, they are deleted first. * * \returns A reference to this. */ DList &operator=(const DList &other); /** * \brief Transfer the contents of another list into this list. * * The elements of the other list moved in. The other list will be empty * afterwards. If this list contains any elements before the copy, then * they are deleted. */ void transfer(DList &other); #else /** * \brief Abandon all elements in the list. * * List elements are not deleted. */ ~DList() {} /** * \brief Perform a deep copy of the list. * * The elements of the other list are duplicated and put into this list. * Each list item is created using the copy constructor. If this list * contains any elements before the copy, they are abandoned. * * \returns A reference to this. */ DList &operator=(const DList &other); /** * \brief Transfer the contents of another list into this list. * * The elements of the other list moved in. The other list will be empty * afterwards. If this list contains any elements before the copy, they * are abandoned. */ void transfer(DList &other); #endif #ifdef DOUBLELIST_VALUE /** * \brief Make a new element and prepend it to the front of the list. * * The item is copied into the new element using the copy constructor. * Equivalent to list.addBefore(list.head, item). */ void prepend(const T &item); /** * \brief Make a new element and append it to the end of the list. * * The item is copied into the new element using the copy constructor. * Equivalent to list.addAfter(list.tail, item). */ void append(const T &item); /** * \brief Make a new element and insert it immediately after an element in * the list. * * The item is copied into the new element using the copy constructor. If * prev_el is NULL then the new element is prepended to the front of the * list. If prev_el is not already in the list then undefined behaviour * results. Equivalent to list.addAfter(prev_el, new DListValEl(item)). */ void addAfter(Element *prev_el, const T &item); /** * \brief Make a new element and insert it immediately before an element * in the list. * * The item is copied into the new element using the copy construcotor. If * next_el is NULL then the new element is appended to the end of the * list. If next_el is not already in the list then undefined behaviour * results. Equivalent to list.addBefore(next_el, new DListValEl(item)). */ void addBefore(Element *next_el, const T &item); #endif /** * \brief Prepend a single element to the front of the list. * * If new_el is already an element of some list, then undefined behaviour * results. Equivalent to list.addBefore(list.head, new_el). */ void prepend(Element *new_el) { addBefore(head, new_el); } /** * \brief Append a single element to the end of the list. * * If new_el is alreay an element of some list, then undefined behaviour * results. Equivalent to list.addAfter(list.tail, new_el). */ void append(Element *new_el) { addAfter(tail, new_el); } /** * \brief Prepend an entire list to the beginning of this list. * * All items are moved, not copied. Afterwards, the other list is emtpy. * All items are prepended at once, so this is an O(1) operation. * Equivalent to list.addBefore(list.head, dl). */ void prepend(DList &dl) { addBefore(head, dl); } /** * \brief Append an entire list to the end of the list. * * All items are moved, not copied. Afterwards, the other list is empty. * All items are appened at once, so this is an O(1) operation. * Equivalent to list.addAfter(list.tail, dl). */ void append(DList &dl) { addAfter(tail, dl); } void addAfter(Element *prev_el, Element *new_el); void addBefore(Element *next_el, Element *new_el); void addAfter(Element *prev_el, DList &dl); void addBefore(Element *next_el, DList &dl); /** * \brief Detach the head of the list * * The element detached is not deleted. If there is no head of the list * (the list is empty) then undefined behaviour results. Equivalent to * list.detach(list.head). * * \returns The element detached. */ Element *detachFirst() { return detach(head); } /** * \brief Detach the tail of the list * * The element detached is not deleted. If there is no tail of the list * (the list is empty) then undefined behaviour results. Equivalent to * list.detach(list.tail). * * \returns The element detached. */ Element *detachLast() { return detach(tail); } /* Detaches an element from the list. Does not free any memory. */ Element *detach(Element *el); /** * \brief Detach and delete the first element in the list. * * If there is no first element (the list is empty) then undefined * behaviour results. Equivalent to delete list.detach(list.head); */ void removeFirst() { delete detach( head ); } /** * \brief Detach and delete the last element in the list. * * If there is no last element (the list is emtpy) then undefined * behaviour results. Equivalent to delete list.detach(list.tail); */ void removeLast() { delete detach( tail ); } /** * \brief Detach and delete an element from the list. * * If the element is not in the list, then undefined behaviour results. * Equivalent to delete list.detach(el); */ void remove(Element *el) { delete detach( el ); } void empty(); void abandon(); /** \brief The number of elements in the list. */ long length() const { return listLen; } /** \brief Head and tail of the linked list. */ Element *head, *tail; /** \brief The number of element in the list. */ long listLen; /* Convenience access. */ long size() const { return listLen; } /* Forward this so a ref can be used. */ struct Iter; /* Class for setting the iterator. */ struct IterFirst { IterFirst( const DList &l ) : l(l) { } const DList &l; }; struct IterLast { IterLast( const DList &l ) : l(l) { } const DList &l; }; struct IterNext { IterNext( const Iter &i ) : i(i) { } const Iter &i; }; struct IterPrev { IterPrev( const Iter &i ) : i(i) { } const Iter &i; }; /** * \brief Double List Iterator. * \ingroup iterators */ struct Iter { /* Default construct. */ Iter() : ptr(0) { } /* Construct from a double list. */ Iter( const DList &dl ) : ptr(dl.head) { } Iter( Element *el ) : ptr(el) { } Iter( const IterFirst &dlf ) : ptr(dlf.l.head) { } Iter( const IterLast &dll ) : ptr(dll.l.tail) { } Iter( const IterNext &dln ) : ptr(dln.i.ptr->BASE_EL(next)) { } Iter( const IterPrev &dlp ) : ptr(dlp.i.ptr->BASE_EL(prev)) { } /* Assign from a double list. */ Iter &operator=( const DList &dl ) { ptr = dl.head; return *this; } Iter &operator=( Element *el ) { ptr = el; return *this; } Iter &operator=( const IterFirst &af ) { ptr = af.l.head; return *this; } Iter &operator=( const IterLast &al ) { ptr = al.l.tail; return *this; } Iter &operator=( const IterNext &an ) { ptr = an.i.ptr->BASE_EL(next); return *this; } Iter &operator=( const IterPrev &ap ) { ptr = ap.i.ptr->BASE_EL(prev); return *this; } /** \brief Less than end? */ bool lte() const { return ptr != 0; } /** \brief At end? */ bool end() const { return ptr == 0; } /** \brief Greater than beginning? */ bool gtb() const { return ptr != 0; } /** \brief At beginning? */ bool beg() const { return ptr == 0; } /** \brief At first element? */ bool first() const { return ptr && ptr->BASE_EL(prev) == 0; } /** \brief At last element? */ bool last() const { return ptr && ptr->BASE_EL(next) == 0; } /** \brief Implicit cast to Element*. */ operator Element*() const { return ptr; } /** \brief Dereference operator returns Element&. */ Element &operator *() const { return *ptr; } /** \brief Arrow operator returns Element*. */ Element *operator->() const { return ptr; } /** \brief Move to next item. */ inline Element *operator++() { return ptr = ptr->BASE_EL(next); } /** \brief Move to next item. */ inline Element *increment() { return ptr = ptr->BASE_EL(next); } /** \brief Move to next item. */ inline Element *operator++(int); /** \brief Move to previous item. */ inline Element *operator--() { return ptr = ptr->BASE_EL(prev); } /** \brief Move to previous item. */ inline Element *decrement() { return ptr = ptr->BASE_EL(prev); } /** \brief Move to previous item. */ inline Element *operator--(int); /** \brief Return the next item. Does not modify this. */ inline IterNext next() const { return IterNext(*this); } /** \brief Return the prev item. Does not modify this. */ inline IterPrev prev() const { return IterPrev(*this); } /** \brief The iterator is simply a pointer. */ Element *ptr; }; /** \brief Return first element. */ IterFirst first() { return IterFirst(*this); } /** \brief Return last element. */ IterLast last() { return IterLast(*this); } }; /* Copy constructor, does a deep copy of other. */ template DList:: DList(const DList &other) : head(0), tail(0), listLen(0) { Element *el = other.head; while( el != 0 ) { append( new Element(*el) ); el = el->BASE_EL(next); } } #ifdef DOUBLELIST_VALUE /* Assignement operator does deep copy. */ template DList &DList:: operator=(const DList &other) { /* Free the old list. The value list assumes items were allocated on the * heap by itself. */ empty(); Element *el = other.head; while( el != 0 ) { append( new Element(*el) ); el = el->BASE_EL(next); } return *this; } template void DList:: transfer(DList &other) { /* Free the old list. The value list assumes items were allocated on the * heap by itself. */ empty(); head = other.head; tail = other.tail; listLen = other.listLen; other.abandon(); } #else /* Assignement operator does deep copy. */ template DList &DList:: operator=(const DList &other) { Element *el = other.head; while( el != 0 ) { append( new Element(*el) ); el = el->BASE_EL(next); } return *this; } template void DList:: transfer(DList &other) { head = other.head; tail = other.tail; listLen = other.listLen; other.abandon(); } #endif #ifdef DOUBLELIST_VALUE /* Prepend a new item. Inlining this bloats the caller with new overhead. */ template void DList:: prepend(const T &item) { addBefore(head, new Element(item)); } /* Append a new item. Inlining this bloats the caller with the new overhead. */ template void DList:: append(const T &item) { addAfter(tail, new Element(item)); } /* Add a new item after a prev element. Inlining this bloats the caller with * the new overhead. */ template void DList:: addAfter(Element *prev_el, const T &item) { addAfter(prev_el, new Element(item)); } /* Add a new item before a next element. Inlining this bloats the caller with * the new overhead. */ template void DList:: addBefore(Element *next_el, const T &item) { addBefore(next_el, new Element(item)); } #endif /* * The larger iterator operators. */ /* Postfix ++ */ template Element *DList::Iter:: operator++(int) { Element *rtn = ptr; ptr = ptr->BASE_EL(next); return rtn; } /* Postfix -- */ template Element *DList::Iter:: operator--(int) { Element *rtn = ptr; ptr = ptr->BASE_EL(prev); return rtn; } /** * \brief Insert an element immediately after an element in the list. * * If prev_el is NULL then new_el is prepended to the front of the list. If * prev_el is not in the list or if new_el is already in a list, then * undefined behaviour results. */ template void DList:: addAfter(Element *prev_el, Element *new_el) { /* Set the previous pointer of new_el to prev_el. We do * this regardless of the state of the list. */ new_el->BASE_EL(prev) = prev_el; /* Set forward pointers. */ if (prev_el == 0) { /* There was no prev_el, we are inserting at the head. */ new_el->BASE_EL(next) = head; head = new_el; } else { /* There was a prev_el, we can access previous next. */ new_el->BASE_EL(next) = prev_el->BASE_EL(next); prev_el->BASE_EL(next) = new_el; } /* Set reverse pointers. */ if (new_el->BASE_EL(next) == 0) { /* There is no next element. Set the tail pointer. */ tail = new_el; } else { /* There is a next element. Set it's prev pointer. */ new_el->BASE_EL(next)->BASE_EL(prev) = new_el; } /* Update list length. */ listLen++; } /** * \brief Insert an element immediatly before an element in the list. * * If next_el is NULL then new_el is appended to the end of the list. If * next_el is not in the list or if new_el is already in a list, then * undefined behaviour results. */ template void DList:: addBefore(Element *next_el, Element *new_el) { /* Set the next pointer of the new element to next_el. We do * this regardless of the state of the list. */ new_el->BASE_EL(next) = next_el; /* Set reverse pointers. */ if (next_el == 0) { /* There is no next elememnt. We are inserting at the tail. */ new_el->BASE_EL(prev) = tail; tail = new_el; } else { /* There is a next element and we can access next's previous. */ new_el->BASE_EL(prev) = next_el->BASE_EL(prev); next_el->BASE_EL(prev) = new_el; } /* Set forward pointers. */ if (new_el->BASE_EL(prev) == 0) { /* There is no previous element. Set the head pointer.*/ head = new_el; } else { /* There is a previous element, set it's next pointer to new_el. */ new_el->BASE_EL(prev)->BASE_EL(next) = new_el; } /* Update list length. */ listLen++; } /** * \brief Insert an entire list immediatly after an element in this list. * * Elements are moved, not copied. Afterwards, the other list is empty. If * prev_el is NULL then the elements are prepended to the front of the list. * If prev_el is not in the list then undefined behaviour results. All * elements are inserted into the list at once, so this is an O(1) operation. */ template void DList:: addAfter( Element *prev_el, DList &dl ) { /* Do not bother if dl has no elements. */ if ( dl.listLen == 0 ) return; /* Set the previous pointer of dl.head to prev_el. We do * this regardless of the state of the list. */ dl.head->BASE_EL(prev) = prev_el; /* Set forward pointers. */ if (prev_el == 0) { /* There was no prev_el, we are inserting at the head. */ dl.tail->BASE_EL(next) = head; head = dl.head; } else { /* There was a prev_el, we can access previous next. */ dl.tail->BASE_EL(next) = prev_el->BASE_EL(next); prev_el->BASE_EL(next) = dl.head; } /* Set reverse pointers. */ if (dl.tail->BASE_EL(next) == 0) { /* There is no next element. Set the tail pointer. */ tail = dl.tail; } else { /* There is a next element. Set it's prev pointer. */ dl.tail->BASE_EL(next)->BASE_EL(prev) = dl.tail; } /* Update the list length. */ listLen += dl.listLen; /* Empty out dl. */ dl.head = dl.tail = 0; dl.listLen = 0; } /** * \brief Insert an entire list immediately before an element in this list. * * Elements are moved, not copied. Afterwards, the other list is empty. If * next_el is NULL then the elements are appended to the end of the list. If * next_el is not in the list then undefined behaviour results. All elements * are inserted at once, so this is an O(1) operation. */ template void DList:: addBefore( Element *next_el, DList &dl ) { /* Do not bother if dl has no elements. */ if ( dl.listLen == 0 ) return; /* Set the next pointer of dl.tail to next_el. We do * this regardless of the state of the list. */ dl.tail->BASE_EL(next) = next_el; /* Set reverse pointers. */ if (next_el == 0) { /* There is no next elememnt. We are inserting at the tail. */ dl.head->BASE_EL(prev) = tail; tail = dl.tail; } else { /* There is a next element and we can access next's previous. */ dl.head->BASE_EL(prev) = next_el->BASE_EL(prev); next_el->BASE_EL(prev) = dl.tail; } /* Set forward pointers. */ if (dl.head->BASE_EL(prev) == 0) { /* There is no previous element. Set the head pointer.*/ head = dl.head; } else { /* There is a previous element, set it's next pointer to new_el. */ dl.head->BASE_EL(prev)->BASE_EL(next) = dl.head; } /* Update list length. */ listLen += dl.listLen; /* Empty out dl. */ dl.head = dl.tail = 0; dl.listLen = 0; } /** * \brief Detach an element from the list. * * The element is not deleted. If the element is not in the list, then * undefined behaviour results. * * \returns The element detached. */ template Element *DList:: detach(Element *el) { /* Set forward pointers to skip over el. */ if (el->BASE_EL(prev) == 0) head = el->BASE_EL(next); else { el->BASE_EL(prev)->BASE_EL(next) = el->BASE_EL(next); } /* Set reverse pointers to skip over el. */ if (el->BASE_EL(next) == 0) tail = el->BASE_EL(prev); else { el->BASE_EL(next)->BASE_EL(prev) = el->BASE_EL(prev); } /* Update List length and return element we detached. */ listLen--; return el; } /** * \brief Clear the list by deleting all elements. * * Each item in the list is deleted. The list is reset to its initial state. */ template void DList::empty() { Element *nextToGo = 0, *cur = head; while (cur != 0) { nextToGo = cur->BASE_EL(next); delete cur; cur = nextToGo; } head = tail = 0; listLen = 0; } /** * \brief Clear the list by forgetting all elements. * * All elements are abandoned, not deleted. The list is reset to it's initial * state. */ template void DList::abandon() { head = tail = 0; listLen = 0; } #ifdef AAPL_NAMESPACE } #endif kelbt-0.16/aapl/dlistmel.h0000664000175000017500000000456312471662307012407 00000000000000/* * Copyright 2001 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_DLISTMEL_H #define _AAPL_DLISTMEL_H /** * \addtogroup dlist * @{ */ /** * \class DListMel * \brief Doubly linked list for elements that may appear in multiple lists. * * This class is similar to DList, except that the user defined list element * can inherit from multple DListEl classes and consequently be an element in * multiple lists. In other words, DListMel allows a single instance of a data * structure to be an element in multiple lists without the lists interfereing * with one another. * * For each list that an element class is to appear in, the element must have * unique next and previous pointers that can be unambiguously refered to with * some base class name. This name is given to DListMel as a template argument * so it can use the correct next and previous pointers in its list * operations. * * DListMel does not assume ownership of elements in the list. If the elements * are known to reside on the heap and are not contained in any other list or * data structure, the provided empty() routine can be used to delete all * elements, however the destructor will not call this routine, it will simply * abandon all the elements. It is up to the programmer to explicitly * de-allocate items when it is safe to do so. * * \include ex_dlistmel.cpp */ /*@}*/ #define BASE_EL(name) BaseEl::name #define DLMEL_TEMPDEF class Element, class BaseEl #define DLMEL_TEMPUSE Element, BaseEl #define DList DListMel #include "dlcommon.h" #undef BASE_EL #undef DLMEL_TEMPDEF #undef DLMEL_TEMPUSE #undef DList #endif /* _AAPL_DLISTMEL_H */ kelbt-0.16/aapl/compare.h0000664000175000017500000001546012471662307012216 00000000000000/* * Copyright 2001 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_COMPARE_H #define _AAPL_COMPARE_H #include #include "table.h" #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \defgroup compare Compare * \brief Basic compare clases. * * Compare classes are used by data structures that need to know the relative * ordering of elemets. To become a compare class, a class must imlement a * routine long compare(const T &key1, const T &key2) that behaves just like * strcmp. * * Compare classes are passed to the template data structure as a template * parameter and are inherited. In most cases the compare routine will base * the key comparision only on the two keys and the compare routine can * therefore be static. Though sometimes it is useful to include data in the * compare class and use this data in the comparison. For example the compare * class may contain a pointer to some other data structure to which the * comparison is delegated. * * @{ */ /** * \brief Compare two null terminated character sequences. * * This comparision class is a wrapper for strcmp. */ struct CmpStr { /** * \brief Compare two null terminated string types. */ static inline long compare(const char *k1, const char *k2) { return strcmp(k1, k2); } }; /** * \brief Compare a type for which < and > are implemented. * * CmpOrd is suitable for simple types such as integers and pointers that by * default have the less-than and greater-than operators defined. */ template struct CmpOrd { /** * \brief Compare two ordinal types. * * This compare routine copies its arguements in by value. */ static inline long compare(const T k1, const T k2) { if (k1 < k2) return -1; else if (k1 > k2) return 1; else return 0; } }; /** * \brief Compare two tables of type T * * Table comparison is useful for keying a data structure on a vector or * binary search table. T is the element type stored in the table. * CompareT is the comparison structure used to compare the individual values * in the table. */ template < class T, class CompareT = CmpOrd > struct CmpTable : public CompareT { /** * \brief Compare two tables storing type T. */ static inline long compare(const Table &t1, const Table &t2) { if ( t1.tabLen < t2.tabLen ) return -1; else if ( t1.tabLen > t2.tabLen ) return 1; else { T *i1 = t1.data, *i2 = t2.data; long len = t1.tabLen, cmpResult; for ( long pos = 0; pos < len; pos += 1, i1 += 1, i2 += 1 ) { cmpResult = CompareT::compare(*i1, *i2); if ( cmpResult != 0 ) return cmpResult; } return 0; } } }; /** * \brief Compare two tables of type T -- non-static version. * * CmpTableNs is identical to CmpTable, however the compare routine is * non-static. If the CompareT class contains a non-static compare, then this * version must be used because a static member cannot invoke a non-static * member. * * Table comparison is useful for keying a data structure on a vector or binary * search table. T is the element type stored in the table. CompareT * is the comparison structure used to compare the individual values in the * table. */ template < class T, class CompareT = CmpOrd > struct CmpTableNs : public CompareT { /** * \brief Compare two tables storing type T. */ inline long compare(const Table &t1, const Table &t2) { if ( t1.tabLen < t2.tabLen ) return -1; else if ( t1.tabLen > t2.tabLen ) return 1; else { T *i1 = t1.data, *i2 = t2.data; long len = t1.tabLen, cmpResult; for ( long pos = 0; pos < len; pos += 1, i1 += 1, i2 += 1 ) { cmpResult = CompareT::compare(*i1, *i2); if ( cmpResult != 0 ) return cmpResult; } return 0; } } }; /** * \brief Compare two implicitly shared tables of type T * * This table comparison is for data structures based on implicitly * shared tables. * * Table comparison is useful for keying a data structure on a vector or * binary search table. T is the element type stored in the table. * CompareT is the comparison structure used to compare the individual values * in the table. */ template < class T, class CompareT = CmpOrd > struct CmpSTable : public CompareT { /** * \brief Compare two tables storing type T. */ static inline long compare(const STable &t1, const STable &t2) { long t1Length = t1.length(); long t2Length = t2.length(); /* Compare lengths. */ if ( t1Length < t2Length ) return -1; else if ( t1Length > t2Length ) return 1; else { /* Compare the table data. */ T *i1 = t1.data, *i2 = t2.data; for ( long pos = 0; pos < t1Length; pos += 1, i1 += 1, i2 += 1 ) { long cmpResult = CompareT::compare(*i1, *i2); if ( cmpResult != 0 ) return cmpResult; } return 0; } } }; /** * \brief Compare two implicitly shared tables of type T -- non-static * version. * * This is a non-static table comparison for data structures based on * implicitly shared tables. If the CompareT class contains a non-static * compare, then this version must be used because a static member cannot * invoke a non-static member. * * Table comparison is useful for keying a data structure on a vector or * binary search table. T is the element type stored in the table. * CompareT is the comparison structure used to compare the individual values * in the table. */ template < class T, class CompareT = CmpOrd > struct CmpSTableNs : public CompareT { /** * \brief Compare two tables storing type T. */ inline long compare(const STable &t1, const STable &t2) { long t1Length = t1.length(); long t2Length = t2.length(); /* Compare lengths. */ if ( t1Length < t2Length ) return -1; else if ( t1Length > t2Length ) return 1; else { /* Compare the table data. */ T *i1 = t1.data, *i2 = t2.data; for ( long pos = 0; pos < t1Length; pos += 1, i1 += 1, i2 += 1 ) { long cmpResult = CompareT::compare(*i1, *i2); if ( cmpResult != 0 ) return cmpResult; } return 0; } } }; /*@}*/ #ifdef AAPL_NAMESPACE } #endif #endif /* _AAPL_COMPARE_H */ kelbt-0.16/aapl/avlbasic.h0000664000175000017500000000345212471662307012352 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLBASIC_H #define _AAPL_AVLBASIC_H #include "compare.h" /** * \addtogroup avltree * @{ */ /** * \class AvlBasic * \brief AVL Tree in which the entire element structure is the key. * * AvlBasic is an AVL tree that does not distinguish between the element that * it contains and the key. The entire element structure is the key that is * used to compare the relative ordering of elements. This is similar to the * BstSet structure. * * AvlBasic does not assume ownership of elements in the tree. Items must be * explicitly de-allocated. */ /*@}*/ #define BASE_EL(name) name #define BASEKEY(name) name #define AVLMEL_CLASSDEF class Element, class Compare #define AVLMEL_TEMPDEF class Element, class Compare #define AVLMEL_TEMPUSE Element, Compare #define AvlTree AvlBasic #define AVL_BASIC #include "avlcommon.h" #undef BASE_EL #undef BASEKEY #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef AVL_BASIC #endif /* _AAPL_AVLBASIC_H */ kelbt-0.16/aapl/bstset.h0000664000175000017500000000474512471662307012100 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_BSTSET_H #define _AAPL_BSTSET_H /** * \addtogroup bst * @{ */ /** * \class BstSet * \brief Binary search table for types that are the key. * * BstSet is suitable for types that comprise the entire key. Rather than look * into the element to retrieve the key, the element is the key. A class that * contains a comparison routine for the key must be given. */ /*@}*/ #include "compare.h" #include "vector.h" #define BST_TEMPL_DECLARE class Key, class Compare = CmpOrd, \ class Resize = ResizeExpn #define BST_TEMPL_DEF class Key, class Compare, class Resize #define BST_TEMPL_USE Key, Compare, Resize #define GET_KEY(el) (el) #define BstTable BstSet #define Element Key #define BSTSET #include "bstcommon.h" #undef BST_TEMPL_DECLARE #undef BST_TEMPL_DEF #undef BST_TEMPL_USE #undef GET_KEY #undef BstTable #undef Element #undef BSTSET /** * \fn BstSet::insert(const Key &key, Key **lastFound) * \brief Insert the given key. * * If the given key does not already exist in the table then it is inserted. * The key's copy constructor is used to place the item in the table. If * lastFound is given, it is set to the new entry created. If the insert fails * then lastFound is set to the existing key of the same value. * * \returns The new element created upon success, null upon failure. */ /** * \fn BstSet::insertMulti(const Key &key) * \brief Insert the given key even if it exists already. * * If the key exists already then it is placed next to some other key of the * same value. InsertMulti cannot fail. The key's copy constructor is used to * place the item in the table. * * \returns The new element created. */ #endif /* _AAPL_BSTSET_H */ kelbt-0.16/aapl/insertsort.h0000664000175000017500000000506512471662307013004 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_INSERTSORT_H #define _AAPL_INSERTSORT_H #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \addtogroup sort * @{ */ /** * \class InsertSort * \brief Insertion sort an array of data. * * InsertSort can be used to sort any array of objects of type T provided a * compare class is given. InsertSort is in-place. It does not require any * temporary storage. * * Objects are not made aware that they are being moved around in memory. * Assignment operators, constructors and destructors are never invoked by the * sort. * * InsertSort runs in O(n^2) time. It is most useful when sorting small arrays. * where it can outperform the O(n*log(n)) sorters due to its simplicity. * InsertSort is a not a stable sort. Elements with the same key will not have * their relative ordering preserved. */ /*@}*/ /* InsertSort. */ template class InsertSort : public Compare { public: /* Sorting interface routine. */ void sort(T *data, long len); }; /** * \brief Insertion sort an array of data. */ template void InsertSort::sort(T *data, long len) { /* For each next largest spot in the sorted array... */ for ( T *dest = data; dest < data+len-1; dest++ ) { /* Find the next smallest element in the unsorted array. */ T *smallest = dest; for ( T *src = dest+1; src < data+len; src++ ) { /* If src is smaller than the current src, then use it. */ if ( compare( *src, *smallest ) < 0 ) smallest = src; } if ( smallest != dest ) { /* Swap dest, smallest. */ char tmp[sizeof(T)]; memcpy( tmp, dest, sizeof(T) ); memcpy( dest, smallest, sizeof(T) ); memcpy( smallest, tmp, sizeof(T) ); } } } #ifdef AAPL_NAMESPACE } #endif #endif /* _AAPL_INSERTSORT_H */ kelbt-0.16/aapl/sbstset.h0000664000175000017500000000532712471662307012260 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_SBSTSET_H #define _AAPL_SBSTSET_H /** * \addtogroup bst * @{ */ /** * \class SBstSet * \brief Copy-on-write binary search table for types that are the key. * * This is a set style binary search table that employs the copy-on-write * mechanism for storing table data. BstSet is suitable for types that * comprise the entire key. Rather than look into the element to retrieve the * key, the element is the key. A class that contains a comparison routine * for the key must be given. */ /*@}*/ #include "compare.h" #include "svector.h" #define BST_TEMPL_DECLARE class Key, class Compare = CmpOrd, \ class Resize = ResizeExpn #define BST_TEMPL_DEF class Key, class Compare, class Resize #define BST_TEMPL_USE Key, Compare, Resize #define GET_KEY(el) (el) #define BstTable SBstSet #define Vector SVector #define Table STable #define Element Key #define BSTSET #define SHARED_BST #include "bstcommon.h" #undef BST_TEMPL_DECLARE #undef BST_TEMPL_DEF #undef BST_TEMPL_USE #undef GET_KEY #undef BstTable #undef Vector #undef Table #undef Element #undef BSTSET #undef SHARED_BST /** * \fn SBstSet::insert(const Key &key, Key **lastFound) * \brief Insert the given key. * * If the given key does not already exist in the table then it is inserted. * The key's copy constructor is used to place the item in the table. If * lastFound is given, it is set to the new entry created. If the insert fails * then lastFound is set to the existing key of the same value. * * \returns The new element created upon success, null upon failure. */ /** * \fn SBstSet::insertMulti(const Key &key) * \brief Insert the given key even if it exists already. * * If the key exists already then it is placed next to some other key of the * same value. InsertMulti cannot fail. The key's copy constructor is used to * place the item in the table. * * \returns The new element created. */ #endif /* _AAPL_SBSTSET_H */ kelbt-0.16/aapl/avltree.h0000664000175000017500000000446012471662307012230 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLTREE_H #define _AAPL_AVLTREE_H #include "compare.h" /** * \addtogroup avltree * @{ */ /** * \class AvlTree * \brief Basic AVL tree. * * AvlTree is the standard by-structure AVL tree. To use this structure the * user must define an element type and give it the necessary properties. At * the very least it must have a getKey() function that will be used to * compare the relative ordering of elements and tree management data * necessary for the AVL algorithm. An element type can acquire the management * data by inheriting the AvlTreeEl class. * * AvlTree does not presume to manage the allocation of elements in the tree. * The destructor will not delete the items in the tree, instead the elements * must be explicitly de-allocated by the user if necessary and when it is * safe to do so. The empty() routine will traverse the tree and delete all * items. * * Since the tree does not manage the elements, it can contain elements that * are allocated statically or that are part of another data structure. * * \include ex_avltree.cpp */ /*@}*/ #define BASE_EL(name) name #define BASEKEY(name) name #define AVLMEL_CLASSDEF class Element, class Key, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Element, class Key, class Compare #define AVLMEL_TEMPUSE Element, Key, Compare #define AvlTree AvlTree #include "avlcommon.h" #undef BASE_EL #undef BASEKEY #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #endif /* _AAPL_AVLTREE_H */ kelbt-0.16/aapl/README0000664000175000017500000000035212471662307011271 00000000000000This directory contains the Aapl source distribution. For the documentation, build scripts, test programs, ChangeLog, etc. get the aapldev package. AaplDev and other information about Aapl is available from http://www.elude.ca/aapl/ kelbt-0.16/aapl/bubblesort.h0000664000175000017500000000471212471662307012731 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_BUBBLESORT_H #define _AAPL_BUBBLESORT_H #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \addtogroup sort * @{ */ /** * \class BubbleSort * \brief Bubble sort an array of data. * * BubbleSort can be used to sort any array of objects of type T provided a * compare class is given. BubbleSort is in-place. It does not require any * temporary storage. * * Objects are not made aware that they are being moved around in memory. * Assignment operators, constructors and destructors are never invoked by the * sort. * * BubbleSort runs in O(n^2) time. It is most useful when sorting arrays that * are nearly sorted. It is best when neighbouring pairs are out of place. * BubbleSort is a stable sort, meaning that objects with the same key have * their relative ordering preserved. */ /*@}*/ /* BubbleSort. */ template class BubbleSort : public Compare { public: /* Sorting interface routine. */ void sort(T *data, long len); }; /** * \brief Bubble sort an array of data. */ template void BubbleSort:: sort(T *data, long len) { bool changed = true; for ( long pass = 1; changed && pass < len; pass ++ ) { changed = false; for ( long i = 0; i < len-pass; i++ ) { /* Do we swap pos with the next one? */ if ( compare( data[i], data[i+1] ) > 0 ) { char tmp[sizeof(T)]; /* Swap the two items. */ memcpy( tmp, data+i, sizeof(T) ); memcpy( data+i, data+i+1, sizeof(T) ); memcpy( data+i+1, tmp, sizeof(T) ); /* Note that we made a change. */ changed = true; } } } } #ifdef AAPL_NAMESPACE } #endif #endif /* _AAPL_BUBBLESORT_H */ kelbt-0.16/aapl/bsttable.h0000664000175000017500000000515512471662307012370 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_BSTTABLE_H #define _AAPL_BSTTABLE_H #include "compare.h" #include "vector.h" /** * \addtogroup bst * @{ */ /** * \class BstTable * \brief Binary search table for structures that contain a key. * * This is the basic binary search table. It can be used to contain a * structure that has a key and possibly some data. The key should be a member * of the element class and accessible with getKey(). A class containing the * compare routine must be supplied. */ /*@}*/ #define BST_TEMPL_DECLARE class Element, class Key, \ class Compare = CmpOrd, class Resize = ResizeExpn #define BST_TEMPL_DEF class Element, class Key, class Compare, class Resize #define BST_TEMPL_USE Element, Key, Compare, Resize #define GET_KEY(el) ((el).getKey()) #define BSTTABLE #include "bstcommon.h" #undef BST_TEMPL_DECLARE #undef BST_TEMPL_DEF #undef BST_TEMPL_USE #undef GET_KEY #undef BSTTABLE /** * \fn BstTable::insert(const Key &key, Element **lastFound) * \brief Insert a new element with the given key. * * If the given key does not already exist in the table a new element is * inserted with the given key. A constructor taking only const Key& is used * to initialize the new element. If lastFound is given, it is set to the new * element created. If the insert fails then lastFound is set to the existing * element with the same key. * * \returns The new element created upon success, null upon failure. */ /** * \fn BstTable::insertMulti(const Key &key) * \brief Insert a new element even if the key exists already. * * If the key exists already then the new element is placed next to some * element with the same key. InsertMulti cannot fail. A constructor taking * only const Key& is used to initialize the new element. * * \returns The new element created. */ #endif /* _AAPL_BSTTABLE_H */ kelbt-0.16/aapl/svector.h0000664000175000017500000012072112471662307012252 00000000000000/* * Copyright 2002, 2006 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_SVECTOR_H #define _AAPL_SVECTOR_H #include #include #include #include #include "table.h" #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \addtogroup vector * @{ */ /** \class SVector * \brief Copy-on-write dynamic array. * * SVector is a variant of Vector that employs copy-on-write behaviour. The * SVector copy constructor and = operator make shallow copies. If a vector * that references shared data is modified with insert, replace, append, * prepend, setAs or remove, a new copy is made so as not to interfere with * the shared data. However, shared individual elements may be modified by * bypassing the SVector interface. * * SVector is a dynamic array that can be used to contain complex data * structures that have constructors and destructors as well as simple types * such as integers and pointers. * * SVector supports inserting, overwriting, and removing single or multiple * elements at once. Constructors and destructors are called wherever * appropriate. For example, before an element is overwritten, it's * destructor is called. * * SVector provides automatic resizing of allocated memory as needed and * offers different allocation schemes for controlling how the automatic * allocation is done. Two senses of the the length of the data is * maintained: the amount of raw memory allocated to the vector and the number * of actual elements in the vector. The various allocation schemes control * how the allocated space is changed in relation to the number of elements in * the vector. */ /*@}*/ /* SVector */ template < class T, class Resize = ResizeExpn > class SVector : public STable, public Resize { private: typedef STable BaseTable; public: /** * \brief Initialize an empty vector with no space allocated. * * If a linear resizer is used, the step defaults to 256 units of T. For a * runtime vector both up and down allocation schemes default to * Exponential. */ SVector() { } /** * \brief Create a vector that contains an initial element. * * The vector becomes one element in length. The element's copy * constructor is used to place the value in the vector. */ SVector(const T &val) { setAs(&val, 1); } /** * \brief Create a vector that contains an array of elements. * * The vector becomes len elements in length. Copy constructors are used * to place the new elements in the vector. */ SVector(const T *val, long len) { setAs(val, len); } /* Shallow copy. */ SVector( const SVector &v ); /** * \brief Free all memory used by the vector. * * The vector is reset to zero elements. Destructors are called on all * elements in the vector. The space allocated for the vector is freed. */ ~SVector() { empty(); } /* Delete all items. */ void empty(); /** * \brief Deep copy another vector into this vector. * * Copies the entire contents of the other vector into this vector. Any * existing contents are first deleted. Equivalent to setAs. */ void deepCopy( const SVector &v ) { setAs(v.data, v.length()); } /* Perform a shallow copy of another vector. */ SVector &operator=( const SVector &v ); /*@{*/ /** * \brief Insert one element at position pos. * * Elements in the vector from pos onward are shifted one space to the * right. The copy constructor is used to place the element into this * vector. If pos is greater than the length of the vector then undefined * behaviour results. If pos is negative then it is treated as an offset * relative to the length of the vector. */ void insert(long pos, const T &val) { insert(pos, &val, 1); } /* Insert an array of values. */ void insert(long pos, const T *val, long len); /** * \brief Insert all the elements from another vector at position pos. * * Elements in this vector from pos onward are shifted v.length() spaces * to the right. The element's copy constructor is used to copy the items * into this vector. The other vector is left unchanged. If pos is off the * end of the vector, then undefined behaviour results. If pos is negative * then it is treated as an offset relative to the length of the vector. * Equivalent to vector.insert(pos, other.data, other.length()). */ void insert(long pos, const SVector &v) { insert(pos, v.data, v.length()); } /* Insert len copies of val into the vector. */ void insertDup(long pos, const T &val, long len); /** * \brief Insert one new element using the default constrcutor. * * Elements in the vector from pos onward are shifted one space to the right. * The default constructor is used to init the new element. If pos is greater * than the length of the vector then undefined behaviour results. If pos is * negative then it is treated as an offset relative to the length of the * vector. */ void insertNew(long pos) { insertNew(pos, 1); } /* Insert len new items using default constructor. */ void insertNew(long pos, long len); /*@}*/ /*@{*/ /** * \brief Remove one element at position pos. * * The element's destructor is called. Elements to the right of pos are * shifted one space to the left to take up the free space. If pos is greater * than or equal to the length of the vector then undefined behavior results. * If pos is negative then it is treated as an offset relative to the length * of the vector. */ void remove(long pos) { remove(pos, 1); } /* Delete a number of elements. */ void remove(long pos, long len); /*@}*/ /*@{*/ /** * \brief Replace one element at position pos. * * If there is an existing element at position pos (if pos is less than the * length of the vector) then its destructor is called before the space is * used. The copy constructor is used to place the element into the vector. * If pos is greater than the length of the vector then undefined behaviour * results. If pos is negative then it is treated as an offset relative to * the length of the vector. */ void replace(long pos, const T &val) { replace(pos, &val, 1); } /* Replace with an array of values. */ void replace(long pos, const T *val, long len); /** * \brief Replace at position pos with all the elements of another vector. * * Replace at position pos with all the elements of another vector. The other * vector is left unchanged. If there are existing elements at the positions * to be replaced, then destructors are called before the space is used. Copy * constructors are used to place the elements into this vector. It is * allowable for the pos and length of the other vector to specify a * replacement that overwrites existing elements and creates new ones. If pos * is greater than the length of the vector then undefined behaviour results. * If pos is negative, then it is treated as an offset relative to the length * of the vector. */ void replace(long pos, const SVector &v) { replace(pos, v.data, v.length()); } /* Replace len items with len copies of val. */ void replaceDup(long pos, const T &val, long len); /** * \brief Replace at position pos with one new element. * * If there is an existing element at the position to be replaced (pos is * less than the length of the vector) then the element's destructor is * called before the space is used. The default constructor is used to * initialize the new element. If pos is greater than the length of the * vector then undefined behaviour results. If pos is negative, then it is * treated as an offset relative to the length of the vector. */ void replaceNew(long pos) { replaceNew(pos, 1); } /* Replace len items at pos with newly constructed objects. */ void replaceNew(long pos, long len); /*@}*/ /*@{*/ /** * \brief Set the contents of the vector to be val exactly. * * The vector becomes one element in length. Destructors are called on any * existing elements in the vector. The element's copy constructor is used to * place the val in the vector. */ void setAs(const T &val) { setAs(&val, 1); } /* Set to the contents of an array. */ void setAs(const T *val, long len); /** * \brief Set the vector to exactly the contents of another vector. * * The vector becomes v.length() elements in length. Destructors are called * on any existing elements. Copy constructors are used to place the new * elements in the vector. */ void setAs(const SVector &v) { setAs(v.data, v.length()); } /* Set as len copies of item. */ void setAsDup(const T &item, long len); /** * \brief Set the vector to exactly one new item. * * The vector becomes one element in length. Destructors are called on any * existing elements in the vector. The default constructor is used to * init the new item. */ void setAsNew() { setAsNew(1); } /* Set as newly constructed objects using the default constructor. */ void setAsNew(long len); /*@}*/ /*@{*/ /** * \brief Append one elment to the end of the vector. * * Copy constructor is used to place the element in the vector. */ void append(const T &val) { replace(BaseTable::length(), &val, 1); } /** * \brief Append len elements to the end of the vector. * * Copy constructors are used to place the elements in the vector. */ void append(const T *val, long len) { replace(BaseTable::length(), val, len); } /** * \brief Append the contents of another vector. * * The other vector is left unchanged. Copy constructors are used to place * the elements in the vector. */ void append(const SVector &v) { replace(BaseTable::length(), v.data, v.length()); } /** * \brief Append len copies of item. * * The copy constructor is used to place the item in the vector. */ void appendDup(const T &item, long len) { replaceDup(BaseTable::length(), item, len); } /** * \brief Append a single newly created item. * * The new element is initialized with the default constructor. */ void appendNew() { replaceNew(BaseTable::length(), 1); } /** * \brief Append len newly created items. * * The new elements are initialized with the default constructor. */ void appendNew(long len) { replaceNew(BaseTable::length(), len); } /*@}*/ /*@{*/ /** * \brief Prepend one elment to the front of the vector. * * Copy constructor is used to place the element in the vector. */ void prepend(const T &val) { insert(0, &val, 1); } /** * \brief Prepend len elements to the front of the vector. * * Copy constructors are used to place the elements in the vector. */ void prepend(const T *val, long len) { insert(0, val, len); } /** * \brief Prepend the contents of another vector. * * The other vector is left unchanged. Copy constructors are used to place * the elements in the vector. */ void prepend(const SVector &v) { insert(0, v.data, v.length()); } /** * \brief Prepend len copies of item. * * The copy constructor is used to place the item in the vector. */ void prependDup(const T &item, long len) { insertDup(0, item, len); } /** * \brief Prepend a single newly created item. * * The new element is initialized with the default constructor. */ void prependNew() { insertNew(0, 1); } /** * \brief Prepend len newly created items. * * The new elements are initialized with the default constructor. */ void prependNew(long len) { insertNew(0, len); } /*@}*/ /* Convenience access. */ T &operator[](int i) const { return BaseTable::data[i]; } long size() const { return BaseTable::length(); } /* Various classes for setting the iterator */ struct Iter; struct IterFirst { IterFirst( const SVector &v ) : v(v) { } const SVector &v; }; struct IterLast { IterLast( const SVector &v ) : v(v) { } const SVector &v; }; struct IterNext { IterNext( const Iter &i ) : i(i) { } const Iter &i; }; struct IterPrev { IterPrev( const Iter &i ) : i(i) { } const Iter &i; }; /** * \brief Shared Vector Iterator. * \ingroup iterators */ struct Iter { /* Construct, assign. */ Iter() : ptr(0), ptrBeg(0), ptrEnd(0) { } /* Construct. */ Iter( const SVector &v ); Iter( const IterFirst &vf ); Iter( const IterLast &vl ); inline Iter( const IterNext &vn ); inline Iter( const IterPrev &vp ); /* Assign. */ Iter &operator=( const SVector &v ); Iter &operator=( const IterFirst &vf ); Iter &operator=( const IterLast &vl ); inline Iter &operator=( const IterNext &vf ); inline Iter &operator=( const IterPrev &vl ); /** \brief Less than end? */ bool lte() const { return ptr != ptrEnd; } /** \brief At end? */ bool end() const { return ptr == ptrEnd; } /** \brief Greater than beginning? */ bool gtb() const { return ptr != ptrBeg; } /** \brief At beginning? */ bool beg() const { return ptr == ptrBeg; } /** \brief At first element? */ bool first() const { return ptr == ptrBeg+1; } /** \brief At last element? */ bool last() const { return ptr == ptrEnd-1; } /* Return the position. */ long pos() const { return ptr - ptrBeg - 1; } T &operator[](int i) const { return ptr[i]; } /** \brief Implicit cast to T*. */ operator T*() const { return ptr; } /** \brief Dereference operator returns T&. */ T &operator *() const { return *ptr; } /** \brief Arrow operator returns T*. */ T *operator->() const { return ptr; } /** \brief Move to next item. */ T *operator++() { return ++ptr; } /** \brief Move to next item. */ T *operator++(int) { return ptr++; } /** \brief Move to next item. */ T *increment() { return ++ptr; } /** \brief Move to previous item. */ T *operator--() { return --ptr; } /** \brief Move to previous item. */ T *operator--(int) { return ptr--; } /** \brief Move to previous item. */ T *decrement() { return --ptr; } /** \brief Return the next item. Does not modify this. */ inline IterNext next() const { return IterNext(*this); } /** \brief Return the previous item. Does not modify this. */ inline IterPrev prev() const { return IterPrev(*this); } /** \brief The iterator is simply a pointer. */ T *ptr; /* For testing endpoints. */ T *ptrBeg, *ptrEnd; }; /** \brief Return first element. */ IterFirst first() { return IterFirst( *this ); } /** \brief Return last element. */ IterLast last() { return IterLast( *this ); } protected: void makeRawSpaceFor(long pos, long len); void setAsCommon(long len); long replaceCommon(long pos, long len); long insertCommon(long pos, long len); void upResize(long len); void upResizeDup(long len); void upResizeFromEmpty(long len); void downResize(long len); void downResizeDup(long len); }; /** * \brief Perform a shallow copy of the vector. * * Takes a reference to the contents of the other vector. */ template SVector:: SVector(const SVector &v) { /* Take a reference to other, if any data is allocated. */ if ( v.data == 0 ) BaseTable::data = 0; else { /* Get the source header, up the refcount and ref it. */ STabHead *srcHead = ((STabHead*) v.data) - 1; srcHead->refCount += 1; BaseTable::data = (T*) (srcHead + 1); } } /** * \brief Shallow copy another vector into this vector. * * Takes a reference to the other vector. The contents of this vector are * first emptied. * * \returns A reference to this. */ template SVector & SVector:: operator=( const SVector &v ) { /* First clean out the current contents. */ empty(); /* Take a reference to other, if any data is allocated. */ if ( v.data == 0 ) BaseTable::data = 0; else { /* Get the source header, up the refcount and ref it. */ STabHead *srcHead = ((STabHead*) v.data) - 1; srcHead->refCount += 1; BaseTable::data = (T*) (srcHead + 1); } return *this; } /* Init a vector iterator with just a vector. */ template SVector:: Iter::Iter( const SVector &v ) { long length; if ( v.data == 0 || (length=(((STabHead*)v.data)-1)->tabLen) == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = v.data; ptrBeg = v.data-1; ptrEnd = v.data+length; } } /* Init a vector iterator with the first of a vector. */ template SVector:: Iter::Iter( const IterFirst &vf ) { long length; if ( vf.v.data == 0 || (length=(((STabHead*)vf.v.data)-1)->tabLen) == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = vf.v.data; ptrBeg = vf.v.data-1; ptrEnd = vf.v.data+length; } } /* Init a vector iterator with the last of a vector. */ template SVector:: Iter::Iter( const IterLast &vl ) { long length; if ( vl.v.data == 0 || (length=(((STabHead*)vl.v.data)-1)->tabLen) == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = vl.v.data+length-1; ptrBeg = vl.v.data-1; ptrEnd = vl.v.data+length; } } /* Init a vector iterator with the next of some other iterator. */ template SVector:: Iter::Iter( const IterNext &vn ) : ptr(vn.i.ptr+1), ptrBeg(vn.i.ptrBeg), ptrEnd(vn.i.ptrEnd) { } /* Init a vector iterator with the prev of some other iterator. */ template SVector:: Iter::Iter( const IterPrev &vp ) : ptr(vp.i.ptr-1), ptrBeg(vp.i.ptrBeg), ptrEnd(vp.i.ptrEnd) { } /* Set a vector iterator with some vector. */ template typename SVector::Iter & SVector::Iter::operator=( const SVector &v ) { long length; if ( v.data == 0 || (length=(((STabHead*)v.data)-1)->tabLen) == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = v.data; ptrBeg = v.data-1; ptrEnd = v.data+length; } return *this; } /* Set a vector iterator with the first element in a vector. */ template typename SVector::Iter & SVector::Iter::operator=( const IterFirst &vf ) { long length; if ( vf.v.data == 0 || (length=(((STabHead*)vf.v.data)-1)->tabLen) == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = vf.v.data; ptrBeg = vf.v.data-1; ptrEnd = vf.v.data+length; } return *this; } /* Set a vector iterator with the last element in a vector. */ template typename SVector::Iter & SVector::Iter::operator=( const IterLast &vl ) { long length; if ( vl.v.data == 0 || (length=(((STabHead*)vl.v.data)-1)->tabLen) == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = vl.v.data+length-1; ptrBeg = vl.v.data-1; ptrEnd = vl.v.data+length; } return *this; } /* Set a vector iterator with the next of some other iterator. */ template typename SVector::Iter & SVector::Iter::operator=( const IterNext &vn ) { ptr = vn.i.ptr+1; ptrBeg = vn.i.ptrBeg; ptrEnd = vn.i.ptrEnd; return *this; } /* Set a vector iterator with the prev of some other iterator. */ template typename SVector::Iter & SVector::Iter::operator=( const IterPrev &vp ) { ptr = vp.i.ptr-1; ptrBeg = vp.i.ptrBeg; ptrEnd = vp.i.ptrEnd; return *this; } /* Up resize the data for len elements using Resize::upResize to tell us the * new length. Reads and writes allocLen. Does not read or write length. * Assumes that there is some data allocated already. */ template void SVector:: upResize(long len) { /* Get the current header. */ STabHead *head = ((STabHead*)BaseTable::data) - 1; /* Ask the resizer what the new length will be. */ long newLen = Resize::upResize(head->allocLen, len); /* Did the data grow? */ if ( newLen > head->allocLen ) { head->allocLen = newLen; /* Table exists already, resize it up. */ head = (STabHead*) realloc( head, sizeof(STabHead) + sizeof(T) * newLen ); if ( head == 0 ) throw std::bad_alloc(); /* Save the data pointer. */ BaseTable::data = (T*) (head + 1); } } /* Allocates a new buffer for an up resize that requires a duplication of the * data. Uses Resize::upResize to get the allocation length. Reads and writes * allocLen. This upResize does write the new length. Assumes that there is * some data allocated already. */ template void SVector:: upResizeDup(long len) { /* Get the current header. */ STabHead *head = ((STabHead*)BaseTable::data) - 1; /* Ask the resizer what the new length will be. */ long newLen = Resize::upResize(head->allocLen, len); /* Dereferencing the existing data, decrement the refcount. */ head->refCount -= 1; /* Table exists already, resize it up. */ head = (STabHead*) malloc( sizeof(STabHead) + sizeof(T) * newLen ); if ( head == 0 ) throw std::bad_alloc(); head->refCount = 1; head->allocLen = newLen; head->tabLen = len; /* Save the data pointer. */ BaseTable::data = (T*) (head + 1); } /* Up resize the data for len elements using Resize::upResize to tell us the * new length. Reads and writes allocLen. This upresize DOES write length. * Assumes that no data is allocated. */ template void SVector:: upResizeFromEmpty(long len) { /* There is no table yet. If the len is zero, then there is no need to * create a table. */ if ( len > 0 ) { /* Ask the resizer what the new length will be. */ long newLen = Resize::upResize(0, len); /* If len is greater than zero then we are always allocating the table. */ STabHead *head = (STabHead*) malloc( sizeof(STabHead) + sizeof(T) * newLen ); if ( head == 0 ) throw std::bad_alloc(); /* Set up the header and save the data pointer. Note that we set the * length here. This differs from the other upResizes. */ head->refCount = 1; head->allocLen = newLen; head->tabLen = len; BaseTable::data = (T*) (head + 1); } } /* Down resize the data for len elements using Resize::downResize to determine * the new length. Reads and writes allocLen. Does not read or write length. */ template void SVector:: downResize(long len) { /* If there is already no length, then there is nothing we can do. */ if ( BaseTable::data != 0 ) { /* Get the current header. */ STabHead *head = ((STabHead*)BaseTable::data) - 1; /* Ask the resizer what the new length will be. */ long newLen = Resize::downResize( head->allocLen, len ); /* Did the data shrink? */ if ( newLen < head->allocLen ) { if ( newLen == 0 ) { /* Simply free the data. */ free( head ); BaseTable::data = 0; } else { /* Save the new allocated length. */ head->allocLen = newLen; /* Not shrinking to size zero, realloc it to the smaller size. */ head = (STabHead*) realloc( head, sizeof(STabHead) + sizeof(T) * newLen ); if ( head == 0 ) throw std::bad_alloc(); /* Save the new data ptr. */ BaseTable::data = (T*) (head + 1); } } } } /* Allocate a new buffer for a down resize and duplication of the array. The * new array will be len long and allocation size will be determined using * Resize::downResize with the old array's allocLen. Does not actually copy * any data. Reads and writes allocLen and writes the new len. */ template void SVector:: downResizeDup(long len) { /* If there is already no length, then there is nothing we can do. */ if ( BaseTable::data != 0 ) { /* Get the current header. */ STabHead *head = ((STabHead*)BaseTable::data) - 1; /* Ask the resizer what the new length will be. */ long newLen = Resize::downResize( head->allocLen, len ); /* Detaching from the existing head, decrement the refcount. */ head->refCount -= 1; /* Not shrinking to size zero, malloc it to the smaller size. */ head = (STabHead*) malloc( sizeof(STabHead) + sizeof(T) * newLen ); if ( head == 0 ) throw std::bad_alloc(); /* Save the new allocated length. */ head->refCount = 1; head->allocLen = newLen; head->tabLen = len; /* Save the data pointer. */ BaseTable::data = (T*) (head + 1); } } /** * \brief Free all memory used by the vector. * * The vector is reset to zero elements. Destructors are called on all * elements in the vector. The space allocated for the vector is freed. */ template void SVector:: empty() { if ( BaseTable::data != 0 ) { /* Get the header and drop the refcount on the data. */ STabHead *head = ((STabHead*) BaseTable::data) - 1; head->refCount -= 1; /* If the refcount just went down to zero nobody else is referencing * the data. */ if ( head->refCount == 0 ) { /* Call All destructors. */ T *pos = BaseTable::data; for ( long i = 0; i < head->tabLen; pos++, i++ ) pos->~T(); /* Free the data space. */ free( head ); } /* Clear the pointer. */ BaseTable::data = 0; } } /* Prepare for setting the contents of the vector to some array len long. * Handles reusing the existing space, detaching from a common space or * growing from zero length automatically. */ template void SVector:: setAsCommon(long len) { if ( BaseTable::data != 0 ) { /* Get the header. */ STabHead *head = ((STabHead*)BaseTable::data) - 1; /* If the refCount is one, then we can reuse the space. Otherwise we * must detach from the referenced data create new space. */ if ( head->refCount == 1 ) { /* Call All destructors. */ T *pos = BaseTable::data; for ( long i = 0; i < head->tabLen; pos++, i++ ) pos->~T(); /* Adjust the allocated length. */ if ( len < head->tabLen ) downResize( len ); else if ( len > head->tabLen ) upResize( len ); if ( BaseTable::data != 0 ) { /* Get the header again and set the length. */ head = ((STabHead*)BaseTable::data) - 1; head->tabLen = len; } } else { /* Just detach from the data. */ head->refCount -= 1; BaseTable::data = 0; /* Make enough space. This will set the length. */ upResizeFromEmpty( len ); } } else { /* The table is currently empty. Make enough space. This will set the * length. */ upResizeFromEmpty( len ); } } /** * \brief Set the contents of the vector to be len elements exactly. * * The vector becomes len elements in length. Destructors are called on any * existing elements in the vector. Copy constructors are used to place the * new elements in the vector. */ template void SVector:: setAs(const T *val, long len) { /* Common stuff for setting the array to len long. */ setAsCommon( len ); /* Copy data in. */ T *dst = BaseTable::data; const T *src = val; for ( long i = 0; i < len; i++, dst++, src++ ) new(dst) T(*src); } /** * \brief Set the vector to len copies of item. * * The vector becomes len elements in length. Destructors are called on any * existing elements in the vector. The element's copy constructor is used to * copy the item into the vector. */ template void SVector:: setAsDup(const T &item, long len) { /* Do the common stuff for setting the array to len long. */ setAsCommon( len ); /* Copy item in one spot at a time. */ T *dst = BaseTable::data; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(item); } /** * \brief Set the vector to exactly len new items. * * The vector becomes len elements in length. Destructors are called on any * existing elements in the vector. Default constructors are used to init the * new items. */ template void SVector:: setAsNew(long len) { /* Do the common stuff for setting the array to len long. */ setAsCommon( len ); /* Create items using default constructor. */ T *dst = BaseTable::data; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(); } /* Make space in vector for a replacement at pos of len items. Handles reusing * existing space, detaching or growing from zero space. */ template long SVector:: replaceCommon(long pos, long len) { if ( BaseTable::data != 0 ) { /* Get the header. */ STabHead *head = ((STabHead*)BaseTable::data) - 1; /* If we are given a negative position to replace at then treat it as * a position relative to the length. This doesn't have any meaning * unless the length is at least one. */ if ( pos < 0 ) pos = head->tabLen + pos; /* The end is the one past the last item that we want to write to. */ long i, endPos = pos + len; if ( head->refCount == 1 ) { /* We can reuse the space. Make sure we have enough space. */ if ( endPos > head->tabLen ) { upResize( endPos ); /* Get the header again, whose addr may have changed after * resizing. */ head = ((STabHead*)BaseTable::data) - 1; /* Delete any objects we need to delete. */ T *item = BaseTable::data + pos; for ( i = pos; i < head->tabLen; i++, item++ ) item->~T(); /* We are extending the vector, set the new data length. */ head->tabLen = endPos; } else { /* Delete any objects we need to delete. */ T *item = BaseTable::data + pos; for ( i = pos; i < endPos; i++, item++ ) item->~T(); } } else { /* Use endPos to calc the end of the vector. */ long newLen = endPos; if ( newLen < head->tabLen ) newLen = head->tabLen; /* Duplicate and grow up to endPos. This will set the length. */ upResizeDup( newLen ); /* Copy from src up to pos. */ const T *src = (T*) (head + 1); T *dst = BaseTable::data; for ( i = 0; i < pos; i++, dst++, src++) new(dst) T(*src); /* Copy any items after the replace range. */ for ( i += len, src += len, dst += len; i < head->tabLen; i++, dst++, src++ ) new(dst) T(*src); } } else { /* There is no data initially, must grow from zero. This will set the * new length. */ upResizeFromEmpty( len ); } return pos; } /** * \brief Replace len elements at position pos. * * If there are existing elements at the positions to be replaced, then * destructors are called before the space is used. Copy constructors are used * to place the elements into the vector. It is allowable for the pos and * length to specify a replacement that overwrites existing elements and * creates new ones. If pos is greater than the length of the vector then * undefined behaviour results. If pos is negative, then it is treated as an * offset relative to the length of the vector. */ template void SVector:: replace(long pos, const T *val, long len) { /* Common work for replacing in the vector. */ pos = replaceCommon( pos, len ); /* Copy data in using copy constructor. */ T *dst = BaseTable::data + pos; const T *src = val; for ( long i = 0; i < len; i++, dst++, src++ ) new(dst) T(*src); } /** * \brief Replace at position pos with len copies of an item. * * If there are existing elements at the positions to be replaced, then * destructors are called before the space is used. The copy constructor is * used to place the element into this vector. It is allowable for the pos and * length to specify a replacement that overwrites existing elements and * creates new ones. If pos is greater than the length of the vector then * undefined behaviour results. If pos is negative, then it is treated as an * offset relative to the length of the vector. */ template void SVector:: replaceDup(long pos, const T &val, long len) { /* Common replacement stuff. */ pos = replaceCommon( pos, len ); /* Copy data in using copy constructor. */ T *dst = BaseTable::data + pos; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(val); } /** * \brief Replace at position pos with len new elements. * * If there are existing elements at the positions to be replaced, then * destructors are called before the space is used. The default constructor is * used to initialize the new elements. It is allowable for the pos and length * to specify a replacement that overwrites existing elements and creates new * ones. If pos is greater than the length of the vector then undefined * behaviour results. If pos is negative, then it is treated as an offset * relative to the length of the vector. */ template void SVector:: replaceNew(long pos, long len) { /* Do the common replacement stuff. */ pos = replaceCommon( pos, len ); /* Copy data in using copy constructor. */ T *dst = BaseTable::data + pos; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(); } /** * \brief Remove len elements at position pos. * * Destructor is called on all elements removed. Elements to the right of pos * are shifted len spaces to the left to take up the free space. If pos is * greater than or equal to the length of the vector then undefined behavior * results. If pos is negative then it is treated as an offset relative to the * length of the vector. */ template void SVector:: remove(long pos, long len) { /* If there is no data, we can't delete anything anyways. */ if ( BaseTable::data != 0 ) { /* Get the header. */ STabHead *head = ((STabHead*)BaseTable::data) - 1; /* If we are given a negative position to remove at then * treat it as a position relative to the length. */ if ( pos < 0 ) pos = head->tabLen + pos; /* The first position after the last item deleted. */ long endPos = pos + len; /* The New data length. */ long i, newLen = head->tabLen - len; if ( head->refCount == 1 ) { /* We are the only ones using the data. We can reuse * the existing space. */ /* The place in the data we are deleting at. */ T *dst = BaseTable::data + pos; /* Call Destructors. */ T *item = BaseTable::data + pos; for ( i = 0; i < len; i += 1, item += 1 ) item->~T(); /* Shift data over if necessary. */ long lenToSlideOver = head->tabLen - endPos; if ( len > 0 && lenToSlideOver > 0 ) memmove(BaseTable::data + pos, dst + len, sizeof(T)*lenToSlideOver); /* Shrink the data if necessary. */ downResize( newLen ); if ( BaseTable::data != 0 ) { /* Get the header again (because of the resize) and set the * new data length. */ head = ((STabHead*)BaseTable::data) - 1; head->tabLen = newLen; } } else { /* Must detach from the common data. Just copy the non-deleted * items from the common data. */ /* Duplicate and grow down to newLen. This will set the length. */ downResizeDup( newLen ); /* Copy over just the non-deleted parts. */ const T *src = (T*) (head + 1); T *dst = BaseTable::data; for ( i = 0; i < pos; i++, dst++, src++ ) new(dst) T(*src); /* ... and the second half. */ for ( i += len, src += len; i < head->tabLen; i++, src++, dst++ ) new(dst) T(*src); } } } /* Shift over existing data. Handles reusing existing space, detaching or * growing from zero space. */ template long SVector:: insertCommon(long pos, long len) { if ( BaseTable::data != 0 ) { /* Get the header. */ STabHead *head = ((STabHead*)BaseTable::data) - 1; /* If we are given a negative position to insert at then treat it as a * position relative to the length. This only has meaning if there is * existing data. */ if ( pos < 0 ) pos = head->tabLen + pos; /* Calculate the new length. */ long i, newLen = head->tabLen + len; if ( head->refCount == 1 ) { /* Up resize, we are growing. */ upResize( newLen ); /* Get the header again, (the addr may have changed after * resizing). */ head = ((STabHead*)BaseTable::data) - 1; /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < head->tabLen ) { memmove( BaseTable::data + pos + len, BaseTable::data + pos, sizeof(T)*(head->tabLen - pos) ); } /* Grow the length by the len inserted. */ head->tabLen += len; } else { /* Need to detach from the existing array. Copy over the other * parts. This will set the length. */ upResizeDup( newLen ); /* Copy over the parts around the insert. */ const T *src = (T*) (head + 1); T *dst = BaseTable::data; for ( i = 0; i < pos; i++, dst++, src++ ) new(dst) T(*src); /* ... and the second half. */ for ( dst += len; i < head->tabLen; i++, src++, dst++ ) new(dst) T(*src); } } else { /* There is no existing data. Start from zero. This will set the * length. */ upResizeFromEmpty( len ); } return pos; } /** * \brief Insert len elements at position pos. * * Elements in the vector from pos onward are shifted len spaces to the right. * The copy constructor is used to place the elements into this vector. If pos * is greater than the length of the vector then undefined behaviour results. * If pos is negative then it is treated as an offset relative to the length * of the vector. */ template void SVector:: insert(long pos, const T *val, long len) { /* Do the common insertion stuff. */ pos = insertCommon( pos, len ); /* Copy data in element by element. */ T *dst = BaseTable::data + pos; const T *src = val; for ( long i = 0; i < len; i++, dst++, src++ ) new(dst) T(*src); } /** * \brief Insert len copies of item at position pos. * * Elements in the vector from pos onward are shifted len spaces to the right. * The copy constructor is used to place the element into this vector. If pos * is greater than the length of the vector then undefined behaviour results. * If pos is negative then it is treated as an offset relative to the length * of the vector. */ template void SVector:: insertDup(long pos, const T &item, long len) { /* Do the common insertion stuff. */ pos = insertCommon( pos, len ); /* Copy the data item in one at a time. */ T *dst = BaseTable::data + pos; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(item); } /** * \brief Insert len new elements using the default constructor. * * Elements in the vector from pos onward are shifted len spaces to the right. * Default constructors are used to init the new elements. If pos is off the * end of the vector then undefined behaviour results. If pos is negative then * it is treated as an offset relative to the length of the vector. */ template void SVector:: insertNew(long pos, long len) { /* Do the common insertion stuff. */ pos = insertCommon( pos, len ); /* Init new data with default constructors. */ T *dst = BaseTable::data + pos; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(); } /* Makes space for len items, Does not init the items in any way. If pos is * greater than the length of the vector then undefined behaviour results. * Updates the length of the vector. */ template void SVector:: makeRawSpaceFor(long pos, long len) { if ( BaseTable::data != 0 ) { /* Get the header. */ STabHead *head = ((STabHead*)BaseTable::data) - 1; /* Calculate the new length. */ long i, newLen = head->tabLen + len; if ( head->refCount == 1 ) { /* Up resize, we are growing. */ upResize( newLen ); /* Get the header again, (the addr may have changed after * resizing). */ head = ((STabHead*)BaseTable::data) - 1; /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < head->tabLen ) { memmove( BaseTable::data + pos + len, BaseTable::data + pos, sizeof(T)*(head->tabLen - pos) ); } /* Grow the length by the len inserted. */ head->tabLen += len; } else { /* Need to detach from the existing array. Copy over the other * parts. This will set the length. */ upResizeDup( newLen ); /* Copy over the parts around the insert. */ const T *src = (T*) (head + 1); T *dst = BaseTable::data; for ( i = 0; i < pos; i++, dst++, src++ ) new(dst) T(*src); /* ... and the second half. */ for ( dst += len; i < head->tabLen; i++, src++, dst++ ) new(dst) T(*src); } } else { /* There is no existing data. Start from zero. This will set the * length. */ upResizeFromEmpty( len ); } } #ifdef AAPL_NAMESPACE } #endif #endif /* _AAPL_SVECTOR_H */ kelbt-0.16/aapl/avlkeyless.h0000664000175000017500000000304612471662307012747 00000000000000/* * Copyright 2002, 2003 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLKEYLESS_H #define _AAPL_AVLKEYLESS_H #include "compare.h" /** * \addtogroup avltree * @{ */ /** * \class AvlKeyless * \brief AVL tree that has no insert/find/remove functions that take a key. * * AvlKeyless is an implementation of the AVL tree rebalancing functionality * only. It provides the common code for the tiny AVL tree implementations. */ /*@}*/ #define BASE_EL(name) name #define AVLMEL_CLASSDEF class Element #define AVLMEL_TEMPDEF class Element #define AVLMEL_TEMPUSE Element #define AvlTree AvlKeyless #define AVL_KEYLESS #include "avlcommon.h" #undef BASE_EL #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef AVL_KEYLESS #endif /* _AAPL_AVLKEYLESS_H */ kelbt-0.16/aapl/COPYING0000664000175000017500000006363612471662307011462 00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! kelbt-0.16/aapl/vector.h0000664000175000017500000010502412471662307012066 00000000000000/* * Copyright 2002, 2006 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_VECTOR_H #define _AAPL_VECTOR_H #include #include #include #include #include "table.h" #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \addtogroup vector * @{ */ /** \class Vector * \brief Dynamic array. * * This is typical vector implementation. It is a dynamic array that can be * used to contain complex data structures that have constructors and * destructors as well as simple types such as integers and pointers. * * Vector supports inserting, overwriting, and removing single or multiple * elements at once. Constructors and destructors are called wherever * appropriate. For example, before an element is overwritten, it's * destructor is called. * * Vector provides automatic resizing of allocated memory as needed and offers * different allocation schemes for controlling how the automatic allocation * is done. Two senses of the the length of the data is maintained: the * amount of raw memory allocated to the vector and the number of actual * elements in the vector. The various allocation schemes control how the * allocated space is changed in relation to the number of elements in the * vector. * * \include ex_vector.cpp */ /*@}*/ template < class T, class Resize = ResizeExpn > class Vector : public Table, public Resize { private: typedef Table BaseTable; public: /** * \brief Initialize an empty vector with no space allocated. * * If a linear resizer is used, the step defaults to 256 units of T. For a * runtime vector both up and down allocation schemes default to * Exponential. */ Vector() { } /** * \brief Create a vector that contains an initial element. * * The vector becomes one element in length. The element's copy * constructor is used to place the value in the vector. */ Vector(const T &val) { setAs(&val, 1); } /** * \brief Create a vector that contains an array of elements. * * The vector becomes len elements in length. Copy constructors are used * to place the new elements in the vector. */ Vector(const T *val, long len) { setAs(val, len); } /* Deep copy. */ Vector( const Vector &v ); /* Free all mem used by the vector. */ ~Vector() { empty(); } /* Delete all items. */ void empty(); /* Abandon the contents of the vector without deleteing. */ void abandon(); /* Transfers the elements of another vector into this vector. First emptys * the current vector. */ void transfer( Vector &v ); /* Perform a deep copy of another vector into this vector. */ Vector &operator=( const Vector &v ); /*@{*/ /** * \brief Insert one element at position pos. * * Elements in the vector from pos onward are shifted one space to the * right. The copy constructor is used to place the element into this * vector. If pos is greater than the length of the vector then undefined * behaviour results. If pos is negative then it is treated as an offset * relative to the length of the vector. */ void insert(long pos, const T &val) { insert(pos, &val, 1); } /* Insert an array of values. */ void insert(long pos, const T *val, long len); /** * \brief Insert all the elements from another vector at position pos. * * Elements in this vector from pos onward are shifted v.tabLen spaces to * the right. The element's copy constructor is used to copy the items * into this vector. The other vector is left unchanged. If pos is off the * end of the vector, then undefined behaviour results. If pos is negative * then it is treated as an offset relative to the length of the vector. * Equivalent to vector.insert(pos, other.data, other.tabLen). */ void insert(long pos, const Vector &v) { insert(pos, v.data, v.tabLen); } /* Insert len copies of val into the vector. */ void insertDup(long pos, const T &val, long len); /** * \brief Insert one new element using the default constrcutor. * * Elements in the vector from pos onward are shifted one space to the * right. The default constructor is used to init the new element. If pos * is greater than the length of the vector then undefined behaviour * results. If pos is negative then it is treated as an offset relative to * the length of the vector. */ void insertNew(long pos) { insertNew(pos, 1); } /* Insert len new items using default constructor. */ void insertNew(long pos, long len); /*@}*/ /*@{*/ /** * \brief Remove one element at position pos. * * The element's destructor is called. Elements to the right of pos are * shifted one space to the left to take up the free space. If pos is greater * than or equal to the length of the vector then undefined behavior results. * If pos is negative then it is treated as an offset relative to the length * of the vector. */ void remove(long pos) { remove(pos, 1); } /* Delete a number of elements. */ void remove(long pos, long len); /*@}*/ /*@{*/ /** * \brief Replace one element at position pos. * * If there is an existing element at position pos (if pos is less than * the length of the vector) then its destructor is called before the * space is used. The copy constructor is used to place the element into * the vector. If pos is greater than the length of the vector then * undefined behaviour results. If pos is negative then it is treated as * an offset relative to the length of the vector. */ void replace(long pos, const T &val) { replace(pos, &val, 1); } /* Replace with an array of values. */ void replace(long pos, const T *val, long len); /** * \brief Replace at position pos with all the elements of another vector. * * Replace at position pos with all the elements of another vector. The * other vector is left unchanged. If there are existing elements at the * positions to be replaced, then destructors are called before the space * is used. Copy constructors are used to place the elements into this * vector. It is allowable for the pos and length of the other vector to * specify a replacement that overwrites existing elements and creates new * ones. If pos is greater than the length of the vector then undefined * behaviour results. If pos is negative, then it is treated as an offset * relative to the length of the vector. */ void replace(long pos, const Vector &v) { replace(pos, v.data, v.tabLen); } /* Replace len items with len copies of val. */ void replaceDup(long pos, const T &val, long len); /** * \brief Replace at position pos with one new element. * * If there is an existing element at the position to be replaced (pos is * less than the length of the vector) then the element's destructor is * called before the space is used. The default constructor is used to * initialize the new element. If pos is greater than the length of the * vector then undefined behaviour results. If pos is negative, then it is * treated as an offset relative to the length of the vector. */ void replaceNew(long pos) { replaceNew(pos, 1); } /* Replace len items at pos with newly constructed objects. */ void replaceNew(long pos, long len); /*@}*/ /*@{*/ /** * \brief Set the contents of the vector to be val exactly. * * The vector becomes one element in length. Destructors are called on any * existing elements in the vector. The element's copy constructor is used * to place the val in the vector. */ void setAs(const T &val) { setAs(&val, 1); } /* Set to the contents of an array. */ void setAs(const T *val, long len); /** * \brief Set the vector to exactly the contents of another vector. * * The vector becomes v.tabLen elements in length. Destructors are called * on any existing elements. Copy constructors are used to place the new * elements in the vector. */ void setAs(const Vector &v) { setAs(v.data, v.tabLen); } /* Set as len copies of item. */ void setAsDup(const T &item, long len); /** * \brief Set the vector to exactly one new item. * * The vector becomes one element in length. Destructors are called on any * existing elements in the vector. The default constructor is used to * init the new item. */ void setAsNew() { setAsNew(1); } /* Set as newly constructed objects using the default constructor. */ void setAsNew(long len); /*@}*/ /*@{*/ /** * \brief Append one elment to the end of the vector. * * Copy constructor is used to place the element in the vector. */ void append(const T &val) { replace(BaseTable::tabLen, &val, 1); } /** * \brief Append len elements to the end of the vector. * * Copy constructors are used to place the elements in the vector. */ void append(const T *val, long len) { replace(BaseTable::tabLen, val, len); } /** * \brief Append the contents of another vector. * * The other vector is left unchanged. Copy constructors are used to place the * elements in the vector. */ void append(const Vector &v) { replace(BaseTable::tabLen, v.data, v.tabLen); } /** * \brief Append len copies of item. * * The copy constructor is used to place the item in the vector. */ void appendDup(const T &item, long len) { replaceDup(BaseTable::tabLen, item, len); } /** * \brief Append a single newly created item. * * The new element is initialized with the default constructor. */ void appendNew() { replaceNew(BaseTable::tabLen, 1); } /** * \brief Append len newly created items. * * The new elements are initialized with the default constructor. */ void appendNew(long len) { replaceNew(BaseTable::tabLen, len); } /*@}*/ /*@{*/ /** \fn Vector::prepend(const T &val) * \brief Prepend one elment to the front of the vector. * * Copy constructor is used to place the element in the vector. */ void prepend(const T &val) { insert(0, &val, 1); } /** * \brief Prepend len elements to the front of the vector. * * Copy constructors are used to place the elements in the vector. */ void prepend(const T *val, long len) { insert(0, val, len); } /** * \brief Prepend the contents of another vector. * * The other vector is left unchanged. Copy constructors are used to place the * elements in the vector. */ void prepend(const Vector &v) { insert(0, v.data, v.tabLen); } /** * \brief Prepend len copies of item. * * The copy constructor is used to place the item in the vector. */ void prependDup(const T &item, long len) { insertDup(0, item, len); } /** * \brief Prepend a single newly created item. * * The new element is initialized with the default constructor. */ void prependNew() { insertNew(0, 1); } /** * \brief Prepend len newly created items. * * The new elements are initialized with the default constructor. */ void prependNew(long len) { insertNew(0, len); } /*@}*/ /* Convenience access. */ T &operator[](int i) const { return BaseTable::data[i]; } long size() const { return BaseTable::tabLen; } /* Forward this so a ref can be used. */ struct Iter; /* Various classes for setting the iterator */ struct IterFirst { IterFirst( const Vector &v ) : v(v) { } const Vector &v; }; struct IterLast { IterLast( const Vector &v ) : v(v) { } const Vector &v; }; struct IterNext { IterNext( const Iter &i ) : i(i) { } const Iter &i; }; struct IterPrev { IterPrev( const Iter &i ) : i(i) { } const Iter &i; }; /** * \brief Vector Iterator. * \ingroup iterators */ struct Iter { /* Construct, assign. */ Iter() : ptr(0), ptrBeg(0), ptrEnd(0) { } /* Construct. */ Iter( const Vector &v ); Iter( const IterFirst &vf ); Iter( const IterLast &vl ); inline Iter( const IterNext &vn ); inline Iter( const IterPrev &vp ); /* Assign. */ Iter &operator=( const Vector &v ); Iter &operator=( const IterFirst &vf ); Iter &operator=( const IterLast &vl ); inline Iter &operator=( const IterNext &vf ); inline Iter &operator=( const IterPrev &vl ); /** \brief Less than end? */ bool lte() const { return ptr != ptrEnd; } /** \brief At end? */ bool end() const { return ptr == ptrEnd; } /** \brief Greater than beginning? */ bool gtb() const { return ptr != ptrBeg; } /** \brief At beginning? */ bool beg() const { return ptr == ptrBeg; } /** \brief At first element? */ bool first() const { return ptr == ptrBeg+1; } /** \brief At last element? */ bool last() const { return ptr == ptrEnd-1; } /* Return the position. */ long pos() const { return ptr - ptrBeg - 1; } T &operator[](int i) const { return ptr[i]; } /** \brief Implicit cast to T*. */ operator T*() const { return ptr; } /** \brief Dereference operator returns T&. */ T &operator *() const { return *ptr; } /** \brief Arrow operator returns T*. */ T *operator->() const { return ptr; } /** \brief Move to next item. */ T *operator++() { return ++ptr; } /** \brief Move to next item. */ T *operator++(int) { return ptr++; } /** \brief Move to next item. */ T *increment() { return ++ptr; } /** \brief Move n items forward. */ T *operator+=(long n) { return ptr+=n; } /** \brief Move to previous item. */ T *operator--() { return --ptr; } /** \brief Move to previous item. */ T *operator--(int) { return ptr--; } /** \brief Move to previous item. */ T *decrement() { return --ptr; } /** \brief Move n items back. */ T *operator-=(long n) { return ptr-=n; } /** \brief Return the next item. Does not modify this. */ inline IterNext next() const { return IterNext(*this); } /** \brief Return the previous item. Does not modify this. */ inline IterPrev prev() const { return IterPrev(*this); } /** \brief The iterator is simply a pointer. */ T *ptr; /* For testing endpoints. */ T *ptrBeg, *ptrEnd; }; /** \brief Return first element. */ IterFirst first() { return IterFirst( *this ); } /** \brief Return last element. */ IterLast last() { return IterLast( *this ); } protected: void makeRawSpaceFor(long pos, long len); void upResize(long len); void downResize(long len); }; /* Init a vector iterator with just a vector. */ template Vector::Iter::Iter( const Vector &v ) { if ( v.tabLen == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = v.data; ptrBeg = v.data-1; ptrEnd = v.data+v.tabLen; } } /* Init a vector iterator with the first of a vector. */ template Vector::Iter::Iter( const IterFirst &vf ) { if ( vf.v.tabLen == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = vf.v.data; ptrBeg = vf.v.data-1; ptrEnd = vf.v.data+vf.v.tabLen; } } /* Init a vector iterator with the last of a vector. */ template Vector::Iter::Iter( const IterLast &vl ) { if ( vl.v.tabLen == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = vl.v.data+vl.v.tabLen-1; ptrBeg = vl.v.data-1; ptrEnd = vl.v.data+vl.v.tabLen; } } /* Init a vector iterator with the next of some other iterator. */ template Vector::Iter::Iter( const IterNext &vn ) : ptr(vn.i.ptr+1), ptrBeg(vn.i.ptrBeg), ptrEnd(vn.i.ptrEnd) { } /* Init a vector iterator with the prev of some other iterator. */ template Vector::Iter::Iter( const IterPrev &vp ) : ptr(vp.i.ptr-1), ptrBeg(vp.i.ptrBeg), ptrEnd(vp.i.ptrEnd) { } /* Set a vector iterator with some vector. */ template typename Vector::Iter & Vector::Iter::operator=( const Vector &v ) { if ( v.tabLen == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = v.data; ptrBeg = v.data-1; ptrEnd = v.data+v.tabLen; } return *this; } /* Set a vector iterator with the first element in a vector. */ template typename Vector::Iter & Vector::Iter::operator=( const IterFirst &vf ) { if ( vf.v.tabLen == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = vf.v.data; ptrBeg = vf.v.data-1; ptrEnd = vf.v.data+vf.v.tabLen; } return *this; } /* Set a vector iterator with the last element in a vector. */ template typename Vector::Iter & Vector::Iter::operator=( const IterLast &vl ) { if ( vl.v.tabLen == 0 ) ptr = ptrBeg = ptrEnd = 0; else { ptr = vl.v.data+vl.v.tabLen-1; ptrBeg = vl.v.data-1; ptrEnd = vl.v.data+vl.v.tabLen; } return *this; } /* Set a vector iterator with the next of some other iterator. */ template typename Vector::Iter & Vector::Iter::operator=( const IterNext &vn ) { ptr = vn.i.ptr+1; ptrBeg = vn.i.ptrBeg; ptrEnd = vn.i.ptrEnd; return *this; } /* Set a vector iterator with the prev of some other iterator. */ template typename Vector::Iter & Vector::Iter::operator=( const IterPrev &vp ) { ptr = vp.i.ptr-1; ptrBeg = vp.i.ptrBeg; ptrEnd = vp.i.ptrEnd; return *this; } /** * \brief Forget all elements in the vector. * * The contents of the vector are reset to null without without the space * being freed. */ template void Vector:: abandon() { BaseTable::data = 0; BaseTable::tabLen = 0; BaseTable::allocLen = 0; } /** * \brief Transfer the contents of another vector into this vector. * * The dynamic array of the other vector is moved into this vector by * reference. If this vector is non-empty then its contents are first deleted. * Afterward the other vector will be empty. */ template void Vector:: transfer( Vector &v ) { empty(); BaseTable::data = v.data; BaseTable::tabLen = v.tabLen; BaseTable::allocLen = v.allocLen; v.abandon(); } /** * \brief Deep copy another vector into this vector. * * Copies the entire contents of the other vector into this vector. Any * existing contents are first deleted. Equivalent to setAs. * * \returns A reference to this. */ template Vector &Vector:: operator=( const Vector &v ) { setAs(v.data, v.tabLen); return *this; } /* Up resize the data for len elements using Resize::upResize to tell us the * new tabLen. Reads and writes allocLen. Does not read or write tabLen. */ template void Vector:: upResize(long len) { /* Ask the resizer what the new tabLen will be. */ long newLen = Resize::upResize(BaseTable::allocLen, len); /* Did the data grow? */ if ( newLen > BaseTable::allocLen ) { BaseTable::allocLen = newLen; if ( BaseTable::data != 0 ) { /* Table exists already, resize it up. */ BaseTable::data = (T*) realloc( BaseTable::data, sizeof(T) * newLen ); if ( BaseTable::data == 0 ) throw std::bad_alloc(); } else { /* Create the data. */ BaseTable::data = (T*) malloc( sizeof(T) * newLen ); if ( BaseTable::data == 0 ) throw std::bad_alloc(); } } } /* Down resize the data for len elements using Resize::downResize to determine * the new tabLen. Reads and writes allocLen. Does not read or write tabLen. */ template void Vector:: downResize(long len) { /* Ask the resizer what the new tabLen will be. */ long newLen = Resize::downResize( BaseTable::allocLen, len ); /* Did the data shrink? */ if ( newLen < BaseTable::allocLen ) { BaseTable::allocLen = newLen; if ( newLen == 0 ) { /* Simply free the data. */ free( BaseTable::data ); BaseTable::data = 0; } else { /* Not shrinking to size zero, realloc it to the smaller size. */ BaseTable::data = (T*) realloc( BaseTable::data, sizeof(T) * newLen ); if ( BaseTable::data == 0 ) throw std::bad_alloc(); } } } /** * \brief Perform a deep copy of the vector. * * The contents of the other vector are copied into this vector. This vector * gets the same allocation size as the other vector. All items are copied * using the element's copy constructor. */ template Vector:: Vector(const Vector &v) { BaseTable::tabLen = v.tabLen; BaseTable::allocLen = v.allocLen; if ( BaseTable::allocLen > 0 ) { /* Allocate needed space. */ BaseTable::data = (T*) malloc(sizeof(T) * BaseTable::allocLen); if ( BaseTable::data == 0 ) throw std::bad_alloc(); /* If there are any items in the src data, copy them in. */ T *dst = BaseTable::data, *src = v.data; for (long pos = 0; pos < BaseTable::tabLen; pos++, dst++, src++ ) new(dst) T(*src); } else { /* Nothing allocated. */ BaseTable::data = 0; } } /** \fn Vector::~Vector() * \brief Free all memory used by the vector. * * The vector is reset to zero elements. Destructors are called on all * elements in the vector. The space allocated for the vector is freed. */ /** * \brief Free all memory used by the vector. * * The vector is reset to zero elements. Destructors are called on all * elements in the vector. The space allocated for the vector is freed. */ template void Vector:: empty() { if ( BaseTable::data != 0 ) { /* Call All destructors. */ T *pos = BaseTable::data; for ( long i = 0; i < BaseTable::tabLen; pos++, i++ ) pos->~T(); /* Free the data space. */ free( BaseTable::data ); BaseTable::data = 0; BaseTable::tabLen = BaseTable::allocLen = 0; } } /** * \brief Set the contents of the vector to be len elements exactly. * * The vector becomes len elements in length. Destructors are called on any * existing elements in the vector. Copy constructors are used to place the * new elements in the vector. */ template void Vector:: setAs(const T *val, long len) { /* Call All destructors. */ long i; T *pos = BaseTable::data; for ( i = 0; i < BaseTable::tabLen; pos++, i++ ) pos->~T(); /* Adjust the allocated length. */ if ( len < BaseTable::tabLen ) downResize( len ); else if ( len > BaseTable::tabLen ) upResize( len ); /* Set the new data length to exactly len. */ BaseTable::tabLen = len; /* Copy data in. */ T *dst = BaseTable::data; const T *src = val; for ( i = 0; i < len; i++, dst++, src++ ) new(dst) T(*src); } /** * \brief Set the vector to len copies of item. * * The vector becomes len elements in length. Destructors are called on any * existing elements in the vector. The element's copy constructor is used to * copy the item into the vector. */ template void Vector:: setAsDup(const T &item, long len) { /* Call All destructors. */ T *pos = BaseTable::data; for ( long i = 0; i < BaseTable::tabLen; pos++, i++ ) pos->~T(); /* Adjust the allocated length. */ if ( len < BaseTable::tabLen ) downResize( len ); else if ( len > BaseTable::tabLen ) upResize( len ); /* Set the new data length to exactly len. */ BaseTable::tabLen = len; /* Copy item in one spot at a time. */ T *dst = BaseTable::data; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(item); } /** * \brief Set the vector to exactly len new items. * * The vector becomes len elements in length. Destructors are called on any * existing elements in the vector. Default constructors are used to init the * new items. */ template void Vector:: setAsNew(long len) { /* Call All destructors. */ T *pos = BaseTable::data; for ( long i = 0; i < BaseTable::tabLen; pos++, i++ ) pos->~T(); /* Adjust the allocated length. */ if ( len < BaseTable::tabLen ) downResize( len ); else if ( len > BaseTable::tabLen ) upResize( len ); /* Set the new data length to exactly len. */ BaseTable::tabLen = len; /* Create items using default constructor. */ T *dst = BaseTable::data; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(); } /** * \brief Replace len elements at position pos. * * If there are existing elements at the positions to be replaced, then * destructors are called before the space is used. Copy constructors are used * to place the elements into the vector. It is allowable for the pos and * length to specify a replacement that overwrites existing elements and * creates new ones. If pos is greater than the length of the vector then * undefined behaviour results. If pos is negative, then it is treated as an * offset relative to the length of the vector. */ template void Vector:: replace(long pos, const T *val, long len) { long endPos, i; T *item; /* If we are given a negative position to replace at then * treat it as a position relative to the length. */ if ( pos < 0 ) pos = BaseTable::tabLen + pos; /* The end is the one past the last item that we want * to write to. */ endPos = pos + len; /* Make sure we have enough space. */ if ( endPos > BaseTable::tabLen ) { upResize( endPos ); /* Delete any objects we need to delete. */ item = BaseTable::data + pos; for ( i = pos; i < BaseTable::tabLen; i++, item++ ) item->~T(); /* We are extending the vector, set the new data length. */ BaseTable::tabLen = endPos; } else { /* Delete any objects we need to delete. */ item = BaseTable::data + pos; for ( i = pos; i < endPos; i++, item++ ) item->~T(); } /* Copy data in using copy constructor. */ T *dst = BaseTable::data + pos; const T *src = val; for ( i = 0; i < len; i++, dst++, src++ ) new(dst) T(*src); } /** * \brief Replace at position pos with len copies of an item. * * If there are existing elements at the positions to be replaced, then * destructors are called before the space is used. The copy constructor is * used to place the element into this vector. It is allowable for the pos and * length to specify a replacement that overwrites existing elements and * creates new ones. If pos is greater than the length of the vector then * undefined behaviour results. If pos is negative, then it is treated as an * offset relative to the length of the vector. */ template void Vector:: replaceDup(long pos, const T &val, long len) { long endPos, i; T *item; /* If we are given a negative position to replace at then * treat it as a position relative to the length. */ if ( pos < 0 ) pos = BaseTable::tabLen + pos; /* The end is the one past the last item that we want * to write to. */ endPos = pos + len; /* Make sure we have enough space. */ if ( endPos > BaseTable::tabLen ) { upResize( endPos ); /* Delete any objects we need to delete. */ item = BaseTable::data + pos; for ( i = pos; i < BaseTable::tabLen; i++, item++ ) item->~T(); /* We are extending the vector, set the new data length. */ BaseTable::tabLen = endPos; } else { /* Delete any objects we need to delete. */ item = BaseTable::data + pos; for ( i = pos; i < endPos; i++, item++ ) item->~T(); } /* Copy data in using copy constructor. */ T *dst = BaseTable::data + pos; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(val); } /** * \brief Replace at position pos with len new elements. * * If there are existing elements at the positions to be replaced, then * destructors are called before the space is used. The default constructor is * used to initialize the new elements. It is allowable for the pos and length * to specify a replacement that overwrites existing elements and creates new * ones. If pos is greater than the length of the vector then undefined * behaviour results. If pos is negative, then it is treated as an offset * relative to the length of the vector. */ template void Vector:: replaceNew(long pos, long len) { long endPos, i; T *item; /* If we are given a negative position to replace at then * treat it as a position relative to the length. */ if ( pos < 0 ) pos = BaseTable::tabLen + pos; /* The end is the one past the last item that we want * to write to. */ endPos = pos + len; /* Make sure we have enough space. */ if ( endPos > BaseTable::tabLen ) { upResize( endPos ); /* Delete any objects we need to delete. */ item = BaseTable::data + pos; for ( i = pos; i < BaseTable::tabLen; i++, item++ ) item->~T(); /* We are extending the vector, set the new data length. */ BaseTable::tabLen = endPos; } else { /* Delete any objects we need to delete. */ item = BaseTable::data + pos; for ( i = pos; i < endPos; i++, item++ ) item->~T(); } /* Copy data in using copy constructor. */ T *dst = BaseTable::data + pos; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(); } /** * \brief Remove len elements at position pos. * * Destructor is called on all elements removed. Elements to the right of pos * are shifted len spaces to the left to take up the free space. If pos is * greater than or equal to the length of the vector then undefined behavior * results. If pos is negative then it is treated as an offset relative to the * length of the vector. */ template void Vector:: remove(long pos, long len) { long newLen, lenToSlideOver, endPos; T *dst, *item; /* If we are given a negative position to remove at then * treat it as a position relative to the length. */ if ( pos < 0 ) pos = BaseTable::tabLen + pos; /* The first position after the last item deleted. */ endPos = pos + len; /* The new data length. */ newLen = BaseTable::tabLen - len; /* The place in the data we are deleting at. */ dst = BaseTable::data + pos; /* Call Destructors. */ item = dst; for ( long i = 0; i < len; i += 1, item += 1 ) item->~T(); /* Shift data over if necessary. */ lenToSlideOver = BaseTable::tabLen - endPos; if ( len > 0 && lenToSlideOver > 0 ) memmove(dst, dst + len, sizeof(T)*lenToSlideOver); /* Shrink the data if necessary. */ downResize( newLen ); /* Set the new data length. */ BaseTable::tabLen = newLen; } /** * \brief Insert len elements at position pos. * * Elements in the vector from pos onward are shifted len spaces to the right. * The copy constructor is used to place the elements into this vector. If pos * is greater than the length of the vector then undefined behaviour results. * If pos is negative then it is treated as an offset relative to the length * of the vector. */ template void Vector:: insert(long pos, const T *val, long len) { /* If we are given a negative position to insert at then * treat it as a position relative to the length. */ if ( pos < 0 ) pos = BaseTable::tabLen + pos; /* Calculate the new length. */ long newLen = BaseTable::tabLen + len; /* Up resize, we are growing. */ upResize( newLen ); /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < BaseTable::tabLen ) { memmove(BaseTable::data + pos + len, BaseTable::data + pos, sizeof(T)*(BaseTable::tabLen-pos)); } /* Copy data in element by element. */ T *dst = BaseTable::data + pos; const T *src = val; for ( long i = 0; i < len; i++, dst++, src++ ) new(dst) T(*src); /* Set the new length. */ BaseTable::tabLen = newLen; } /** * \brief Insert len copies of item at position pos. * * Elements in the vector from pos onward are shifted len spaces to the right. * The copy constructor is used to place the element into this vector. If pos * is greater than the length of the vector then undefined behaviour results. * If pos is negative then it is treated as an offset relative to the length * of the vector. */ template void Vector:: insertDup(long pos, const T &item, long len) { /* If we are given a negative position to insert at then * treat it as a position relative to the length. */ if ( pos < 0 ) pos = BaseTable::tabLen + pos; /* Calculate the new length. */ long newLen = BaseTable::tabLen + len; /* Up resize, we are growing. */ upResize( newLen ); /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < BaseTable::tabLen ) { memmove(BaseTable::data + pos + len, BaseTable::data + pos, sizeof(T)*(BaseTable::tabLen-pos)); } /* Copy the data item in one at a time. */ T *dst = BaseTable::data + pos; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(item); /* Set the new length. */ BaseTable::tabLen = newLen; } /** * \brief Insert len new elements using the default constructor. * * Elements in the vector from pos onward are shifted len spaces to the right. * Default constructors are used to init the new elements. If pos is off the * end of the vector then undefined behaviour results. If pos is negative then * it is treated as an offset relative to the length of the vector. */ template void Vector:: insertNew(long pos, long len) { /* If we are given a negative position to insert at then * treat it as a position relative to the length. */ if ( pos < 0 ) pos = BaseTable::tabLen + pos; /* Calculate the new length. */ long newLen = BaseTable::tabLen + len; /* Up resize, we are growing. */ upResize( newLen ); /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < BaseTable::tabLen ) { memmove(BaseTable::data + pos + len, BaseTable::data + pos, sizeof(T)*(BaseTable::tabLen-pos)); } /* Init new data with default constructors. */ T *dst = BaseTable::data + pos; for ( long i = 0; i < len; i++, dst++ ) new(dst) T(); /* Set the new length. */ BaseTable::tabLen = newLen; } /* Makes space for len items, Does not init the items in any way. If pos is * greater than the length of the vector then undefined behaviour results. * Updates the length of the vector. */ template void Vector:: makeRawSpaceFor(long pos, long len) { /* Calculate the new length. */ long newLen = BaseTable::tabLen + len; /* Up resize, we are growing. */ upResize( newLen ); /* Shift over data at insert spot if needed. */ if ( len > 0 && pos < BaseTable::tabLen ) { memmove(BaseTable::data + pos + len, BaseTable::data + pos, sizeof(T)*(BaseTable::tabLen-pos)); } /* Save the new length. */ BaseTable::tabLen = newLen; } #ifdef AAPL_NAMESPACE } #endif #endif /* _AAPL_VECTOR_H */ kelbt-0.16/aapl/avlikeyless.h0000664000175000017500000000326712471662307013125 00000000000000/* * Copyright 2002, 2003 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLIKEYLESS_H #define _AAPL_AVLIKEYLESS_H #include "compare.h" #include "dlistmel.h" /** * \addtogroup avlitree * @{ */ /** * \class AvliKeyless * \brief Linked AVL tree that has no insert/find/remove functions that take a * key. * * AvliKeyless is an implementation of the AVL tree rebalancing functionality * only. It provides the common code for the tiny AVL tree implementations. */ /*@}*/ #define BASE_EL(name) name #define BASELIST DListMel< Element, AvliTreeEl > #define AVLMEL_CLASSDEF class Element #define AVLMEL_TEMPDEF class Element #define AVLMEL_TEMPUSE Element #define AvlTree AvliKeyless #define WALKABLE #define AVL_KEYLESS #include "avlcommon.h" #undef BASE_EL #undef BASELIST #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef WALKABLE #undef AVL_KEYLESS #endif /* _AAPL_AVLIKEYLESS_H */ kelbt-0.16/aapl/avlimel.h0000664000175000017500000000462612471662307012223 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLIMEL_H #define _AAPL_AVLIMEL_H #include "compare.h" #include "dlistmel.h" /** * \addtogroup avlitree * @{ */ /** * \class AvliMel * \brief Linked AVL tree for element appearing in multiple trees. * * AvliMel allows for an element to simultaneously be in multiple trees without * the trees interferring with one another. For each tree that the element is * to appear in, there must be a distinct set of AVL Tree management data that * can be unambiguously referenced with some base class name. This name * is passed to the tree as a template parameter and is used in the tree * algorithms. * * The element must use the same key type and value in each tree that it * appears in. If distinct keys are required, the AvliMelKey structure is * available. * * AvliMel does not assume ownership of elements in the tree. The destructor * will not delete the elements. If the user wishes to explicitly deallocate * all the items in the tree the empty() routine is available. * * \include ex_avlimel.cpp */ /*@}*/ #define BASE_EL(name) BaseEl::name #define BASEKEY(name) name #define BASELIST DListMel< Element, BaseEl > #define AVLMEL_CLASSDEF class Element, class Key, \ class BaseEl, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Element, class Key, \ class BaseEl, class Compare #define AVLMEL_TEMPUSE Element, Key, BaseEl, Compare #define AvlTree AvliMel #define WALKABLE #include "avlcommon.h" #undef BASE_EL #undef BASEKEY #undef BASELIST #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef WALKABLE #endif /* _AAPL_AVLIMEL_H */ kelbt-0.16/aapl/dlistval.h0000664000175000017500000000431712471662307012411 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_DLISTVAL_H #define _AAPL_DLISTVAL_H /** * \addtogroup dlist * @{ */ /** * \class DListVal * \brief By-value doubly linked list. * * This class is a doubly linked list that does not require a list element * type to be declared. The user instead gives a type that is to be stored in * the list element. When inserting a new data item, the value is copied into * a newly allocated element. This list is inteded to behave and be utilized * like the list template found in the STL. * * DListVal is different from the other lists in that it allocates elements * itself. The raw element insert interface is still exposed for convenience, * however, the list assumes all elements in the list are allocated on the * heap and are to be managed by the list. The destructor WILL delete the * contents of the list. If the list is ever copied in from another list, the * existing contents are deleted first. This is in contrast to DList and * DListMel, which will never delete their contents to allow for statically * allocated elements. * * \include ex_dlistval.cpp */ /*@}*/ #define BASE_EL(name) name #define DLMEL_TEMPDEF class T #define DLMEL_TEMPUSE T #define DList DListVal #define Element DListValEl #define DOUBLELIST_VALUE #include "dlcommon.h" #undef BASE_EL #undef DLMEL_TEMPDEF #undef DLMEL_TEMPUSE #undef DList #undef Element #undef DOUBLELIST_VALUE #endif /* _AAPL_DLISTVAL_H */ kelbt-0.16/aapl/sbstmap.h0000664000175000017500000000632612471662307012242 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_SBSTMAP_H #define _AAPL_SBSTMAP_H #include "compare.h" #include "svector.h" #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \brief Element for BstMap. * * Stores the key and value pair. */ template struct SBstMapEl { SBstMapEl() {} SBstMapEl(const Key &key) : key(key) {} SBstMapEl(const Key &key, const Value &val) : key(key), value(val) {} /** \brief The key */ Key key; /** \brief The value. */ Value value; }; #ifdef AAPL_NAMESPACE } #endif /** * \addtogroup bst * @{ */ /** * \class SBstMap * \brief Copy-on-write binary search table for key and value pairs. * * This is a map style binary search table that employs the copy-on-write * mechanism for table data. BstMap stores key and value pairs in each * element. The key and value can be any type. A compare class for the key * must be supplied. */ /*@}*/ #define BST_TEMPL_DECLARE class Key, class Value, \ class Compare = CmpOrd, class Resize = ResizeExpn #define BST_TEMPL_DEF class Key, class Value, class Compare, class Resize #define BST_TEMPL_USE Key, Value, Compare, Resize #define GET_KEY(el) ((el).key) #define BstTable SBstMap #define Vector SVector #define Table STable #define Element SBstMapEl #define BSTMAP #define SHARED_BST #include "bstcommon.h" #undef BST_TEMPL_DECLARE #undef BST_TEMPL_DEF #undef BST_TEMPL_USE #undef GET_KEY #undef BstTable #undef Vector #undef Table #undef Element #undef BSTMAP #undef SHARED_BST /** * \fn SBstMap::insert(const Key &key, BstMapEl **lastFound) * \brief Insert the given key. * * If the given key does not already exist in the table then a new element * having key is inserted. They key copy constructor and value default * constructor are used to place the pair in the table. If lastFound is given, * it is set to the new entry created. If the insert fails then lastFound is * set to the existing pair of the same key. * * \returns The new element created upon success, null upon failure. */ /** * \fn SBstMap::insertMulti(const Key &key) * \brief Insert the given key even if it exists already. * * If the key exists already then the new element having key is placed next * to some other pair of the same key. InsertMulti cannot fail. The key copy * constructor and the value default constructor are used to place the pair in * the table. * * \returns The new element created. */ #endif /* _AAPL_SBSTMAP_H */ kelbt-0.16/aapl/quicksort.h0000664000175000017500000001145712471662307012616 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_QUICKSORT_H #define _AAPL_QUICKSORT_H #include "insertsort.h" #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \addtogroup sort * @{ */ /** * \class QuickSort * \brief Quick sort an array of data. * * QuickSort can be used to sort any array of objects of type T provided a * compare class is given. QuickSort is in-place. It does not require any * temporary storage. * * Objects are not made aware that they are being moved around in memory. * Assignment operators, constructors and destructors are never invoked by the * sort. * * QuickSort runs in O(n*log(n)) time in the average case. It is faster than * mergsort in the average case because it does less moving of data. The * performance of quicksort depends mostly on the choice of pivot. This * implementation picks the pivot as the median of first, middle, last. This * choice of pivot avoids the O(n^2) worst case for input already sorted, but * it is still possible to encounter the O(n^2) worst case. For example an * array of identical elements will run in O(n^2) * * QuickSort is not a stable sort. Elements with the same key will not have * their relative ordering preserved. QuickSort switches to an InsertSort * when the size of the array being sorted is small. This happens when * directly sorting a small array or when QuickSort calls iteself recursively * on a small portion of a larger array. */ /*@}*/ /* QuickSort. */ template class QuickSort : public InsertSort { public: /* Sorting interface routine. */ void sort(T *data, long len); private: /* Recursive worker. */ void doSort(T *start, T *end); T *partition(T *start, T *end); inline T *median(T *start, T *end); }; #define _QS_INSERTION_THRESH 16 /* Finds the median of start, middle, end. */ template T *QuickSort:: median(T *start, T *end) { T *pivot, *mid = start + (end-start)/2; /* CChoose the pivot. */ if ( compare(*start, *mid) < 0 ) { if ( compare(*mid, *end) < 0 ) pivot = mid; else if ( compare(*start, *end) < 0 ) pivot = end; else pivot = start; } else if ( compare(*start, *end) < 0 ) pivot = start; else if ( compare(*mid, *end) < 0 ) pivot = end; else pivot = mid; return pivot; } template T *QuickSort:: partition(T *start, T *end) { /* Use the median of start, middle, end as the pivot. First save * it off then move the last element to the free spot. */ char pcPivot[sizeof(T)]; T *pivot = median(start, end); memcpy( pcPivot, pivot, sizeof(T) ); if ( pivot != end ) memcpy( pivot, end, sizeof(T) ); T *first = start-1; T *last = end; pivot = (T*) pcPivot; /* Shuffle element to the correct side of the pivot, ending * up with the free spot where the pivot will go. */ while ( true ) { /* Throw one element ahead to the free spot at last. */ while ( true ) { first += 1; if ( first == last ) goto done; if ( compare( *first, *pivot ) > 0 ) { memcpy(last, first, sizeof(T)); break; } } /* Throw one element back to the free spot at first. */ while ( true ) { last -= 1; if ( last == first ) goto done; if ( compare( *last, *pivot ) < 0 ) { memcpy(first, last, sizeof(T)); break; } } } done: /* Put the pivot into the middle spot for it. */ memcpy( first, pivot, sizeof(T) ); return first; } template< class T, class Compare> void QuickSort:: doSort(T *start, T *end) { long len = end - start + 1; if ( len > _QS_INSERTION_THRESH ) { /* Use quicksort. */ T *pivot = partition( start, end ); doSort(start, pivot-1); doSort(pivot+1, end); } else if ( len > 1 ) { /* Array is small, use insertion sort. */ InsertSort::sort( start, len ); } } /** * \brief Quick sort an array of data. */ template< class T, class Compare> void QuickSort::sort(T *data, long len) { /* Call recursive worker. */ doSort(data, data+len-1); } #ifdef AAPL_NAMESPACE } #endif #endif /* _AAPL_QUICKSORT_H */ kelbt-0.16/aapl/sbsttable.h0000664000175000017500000000551612471662307012554 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_SBSTTABLE_H #define _AAPL_SBSTTABLE_H #include "compare.h" #include "svector.h" /** * \addtogroup bst * @{ */ /** * \class SBstTable * \brief Copy-on-write binary search table for structures that contain a key. * * This is a basic binary search table that employs a copy-on-write data * storage mechanism. It can be used to contain a structure that has a key and * possibly some data. The key should be a member of the element class and * accessible with getKey(). A class containing the compare routine must be * supplied. */ /*@}*/ #define BST_TEMPL_DECLARE class Element, class Key, \ class Compare = CmpOrd, class Resize = ResizeExpn #define BST_TEMPL_DEF class Element, class Key, class Compare, class Resize #define BST_TEMPL_USE Element, Key, Compare, Resize #define GET_KEY(el) ((el).getKey()) #define BstTable SBstTable #define Vector SVector #define Table STable #define BSTTABLE #define SHARED_BST #include "bstcommon.h" #undef BST_TEMPL_DECLARE #undef BST_TEMPL_DEF #undef BST_TEMPL_USE #undef GET_KEY #undef BstTable #undef Vector #undef Table #undef BSTTABLE #undef SHARED_BST /** * \fn SBstTable::insert(const Key &key, Element **lastFound) * \brief Insert a new element with the given key. * * If the given key does not already exist in the table a new element is * inserted with the given key. A constructor taking only const Key& is used * to initialize the new element. If lastFound is given, it is set to the new * element created. If the insert fails then lastFound is set to the existing * element with the same key. * * \returns The new element created upon success, null upon failure. */ /** * \fn SBstTable::insertMulti(const Key &key) * \brief Insert a new element even if the key exists already. * * If the key exists already then the new element is placed next to some * element with the same key. InsertMulti cannot fail. A constructor taking * only const Key& is used to initialize the new element. * * \returns The new element created. */ #endif /* _AAPL_SBSTTABLE_H */ kelbt-0.16/aapl/resize.h0000664000175000017500000002237012471662307012067 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_RESIZE_H #define _AAPL_RESIZE_H #include #ifdef AAPL_NAMESPACE namespace Aapl { #endif /* This step is expressed in units of T. Changing this requires changes to * docs in ResizeLin constructor. */ #define LIN_DEFAULT_STEP 256 /* * Resizing macros giving different resize methods. */ /* If needed is greater than existing, give twice needed. */ #define EXPN_UP( existing, needed ) \ needed > existing ? (needed<<1) : existing /* If needed is less than 1 quarter existing, give twice needed. */ #define EXPN_DOWN( existing, needed ) \ needed < (existing>>2) ? (needed<<1) : existing /* If needed is greater than existing, give needed plus step. */ #define LIN_UP( existing, needed ) \ needed > existing ? (needed+step) : existing /* If needed is less than existing - 2 * step then give needed plus step. */ #define LIN_DOWN( existing, needed ) \ needed < (existing-(step<<1)) ? (needed+step) : existing /* Return existing. */ #define CONST_UP( existing, needed ) existing /* Return existing. */ #define CONST_DOWN( existing, needed ) existing /** * \addtogroup vector * @{ */ /** \class ResizeLin * \brief Linear table resizer. * * When an up resize or a down resize is needed, ResizeLin allocates the space * needed plus some user defined step. The result is that when growing the * vector in a linear fashion, the number of resizes is also linear. * * If only up resizing is done, then there will never be more than step unused * spaces in the vector. If down resizing is done as well, there will never be * more than 2*step unused spaces in the vector. The up resizing and down * resizing policies are offset to improve performance when repeatedly * inserting and removing a small number of elements relative to the step. * This scheme guarantees that repetitive inserting and removing of a small * number of elements will never result in repetative reallocation. * * The vectors pass sizes to the resizer in units of T, so the step gets * interpreted as units of T. */ /*@}*/ /* Linear resizing. */ class ResizeLin { protected: /** * \brief Default constructor. * * Intializes resize step to 256 units of the table type T. */ ResizeLin() : step(LIN_DEFAULT_STEP) { } /** * \brief Determine the new table size when up resizing. * * If the existing size is insufficient for the space needed, then allocate * the space needed plus the step. The step is in units of T. */ inline long upResize( long existing, long needed ) { return LIN_UP(existing, needed); } /** * \brief Determine the new table size when down resizing. * * If space needed is less than the existing - 2*step, then allocate the * space needed space plus the step. The step is in units of T. */ inline long downResize( long existing, long needed ) { return LIN_DOWN(existing, needed); } public: /** * \brief Step for linear resize. * * Amount of extra space in units of T added each time a resize must take * place. This may be changed at any time. The step should be >= 0. */ long step; }; /** * \addtogroup vector * @{ */ /** \class ResizeCtLin * \brief Linear table resizer with compile time step. * * When an up resize or a down resize is needed, ResizeCtLin allocates the * space needed plus some compile time defined step. The result is that when * growing the vector in a linear fashion, the number of resizes is also * linear. * * If only up resizing is done, then there will never be more than step unused * spaces in the vector. If down resizing is done as well, there will never be * more than 2*step unused spaces in the vector. The up resizing and down * resizing policies are offset to improve performance when repeatedly * inserting and removing a small number of elements relative to the step. * This scheme guarantees that repetitive inserting and removing of a small * number of elements will never result in repetative reallocation. * * The vectors pass sizes to the resizer in units of T, so the step gets * interpreted as units of T. */ /*@}*/ /* Linear resizing. */ template class ResizeCtLin { protected: /** * \brief Determine the new table size when up resizing. * * If the existing size is insufficient for the space needed, then allocate * the space needed plus the step. The step is in units of T. */ inline long upResize( long existing, long needed ) { return LIN_UP(existing, needed); } /** * \brief Determine the new table size when down resizing. * * If space needed is less than the existing - 2*step, then allocate the * space needed space plus the step. The step is in units of T. */ inline long downResize( long existing, long needed ) { return LIN_DOWN(existing, needed); } }; /** * \addtogroup vector * @{ */ /** \class ResizeConst * \brief Constant table resizer. * * When an up resize is needed the existing size is always used. ResizeConst * does not allow dynamic resizing. To use ResizeConst, the vector needs to be * constructed with and initial allocation amount otherwise it will be * unusable. */ /*@}*/ /* Constant table resizing. */ class ResizeConst { protected: /* Assert don't need more than exists. Return existing. */ static inline long upResize( long existing, long needed ); /** * \brief Determine the new table size when down resizing. * * Always returns the existing table size. */ static inline long downResize( long existing, long needed ) { return CONST_DOWN(existing, needed); } }; /** * \brief Determine the new table size when up resizing. * * If the existing size is insufficient for the space needed, then an assertion * will fail. Otherwise returns the existing size. */ inline long ResizeConst::upResize( long existing, long needed ) { assert( needed <= existing ); return CONST_UP(existing, needed); } /** * \addtogroup vector * @{ */ /** \class ResizeRunTime * \brief Run time settable table resizer. * * ResizeRunTime can have it's up and down resizing policies set at run time. * Both up and down policies can be set independently to one of Exponential, * Linear, or Constant. See the documentation for ResizeExpn, ResizeLin, and * ResizeConst for the details of the resizing policies. * * The policies may be changed at any time. The default policies are * both Exponential. */ /*@}*/ /* Run time resizing. */ class ResizeRunTime { protected: /** * \brief Default constuctor. * * The up and down resizing it initialized to Exponetial. The step * defaults to 256 units of T. */ inline ResizeRunTime(); /** * \brief Resizing policies. */ enum ResizeType { Exponential, /*!< Exponential resizing. */ Linear, /*!< Linear resizing. */ Constant /*!< Constant table size. */ }; inline long upResize( long existing, long needed ); inline long downResize( long existing, long needed ); public: /** * \brief Step for linear resize. * * Amount of extra space in units of T added each time a resize must take * place. This may be changed at any time. The step should be >= 0. */ long step; /** * \brief Up resizing policy. */ ResizeType upResizeType; /** * \brief Down resizing policy. */ ResizeType downResizeType; }; inline ResizeRunTime::ResizeRunTime() : step( LIN_DEFAULT_STEP ), upResizeType( Exponential ), downResizeType( Exponential ) { } /** * \brief Determine the new table size when up resizing. * * Type of up resizing is determined by upResizeType. Exponential, Linear and * Constant resizing is the same as that of ResizeExpn, ResizeLin and * ResizeConst. */ inline long ResizeRunTime::upResize( long existing, long needed ) { switch ( upResizeType ) { case Exponential: return EXPN_UP(existing, needed); case Linear: return LIN_UP(existing, needed); case Constant: assert( needed <= existing ); return CONST_UP(existing, needed); } return 0; }; /** * \brief Determine the new table size when down resizing. * * Type of down resizing is determined by downResiizeType. Exponential, Linear * and Constant resizing is the same as that of ResizeExpn, ResizeLin and * ResizeConst. */ inline long ResizeRunTime::downResize( long existing, long needed ) { switch ( downResizeType ) { case Exponential: return EXPN_DOWN(existing, needed); case Linear: return LIN_DOWN(existing, needed); case Constant: return CONST_DOWN(existing, needed); } return 0; } /* Don't need these anymore. */ #undef EXPN_UP #undef EXPN_DOWN #undef LIN_UP #undef LIN_DOWN #undef CONST_UP #undef CONST_DOWN #ifdef AAPL_NAMESPACE } #endif #endif /* _AAPL_RESIZE_H */ kelbt-0.16/aapl/avlcommon.h0000664000175000017500000011636712471676202012572 00000000000000/* * Copyright 2001 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* This header is not wrapped in ifndef becuase it is not intended to * be included by the user. */ #include #ifdef AAPL_NAMESPACE namespace Aapl { #endif #ifdef WALKABLE /* This is used by AvlTree, AvlMel and AvlMelKey so it * must be protected by global ifdefs. */ #ifndef __AAPL_AVLI_EL__ #define __AAPL_AVLI_EL__ /** * \brief Tree element properties for linked AVL trees. * * AvliTreeEl needs to be inherited by classes that intend to be element in an * AvliTree. */ template struct AvliTreeEl { /** * \brief Tree pointers connecting element in a tree. */ SubClassEl *left, *right, *parent; /** * \brief Linked list pointers. */ SubClassEl *prev, *next; /** * \brief Height of the tree rooted at this element. * * Height is required by the AVL balancing algorithm. */ long height; }; #endif /* __AAPL_AVLI_EL__ */ #else /* not WALKABLE */ /* This is used by All the non walkable trees so it must be * protected by a global ifdef. */ #ifndef __AAPL_AVL_EL__ #define __AAPL_AVL_EL__ /** * \brief Tree element properties for linked AVL trees. * * AvlTreeEl needs to be inherited by classes that intend to be element in an * AvlTree. */ template struct AvlTreeEl { /** * \brief Tree pointers connecting element in a tree. */ SubClassEl *left, *right, *parent; /** * \brief Height of the tree rooted at this element. * * Height is required by the AVL balancing algorithm. */ long height; }; #endif /* __AAPL_AVL_EL__ */ #endif /* def WALKABLE */ #if defined( AVLTREE_MAP ) #ifdef WALKABLE /** * \brief Tree element for AvliMap * * Stores the key and value pair. */ template struct AvliMapEl : public AvliTreeEl< AvliMapEl > { AvliMapEl(const Key &key) : key(key) { } AvliMapEl(const Key &key, const Value &value) : key(key), value(value) { } const Key &getKey() const { return key; } /** \brief The key. */ Key key; /** \brief The value. */ Value value; }; #else /* not WALKABLE */ /** * \brief Tree element for AvlMap * * Stores the key and value pair. */ template struct AvlMapEl : public AvlTreeEl< AvlMapEl > { AvlMapEl(const Key &key) : key(key) { } AvlMapEl(const Key &key, const Value &value) : key(key), value(value) { } const Key &getKey() const { return key; } /** \brief The key. */ Key key; /** \brief The value. */ Value value; }; #endif /* def WALKABLE */ #elif defined( AVLTREE_SET ) #ifdef WALKABLE /** * \brief Tree element for AvliSet * * Stores the key. */ template struct AvliSetEl : public AvliTreeEl< AvliSetEl > { AvliSetEl(const Key &key) : key(key) { } const Key &getKey() const { return key; } /** \brief The key. */ Key key; }; #else /* not WALKABLE */ /** * \brief Tree element for AvlSet * * Stores the key. */ template struct AvlSetEl : public AvlTreeEl< AvlSetEl > { AvlSetEl(const Key &key) : key(key) { } const Key &getKey() const { return key; } /** \brief The key. */ Key key; }; #endif /* def WALKABLE */ #endif /* AVLTREE_SET */ /* Common AvlTree Class */ template < AVLMEL_CLASSDEF > class AvlTree #if !defined( AVL_KEYLESS ) && defined ( WALKABLE ) : public Compare, public BASELIST #elif !defined( AVL_KEYLESS ) : public Compare #elif defined( WALKABLE ) : public BASELIST #endif { public: /** * \brief Create an empty tree. */ #ifdef WALKABLE AvlTree() : root(0), treeSize(0) { } #else AvlTree() : root(0), head(0), tail(0), treeSize(0) { } #endif /** * \brief Perform a deep copy of the tree. * * Each element is duplicated for the new tree. Copy constructors are used * to create the new elements. */ AvlTree(const AvlTree &other); #if defined( AVLTREE_MAP ) || defined( AVLTREE_SET ) /** * \brief Clear the contents of the tree. * * All element are deleted. */ ~AvlTree() { empty(); } /** * \brief Perform a deep copy of the tree. * * Each element is duplicated for the new tree. Copy constructors are used * to create the new element. If this tree contains items, they are first * deleted. * * \returns A reference to this. */ AvlTree &operator=( const AvlTree &tree ); /** * \brief Transfer the elements of another tree into this. * * First deletes all elements in this tree. */ void transfer( AvlTree &tree ); #else /** * \brief Abandon all elements in the tree. * * Tree elements are not deleted. */ ~AvlTree() {} /** * \brief Perform a deep copy of the tree. * * Each element is duplicated for the new tree. Copy constructors are used * to create the new element. If this tree contains items, they are * abandoned. * * \returns A reference to this. */ AvlTree &operator=( const AvlTree &tree ); /** * \brief Transfer the elements of another tree into this. * * All elements in this tree are abandoned first. */ void transfer( AvlTree &tree ); #endif #ifndef AVL_KEYLESS /* Insert a element into the tree. */ Element *insert( Element *element, Element **lastFound = 0 ); #ifdef AVL_BASIC /* Find a element in the tree. Returns the element if * element exists, false otherwise. */ Element *find( const Element *element ) const; #else Element *insert( const Key &key, Element **lastFound = 0 ); #ifdef AVLTREE_MAP Element *insert( const Key &key, const Value &val, Element **lastFound = 0 ); #endif /* Find a element in the tree. Returns the element if * key exists, false otherwise. */ Element *find( const Key &key ) const; /* Detach a element from the tree. */ Element *detach( const Key &key ); /* Detach and delete a element from the tree. */ bool remove( const Key &key ); #endif /* AVL_BASIC */ #endif /* AVL_KEYLESS */ /* Detach a element from the tree. */ Element *detach( Element *element ); /* Detach and delete a element from the tree. */ void remove( Element *element ); /* Free all memory used by tree. */ void empty(); /* Abandon all element in the tree. Does not delete element. */ void abandon(); /** Root element of the tree. */ Element *root; #ifndef WALKABLE Element *head, *tail; #endif /** The number of element in the tree. */ long treeSize; /** \brief Return the number of elements in the tree. */ long length() const { return treeSize; } /** \brief Return the number of elements in the tree. */ long size() const { return treeSize; } /* Various classes for setting the iterator */ struct Iter; struct IterFirst { IterFirst( const AvlTree &t ) : t(t) { } const AvlTree &t; }; struct IterLast { IterLast( const AvlTree &t ) : t(t) { } const AvlTree &t; }; struct IterNext { IterNext( const Iter &i ) : i(i) { } const Iter &i; }; struct IterPrev { IterPrev( const Iter &i ) : i(i) { } const Iter &i; }; #ifdef WALKABLE /** * \brief Avl Tree Iterator. * \ingroup iterators */ struct Iter { /* Default construct. */ Iter() : ptr(0) { } /* Construct from an avl tree and iterator-setting classes. */ Iter( const AvlTree &t ) : ptr(t.head) { } Iter( const IterFirst &af ) : ptr(af.t.head) { } Iter( const IterLast &al ) : ptr(al.t.tail) { } Iter( const IterNext &an ) : ptr(findNext(an.i.ptr)) { } Iter( const IterPrev &ap ) : ptr(findPrev(ap.i.ptr)) { } /* Assign from a tree and iterator-setting classes. */ Iter &operator=( const AvlTree &tree ) { ptr = tree.head; return *this; } Iter &operator=( const IterFirst &af ) { ptr = af.t.head; return *this; } Iter &operator=( const IterLast &al ) { ptr = al.t.tail; return *this; } Iter &operator=( const IterNext &an ) { ptr = findNext(an.i.ptr); return *this; } Iter &operator=( const IterPrev &ap ) { ptr = findPrev(ap.i.ptr); return *this; } /** \brief Less than end? */ bool lte() const { return ptr != 0; } /** \brief At end? */ bool end() const { return ptr == 0; } /** \brief Greater than beginning? */ bool gtb() const { return ptr != 0; } /** \brief At beginning? */ bool beg() const { return ptr == 0; } /** \brief At first element? */ bool first() const { return ptr && ptr->BASE_EL(prev) == 0; } /** \brief At last element? */ bool last() const { return ptr && ptr->BASE_EL(next) == 0; } /** \brief Implicit cast to Element*. */ operator Element*() const { return ptr; } /** \brief Dereference operator returns Element&. */ Element &operator *() const { return *ptr; } /** \brief Arrow operator returns Element*. */ Element *operator->() const { return ptr; } /** \brief Move to next item. */ inline Element *operator++(); /** \brief Move to next item. */ inline Element *operator++(int); /** \brief Move to next item. */ inline Element *increment(); /** \brief Move to previous item. */ inline Element *operator--(); /** \brief Move to previous item. */ inline Element *operator--(int); /** \brief Move to previous item. */ inline Element *decrement(); /** \brief Return the next item. Does not modify this. */ IterNext next() const { return IterNext( *this ); } /** \brief Return the previous item. Does not modify this. */ IterPrev prev() const { return IterPrev( *this ); } private: static Element *findPrev( Element *element ) { return element->BASE_EL(prev); } static Element *findNext( Element *element ) { return element->BASE_EL(next); } public: /** \brief The iterator is simply a pointer. */ Element *ptr; }; #else /** * \brief Avl Tree Iterator. * \ingroup iterators */ struct Iter { /* Default construct. */ Iter() : ptr(0), tree(0) { } /* Construct from a tree and iterator-setting classes. */ Iter( const AvlTree &t ) : ptr(t.head), tree(&t) { } Iter( const IterFirst &af ) : ptr(af.t.head), tree(&af.t) { } Iter( const IterLast &al ) : ptr(al.t.tail), tree(&al.t) { } Iter( const IterNext &an ) : ptr(findNext(an.i.ptr)), tree(an.i.tree) { } Iter( const IterPrev &ap ) : ptr(findPrev(ap.i.ptr)), tree(ap.i.tree) { } /* Assign from a tree and iterator-setting classes. */ Iter &operator=( const AvlTree &t ) { ptr = t.head; tree = &t; return *this; } Iter &operator=( const IterFirst &af ) { ptr = af.t.head; tree = &af.t; return *this; } Iter &operator=( const IterLast &al ) { ptr = al.t.tail; tree = &al.t; return *this; } Iter &operator=( const IterNext &an ) { ptr = findNext(an.i.ptr); tree = an.i.tree; return *this; } Iter &operator=( const IterPrev &ap ) { ptr = findPrev(ap.i.ptr); tree = ap.i.tree; return *this; } /** \brief Less than end? */ bool lte() const { return ptr != 0; } /** \brief At end? */ bool end() const { return ptr == 0; } /** \brief Greater than beginning? */ bool gtb() const { return ptr != 0; } /** \brief At beginning? */ bool beg() const { return ptr == 0; } /** \brief At first element? */ bool first() const { return ptr && ptr == tree->head; } /** \brief At last element? */ bool last() const { return ptr && ptr == tree->tail; } /** \brief Implicit cast to Element*. */ operator Element*() const { return ptr; } /** \brief Dereference operator returns Element&. */ Element &operator *() const { return *ptr; } /** \brief Arrow operator returns Element*. */ Element *operator->() const { return ptr; } /** \brief Move to next item. */ inline Element *operator++(); /** \brief Move to next item. */ inline Element *operator++(int); /** \brief Move to next item. */ inline Element *increment(); /** \brief Move to previous item. */ inline Element *operator--(); /** \brief Move to previous item. */ inline Element *operator--(int); /** \brief Move to previous item. */ inline Element *decrement(); /** \brief Return the next item. Does not modify this. */ IterNext next() const { return IterNext( *this ); } /** \brief Return the previous item. Does not modify this. */ IterPrev prev() const { return IterPrev( *this ); } private: static Element *findPrev( Element *element ); static Element *findNext( Element *element ); public: /** \brief The iterator is simply a pointer. */ Element *ptr; /* The list is not walkable so we need to keep a pointerto the tree * so we can test against head and tail in O(1) time. */ const AvlTree *tree; }; #endif /** \brief Return first element. */ IterFirst first() { return IterFirst( *this ); } /** \brief Return last element. */ IterLast last() { return IterLast( *this ); } protected: /* Recursive worker for the copy constructor. */ Element *copyBranch( Element *element ); /* Recursively delete element in the tree. */ void deleteChildrenOf(Element *n); /* rebalance the tree beginning at the leaf whose * grandparent is unbalanced. */ Element *rebalance(Element *start); /* Move up the tree from a given element, recalculating the heights. */ void recalcHeights(Element *start); /* Move up the tree and find the first element whose * grand-parent is unbalanced. */ Element *findFirstUnbalGP(Element *start); /* Move up the tree and find the first element which is unbalanced. */ Element *findFirstUnbalEl(Element *start); /* Replace a element in the tree with another element not in the tree. */ void replaceEl(Element *element, Element *replacement); /* Remove a element from the tree and put another (normally a child of element) * in its place. */ void removeEl(Element *element, Element *filler); /* Once an insertion point is found at a leaf then do the insert. */ void attachRebal( Element *element, Element *parentEl, Element *lastLess ); }; /* Copy constructor. New up each item. */ template AvlTree:: AvlTree(const AvlTree &other) #ifdef WALKABLE : /* Make an empty list, copyBranch will fill in the details for us. */ BASELIST() #endif { treeSize = other.treeSize; root = other.root; #ifndef WALKABLE head = 0; tail = 0; #endif /* If there is a root, copy the tree. */ if ( other.root != 0 ) root = copyBranch( other.root ); } #if defined( AVLTREE_MAP ) || defined( AVLTREE_SET ) /* Assignment does deep copy. */ template AvlTree &AvlTree:: operator=( const AvlTree &other ) { /* Clear the tree first. */ empty(); /* Reset the list pointers, the tree copy will fill in the list for us. */ #ifdef WALKABLE BASELIST::abandon(); #else head = 0; tail = 0; #endif /* Copy the entire tree. */ treeSize = other.treeSize; root = other.root; if ( other.root != 0 ) root = copyBranch( other.root ); return *this; } template void AvlTree:: transfer(AvlTree &other) { /* Clear the tree first. */ empty(); treeSize = other.treeSize; root = other.root; #ifdef WALKABLE BASELIST::head = other.BASELIST::head; BASELIST::tail = other.BASELIST::tail; BASELIST::listLen = other.BASELIST::listLen; #else head = other.head; tail = other.tail; #endif other.abandon(); } #else /* ! AVLTREE_MAP && ! AVLTREE_SET */ /* Assignment does deep copy. This version does not clear the tree first. */ template AvlTree &AvlTree:: operator=( const AvlTree &other ) { /* Reset the list pointers, the tree copy will fill in the list for us. */ #ifdef WALKABLE BASELIST::abandon(); #else head = 0; tail = 0; #endif /* Copy the entire tree. */ treeSize = other.treeSize; root = other.root; if ( other.root != 0 ) root = copyBranch( other.root ); return *this; } template void AvlTree:: transfer(AvlTree &other) { treeSize = other.treeSize; root = other.root; #ifdef WALKABLE BASELIST::head = other.BASELIST::head; BASELIST::tail = other.BASELIST::tail; BASELIST::listLen = other.BASELIST::listLen; #else head = other.head; tail = other.tail; #endif other.abandon(); } #endif /* * Iterator operators. */ /* Prefix ++ */ template Element *AvlTree::Iter:: operator++() { return ptr = findNext( ptr ); } /* Postfix ++ */ template Element *AvlTree::Iter:: operator++(int) { Element *rtn = ptr; ptr = findNext( ptr ); return rtn; } /* increment */ template Element *AvlTree::Iter:: increment() { return ptr = findNext( ptr ); } /* Prefix -- */ template Element *AvlTree::Iter:: operator--() { return ptr = findPrev( ptr ); } /* Postfix -- */ template Element *AvlTree::Iter:: operator--(int) { Element *rtn = ptr; ptr = findPrev( ptr ); return rtn; } /* decrement */ template Element *AvlTree::Iter:: decrement() { return ptr = findPrev( ptr ); } #ifndef WALKABLE /* Move ahead one. */ template Element *AvlTree::Iter:: findNext( Element *element ) { /* Try to go right once then infinite left. */ if ( element->BASE_EL(right) != 0 ) { element = element->BASE_EL(right); while ( element->BASE_EL(left) != 0 ) element = element->BASE_EL(left); } else { /* Go up to parent until we were just a left child. */ while ( true ) { Element *last = element; element = element->BASE_EL(parent); if ( element == 0 || element->BASE_EL(left) == last ) break; } } return element; } /* Move back one. */ template Element *AvlTree::Iter:: findPrev( Element *element ) { /* Try to go left once then infinite right. */ if ( element->BASE_EL(left) != 0 ) { element = element->BASE_EL(left); while ( element->BASE_EL(right) != 0 ) element = element->BASE_EL(right); } else { /* Go up to parent until we were just a left child. */ while ( true ) { Element *last = element; element = element->BASE_EL(parent); if ( element == 0 || element->BASE_EL(right) == last ) break; } } return element; } #endif /* Recursive worker for tree copying. */ template Element *AvlTree:: copyBranch( Element *element ) { /* Duplicate element. Either the base element's copy constructor or defaul * constructor will get called. Both will suffice for initting the * pointers to null when they need to be. */ Element *retVal = new Element(*element); /* If the left tree is there, copy it. */ if ( retVal->BASE_EL(left) ) { retVal->BASE_EL(left) = copyBranch(retVal->BASE_EL(left)); retVal->BASE_EL(left)->BASE_EL(parent) = retVal; } #ifdef WALKABLE BASELIST::addAfter( BASELIST::tail, retVal ); #else if ( head == 0 ) head = retVal; tail = retVal; #endif /* If the right tree is there, copy it. */ if ( retVal->BASE_EL(right) ) { retVal->BASE_EL(right) = copyBranch(retVal->BASE_EL(right)); retVal->BASE_EL(right)->BASE_EL(parent) = retVal; } return retVal; } /* Once an insertion position is found, attach a element to the tree. */ template void AvlTree:: attachRebal( Element *element, Element *parentEl, Element *lastLess ) { /* Increment the number of element in the tree. */ treeSize += 1; /* Set element's parent. */ element->BASE_EL(parent) = parentEl; /* New element always starts as a leaf with height 1. */ element->BASE_EL(left) = 0; element->BASE_EL(right) = 0; element->BASE_EL(height) = 1; /* Are we inserting in the tree somewhere? */ if ( parentEl != 0 ) { /* We have a parent so we are somewhere in the tree. If the parent * equals lastLess, then the last traversal in the insertion went * left, otherwise it went right. */ if ( lastLess == parentEl ) { parentEl->BASE_EL(left) = element; #ifdef WALKABLE BASELIST::addBefore( parentEl, element ); #endif } else { parentEl->BASE_EL(right) = element; #ifdef WALKABLE BASELIST::addAfter( parentEl, element ); #endif } #ifndef WALKABLE /* Maintain the first and last pointers. */ if ( head->BASE_EL(left) == element ) head = element; /* Maintain the first and last pointers. */ if ( tail->BASE_EL(right) == element ) tail = element; #endif } else { /* No parent element so we are inserting the root. */ root = element; #ifdef WALKABLE BASELIST::addAfter( BASELIST::tail, element ); #else head = tail = element; #endif } /* Recalculate the heights. */ recalcHeights(parentEl); /* Find the first unbalance. */ Element *ub = findFirstUnbalGP(element); /* rebalance. */ if ( ub != 0 ) { /* We assert that after this single rotation the * tree is now properly balanced. */ rebalance(ub); } } #ifndef AVL_KEYLESS /** * \brief Insert an existing element into the tree. * * If the insert succeeds and lastFound is given then it is set to the element * inserted. If the insert fails then lastFound is set to the existing element in * the tree that has the same key as element. If the element's avl pointers are * already in use then undefined behaviour results. * * \returns The element inserted upon success, null upon failure. */ template Element *AvlTree:: insert( Element *element, Element **lastFound ) { long keyRelation; Element *curEl = root, *parentEl = 0; Element *lastLess = 0; while (true) { if ( curEl == 0 ) { /* We are at an external element and did not find the key we were * looking for. Attach underneath the leaf and rebalance. */ attachRebal( element, parentEl, lastLess ); if ( lastFound != 0 ) *lastFound = element; return element; } #ifdef AVL_BASIC keyRelation = this->compare( *element, *curEl ); #else keyRelation = this->compare( element->BASEKEY(getKey()), curEl->BASEKEY(getKey()) ); #endif /* Do we go left? */ if ( keyRelation < 0 ) { parentEl = lastLess = curEl; curEl = curEl->BASE_EL(left); } /* Do we go right? */ else if ( keyRelation > 0 ) { parentEl = curEl; curEl = curEl->BASE_EL(right); } /* We have hit the target. */ else { if ( lastFound != 0 ) *lastFound = curEl; return 0; } } } #ifdef AVL_BASIC /** * \brief Find a element in the tree with the given key. * * \returns The element if key exists, null if the key does not exist. */ template Element *AvlTree:: find( const Element *element ) const { Element *curEl = root; long keyRelation; while (curEl) { keyRelation = compare( *element, *curEl ); /* Do we go left? */ if ( keyRelation < 0 ) curEl = curEl->BASE_EL(left); /* Do we go right? */ else if ( keyRelation > 0 ) curEl = curEl->BASE_EL(right); /* We have hit the target. */ else { return curEl; } } return 0; } #else /** * \brief Insert a new element into the tree with given key. * * If the key is not already in the tree then a new element is made using the * Element(const Key &key) constructor and the insert succeeds. If lastFound is * given then it is set to the element inserted. If the insert fails then * lastFound is set to the existing element in the tree that has the same key as * element. * * \returns The new element upon success, null upon failure. */ template Element *AvlTree:: insert( const Key &key, Element **lastFound ) { long keyRelation; Element *curEl = root, *parentEl = 0; Element *lastLess = 0; while (true) { if ( curEl == 0 ) { /* We are at an external element and did not find the key we were * looking for. Create the new element, attach it underneath the leaf * and rebalance. */ Element *element = new Element( key ); attachRebal( element, parentEl, lastLess ); if ( lastFound != 0 ) *lastFound = element; return element; } keyRelation = this->compare( key, curEl->BASEKEY(getKey()) ); /* Do we go left? */ if ( keyRelation < 0 ) { parentEl = lastLess = curEl; curEl = curEl->BASE_EL(left); } /* Do we go right? */ else if ( keyRelation > 0 ) { parentEl = curEl; curEl = curEl->BASE_EL(right); } /* We have hit the target. */ else { if ( lastFound != 0 ) *lastFound = curEl; return 0; } } } #ifdef AVLTREE_MAP /** * \brief Insert a new element into the tree with key and value. * * If the key is not already in the tree then a new element is constructed and * the insert succeeds. If lastFound is given then it is set to the element * inserted. If the insert fails then lastFound is set to the existing element in * the tree that has the same key as element. This insert routine is only * available in AvlMap because it is the only class that knows about a Value * type. * * \returns The new element upon success, null upon failure. */ template Element *AvlTree:: insert( const Key &key, const Value &val, Element **lastFound ) { long keyRelation; Element *curEl = root, *parentEl = 0; Element *lastLess = 0; while (true) { if ( curEl == 0 ) { /* We are at an external element and did not find the key we were * looking for. Create the new element, attach it underneath the leaf * and rebalance. */ Element *element = new Element( key, val ); attachRebal( element, parentEl, lastLess ); if ( lastFound != 0 ) *lastFound = element; return element; } keyRelation = this->compare(key, curEl->getKey()); /* Do we go left? */ if ( keyRelation < 0 ) { parentEl = lastLess = curEl; curEl = curEl->BASE_EL(left); } /* Do we go right? */ else if ( keyRelation > 0 ) { parentEl = curEl; curEl = curEl->BASE_EL(right); } /* We have hit the target. */ else { if ( lastFound != 0 ) *lastFound = curEl; return 0; } } } #endif /* AVLTREE_MAP */ /** * \brief Find a element in the tree with the given key. * * \returns The element if key exists, null if the key does not exist. */ template Element *AvlTree:: find( const Key &key ) const { Element *curEl = root; long keyRelation; while (curEl) { keyRelation = this->compare( key, curEl->BASEKEY(getKey()) ); /* Do we go left? */ if ( keyRelation < 0 ) curEl = curEl->BASE_EL(left); /* Do we go right? */ else if ( keyRelation > 0 ) curEl = curEl->BASE_EL(right); /* We have hit the target. */ else { return curEl; } } return 0; } /** * \brief Find a element, then detach it from the tree. * * The element is not deleted. * * \returns The element detached if the key is found, othewise returns null. */ template Element *AvlTree:: detach(const Key &key) { Element *element = find( key ); if ( element ) { detach(element); } return element; } /** * \brief Find, detach and delete a element from the tree. * * \returns True if the element was found and deleted, false otherwise. */ template bool AvlTree:: remove(const Key &key) { /* Assume not found. */ bool retVal = false; /* Look for the key. */ Element *element = find( key ); if ( element != 0 ) { /* If found, detach the element and delete. */ detach( element ); delete element; retVal = true; } return retVal; } #endif /* AVL_BASIC */ #endif /* AVL_KEYLESS */ /** * \brief Detach and delete a element from the tree. * * If the element is not in the tree then undefined behaviour results. */ template void AvlTree:: remove(Element *element) { /* Detach and delete. */ detach(element); delete element; } /** * \brief Detach a element from the tree. * * If the element is not in the tree then undefined behaviour results. * * \returns The element given. */ template Element *AvlTree:: detach(Element *element) { Element *replacement, *fixfrom; long lheight, rheight; #ifdef WALKABLE /* Remove the element from the ordered list. */ BASELIST::detach( element ); #endif /* Update treeSize. */ treeSize--; /* Find a replacement element. */ if (element->BASE_EL(right)) { /* Find the leftmost element of the right subtree. */ replacement = element->BASE_EL(right); while (replacement->BASE_EL(left)) replacement = replacement->BASE_EL(left); /* If replacing the element the with its child then we need to start * fixing at the replacement, otherwise we start fixing at the * parent of the replacement. */ if (replacement->BASE_EL(parent) == element) fixfrom = replacement; else fixfrom = replacement->BASE_EL(parent); #ifndef WALKABLE if ( element == head ) head = replacement; #endif removeEl(replacement, replacement->BASE_EL(right)); replaceEl(element, replacement); } else if (element->BASE_EL(left)) { /* Find the rightmost element of the left subtree. */ replacement = element->BASE_EL(left); while (replacement->BASE_EL(right)) replacement = replacement->BASE_EL(right); /* If replacing the element the with its child then we need to start * fixing at the replacement, otherwise we start fixing at the * parent of the replacement. */ if (replacement->BASE_EL(parent) == element) fixfrom = replacement; else fixfrom = replacement->BASE_EL(parent); #ifndef WALKABLE if ( element == tail ) tail = replacement; #endif removeEl(replacement, replacement->BASE_EL(left)); replaceEl(element, replacement); } else { /* We need to start fixing at the parent of the element. */ fixfrom = element->BASE_EL(parent); #ifndef WALKABLE if ( element == head ) head = element->BASE_EL(parent); if ( element == tail ) tail = element->BASE_EL(parent); #endif /* The element we are deleting is a leaf element. */ removeEl(element, 0); } /* If fixfrom is null it means we just deleted * the root of the tree. */ if ( fixfrom == 0 ) return element; /* Fix the heights after the deletion. */ recalcHeights(fixfrom); /* Fix every unbalanced element going up in the tree. */ Element *ub = findFirstUnbalEl(fixfrom); while ( ub ) { /* Find the element to rebalance by moving down from the first unbalanced * element 2 levels in the direction of the greatest heights. On the * second move down, the heights may be equal ( but not on the first ). * In which case go in the direction of the first move. */ lheight = ub->BASE_EL(left) ? ub->BASE_EL(left)->BASE_EL(height) : 0; rheight = ub->BASE_EL(right) ? ub->BASE_EL(right)->BASE_EL(height) : 0; assert( lheight != rheight ); if (rheight > lheight) { ub = ub->BASE_EL(right); lheight = ub->BASE_EL(left) ? ub->BASE_EL(left)->BASE_EL(height) : 0; rheight = ub->BASE_EL(right) ? ub->BASE_EL(right)->BASE_EL(height) : 0; if (rheight > lheight) ub = ub->BASE_EL(right); else if (rheight < lheight) ub = ub->BASE_EL(left); else ub = ub->BASE_EL(right); } else { ub = ub->BASE_EL(left); lheight = ub->BASE_EL(left) ? ub->BASE_EL(left)->BASE_EL(height) : 0; rheight = ub->BASE_EL(right) ? ub->BASE_EL(right)->BASE_EL(height) : 0; if (rheight > lheight) ub = ub->BASE_EL(right); else if (rheight < lheight) ub = ub->BASE_EL(left); else ub = ub->BASE_EL(left); } /* rebalance returns the grandparant of the subtree formed * by the element that were rebalanced. * We must continue upward from there rebalancing. */ fixfrom = rebalance(ub); /* Find the next unbalaced element. */ ub = findFirstUnbalEl(fixfrom); } return element; } /** * \brief Empty the tree and delete all the element. * * Resets the tree to its initial state. */ template void AvlTree::empty() { if ( root ) { /* Recursively delete from the tree structure. */ deleteChildrenOf(root); delete root; root = 0; treeSize = 0; #ifdef WALKABLE BASELIST::abandon(); #endif } } /** * \brief Forget all element in the tree. * * Does not delete element. Resets the the tree to it's initial state. */ template void AvlTree::abandon() { root = 0; treeSize = 0; #ifdef WALKABLE BASELIST::abandon(); #endif } /* Recursively delete all the children of a element. */ template void AvlTree:: deleteChildrenOf( Element *element ) { /* Recurse left. */ if (element->BASE_EL(left)) { deleteChildrenOf(element->BASE_EL(left)); /* Delete left element. */ delete element->BASE_EL(left); element->BASE_EL(left) = 0; } /* Recurse right. */ if (element->BASE_EL(right)) { deleteChildrenOf(element->BASE_EL(right)); /* Delete right element. */ delete element->BASE_EL(right); element->BASE_EL(left) = 0; } } /* rebalance from a element whose gradparent is unbalanced. Only * call on a element that has a grandparent. */ template Element *AvlTree:: rebalance(Element *n) { long lheight, rheight; Element *a, *b, *c; Element *t1, *t2, *t3, *t4; Element *p = n->BASE_EL(parent); /* parent (Non-NUL). L*/ Element *gp = p->BASE_EL(parent); /* Grand-parent (Non-NULL). */ Element *ggp = gp->BASE_EL(parent); /* Great grand-parent (may be NULL). */ if (gp->BASE_EL(right) == p) { /* gp * \ * p */ if (p->BASE_EL(right) == n) { /* gp * \ * p * \ * n */ a = gp; b = p; c = n; t1 = gp->BASE_EL(left); t2 = p->BASE_EL(left); t3 = n->BASE_EL(left); t4 = n->BASE_EL(right); } else { /* gp * \ * p * / * n */ a = gp; b = n; c = p; t1 = gp->BASE_EL(left); t2 = n->BASE_EL(left); t3 = n->BASE_EL(right); t4 = p->BASE_EL(right); } } else { /* gp * / * p */ if (p->BASE_EL(right) == n) { /* gp * / * p * \ * n */ a = p; b = n; c = gp; t1 = p->BASE_EL(left); t2 = n->BASE_EL(left); t3 = n->BASE_EL(right); t4 = gp->BASE_EL(right); } else { /* gp * / * p * / * n */ a = n; b = p; c = gp; t1 = n->BASE_EL(left); t2 = n->BASE_EL(right); t3 = p->BASE_EL(right); t4 = gp->BASE_EL(right); } } /* Perform rotation. */ /* Tie b to the great grandparent. */ if ( ggp == 0 ) root = b; else if ( ggp->BASE_EL(left) == gp ) ggp->BASE_EL(left) = b; else ggp->BASE_EL(right) = b; b->BASE_EL(parent) = ggp; /* Tie a as a leftchild of b. */ b->BASE_EL(left) = a; a->BASE_EL(parent) = b; /* Tie c as a rightchild of b. */ b->BASE_EL(right) = c; c->BASE_EL(parent) = b; /* Tie t1 as a leftchild of a. */ a->BASE_EL(left) = t1; if ( t1 != 0 ) t1->BASE_EL(parent) = a; /* Tie t2 as a rightchild of a. */ a->BASE_EL(right) = t2; if ( t2 != 0 ) t2->BASE_EL(parent) = a; /* Tie t3 as a leftchild of c. */ c->BASE_EL(left) = t3; if ( t3 != 0 ) t3->BASE_EL(parent) = c; /* Tie t4 as a rightchild of c. */ c->BASE_EL(right) = t4; if ( t4 != 0 ) t4->BASE_EL(parent) = c; /* The heights are all recalculated manualy and the great * grand-parent is passed to recalcHeights() to ensure * the heights are correct up the tree. * * Note that recalcHeights() cuts out when it comes across * a height that hasn't changed. */ /* Fix height of a. */ lheight = a->BASE_EL(left) ? a->BASE_EL(left)->BASE_EL(height) : 0; rheight = a->BASE_EL(right) ? a->BASE_EL(right)->BASE_EL(height) : 0; a->BASE_EL(height) = (lheight > rheight ? lheight : rheight) + 1; /* Fix height of c. */ lheight = c->BASE_EL(left) ? c->BASE_EL(left)->BASE_EL(height) : 0; rheight = c->BASE_EL(right) ? c->BASE_EL(right)->BASE_EL(height) : 0; c->BASE_EL(height) = (lheight > rheight ? lheight : rheight) + 1; /* Fix height of b. */ lheight = a->BASE_EL(height); rheight = c->BASE_EL(height); b->BASE_EL(height) = (lheight > rheight ? lheight : rheight) + 1; /* Fix height of b's parents. */ recalcHeights(ggp); return ggp; } /* Recalculates the heights of all the ancestors of element. */ template void AvlTree:: recalcHeights(Element *element) { long lheight, rheight, new_height; while ( element != 0 ) { lheight = element->BASE_EL(left) ? element->BASE_EL(left)->BASE_EL(height) : 0; rheight = element->BASE_EL(right) ? element->BASE_EL(right)->BASE_EL(height) : 0; new_height = (lheight > rheight ? lheight : rheight) + 1; /* If there is no chage in the height, then there will be no * change in any of the ancestor's height. We can stop going up. * If there was a change, continue upward. */ if (new_height == element->BASE_EL(height)) return; else element->BASE_EL(height) = new_height; element = element->BASE_EL(parent); } } /* Finds the first element whose grandparent is unbalanced. */ template Element *AvlTree:: findFirstUnbalGP(Element *element) { long lheight, rheight, balanceProp; Element *gp; if ( element == 0 || element->BASE_EL(parent) == 0 || element->BASE_EL(parent)->BASE_EL(parent) == 0 ) return 0; /* Don't do anything if we we have no grandparent. */ gp = element->BASE_EL(parent)->BASE_EL(parent); while ( gp != 0 ) { lheight = gp->BASE_EL(left) ? gp->BASE_EL(left)->BASE_EL(height) : 0; rheight = gp->BASE_EL(right) ? gp->BASE_EL(right)->BASE_EL(height) : 0; balanceProp = lheight - rheight; if ( balanceProp < -1 || balanceProp > 1 ) return element; element = element->BASE_EL(parent); gp = gp->BASE_EL(parent); } return 0; } /* Finds the first element that is unbalanced. */ template Element *AvlTree:: findFirstUnbalEl(Element *element) { if ( element == 0 ) return 0; while ( element != 0 ) { long lheight = element->BASE_EL(left) ? element->BASE_EL(left)->BASE_EL(height) : 0; long rheight = element->BASE_EL(right) ? element->BASE_EL(right)->BASE_EL(height) : 0; long balanceProp = lheight - rheight; if ( balanceProp < -1 || balanceProp > 1 ) return element; element = element->BASE_EL(parent); } return 0; } /* Replace a element in the tree with another element not in the tree. */ template void AvlTree:: replaceEl(Element *element, Element *replacement) { Element *parent = element->BASE_EL(parent), *left = element->BASE_EL(left), *right = element->BASE_EL(right); replacement->BASE_EL(left) = left; if (left) left->BASE_EL(parent) = replacement; replacement->BASE_EL(right) = right; if (right) right->BASE_EL(parent) = replacement; replacement->BASE_EL(parent) = parent; if (parent) { if (parent->BASE_EL(left) == element) parent->BASE_EL(left) = replacement; else parent->BASE_EL(right) = replacement; } else root = replacement; replacement->BASE_EL(height) = element->BASE_EL(height); } /* Removes a element from a tree and puts filler in it's place. * Filler should be null or a child of element. */ template void AvlTree:: removeEl(Element *element, Element *filler) { Element *parent = element->BASE_EL(parent); if (parent) { if (parent->BASE_EL(left) == element) parent->BASE_EL(left) = filler; else parent->BASE_EL(right) = filler; } else root = filler; if (filler) filler->BASE_EL(parent) = parent; return; } #ifdef AAPL_NAMESPACE } #endif kelbt-0.16/aapl/avlimap.h0000664000175000017500000000433712471662307012222 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLIMAP_H #define _AAPL_AVLIMAP_H #include "compare.h" #include "dlist.h" /** * \addtogroup avlitree * @{ */ /** * \class AvliMap * \brief Linked key and value oriented AVL tree. * * AvliMap stores key and value pairs in elements that managed by the tree. It * is intendend to be similar to map template found in the STL. AvliMap * requires that a Key type, a Value type, and a class containing a compare() * routine for Key be given. Items can be inserted with just a key or with a * key and value pair. * * AvliMap assumes all elements in the tree are allocated on the heap and are * to be managed by the tree. This means that the class destructor will delete * the contents of the tree. A deep copy will cause existing elements to be * deleted first. * * \include ex_avlimap.cpp */ /*@}*/ #define AVLTREE_MAP #define BASE_EL(name) name #define BASEKEY(name) name #define BASELIST DList< AvliMapEl > #define AVLMEL_CLASSDEF class Key, class Value, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Key, class Value, class Compare #define AVLMEL_TEMPUSE Key, Value, Compare #define AvlTree AvliMap #define Element AvliMapEl #define WALKABLE #include "avlcommon.h" #undef AVLTREE_MAP #undef BASE_EL #undef BASEKEY #undef BASELIST #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef Element #undef WALKABLE #endif /* _AAPL_AVLIMAP_H */ kelbt-0.16/aapl/Makefile.am0000664000175000017500000000067112471723172012447 00000000000000noinst_HEADERS = \ avlbasic.h avlimel.h avlmap.h bstcommon.h compare.h insertsort.h \ sbstset.h avlcommon.h avlimelkey.h avlmel.h bstmap.h dlcommon.h \ mergesort.h sbsttable.h avlibasic.h avliset.h avlmelkey.h bstset.h \ dlist.h quicksort.h svector.h avlikeyless.h avlitree.h avlset.h \ bsttable.h dlistmel.h resize.h table.h avlimap.h avlkeyless.h avltree.h \ bubblesort.h dlistval.h sbstmap.h vector.h EXTRA_DIST = README COPYING kelbt-0.16/aapl/avlset.h0000664000175000017500000000366412471662307012071 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLSET_H #define _AAPL_AVLSET_H #include "compare.h" /** * \addtogroup avltree * @{ */ /** * \class AvlSet * \brief Key-only oriented tree. * * AvlSet stores only keys in elements that are managed by the tree. AvlSet * requires that a Key type and a class containing a compare() routine * for Key be given. Items are inserted with just a key value. * * AvlSet assumes all elements in the tree are allocated on the heap and are * to be managed by the tree. This means that the class destructor will delete * the contents of the tree. A deep copy will cause existing elements to be * deleted first. * * \include ex_avlset.cpp */ /*@}*/ #define AVLTREE_SET #define BASE_EL(name) name #define BASEKEY(name) name #define AVLMEL_CLASSDEF class Key, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Key, class Compare #define AVLMEL_TEMPUSE Key, Compare #define AvlTree AvlSet #define Element AvlSetEl #include "avlcommon.h" #undef AVLTREE_SET #undef BASE_EL #undef BASEKEY #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef Element #endif /* _AAPL_AVLSET_H */ kelbt-0.16/aapl/avlmap.h0000664000175000017500000000413412471662307012044 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLMAP_H #define _AAPL_AVLMAP_H #include "compare.h" /** * \addtogroup avltree * @{ */ /** * \class AvlMap * \brief Key and value oriented AVL tree. * * AvlMap stores key and value pairs in elements that managed by the tree. It * is intendend to be similar to map template found in the STL. AvlMap * requires that a Key type, a Value type, and a class containing a compare() * routine for Key be given. Items can be inserted with just a key or with a * key and value pair. * * AvlMap assumes all elements in the tree are allocated on the heap and are * to be managed by the tree. This means that the class destructor will delete * the contents of the tree. A deep copy will cause existing elements to be * deleted first. * * \include ex_avlmap.cpp */ /*@}*/ #define AVLTREE_MAP #define BASE_EL(name) name #define BASEKEY(name) name #define AVLMEL_CLASSDEF class Key, class Value, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Key, class Value, class Compare #define AVLMEL_TEMPUSE Key, Value, Compare #define AvlTree AvlMap #define Element AvlMapEl #include "avlcommon.h" #undef AVLTREE_MAP #undef BASE_EL #undef BASEKEY #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef Element #endif /* _AAPL_AVLMAP_H */ kelbt-0.16/aapl/mergesort.h0000664000175000017500000000736612471662307012605 00000000000000/* * Copyright 2001, 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_MERGESORT_H #define _AAPL_MERGESORT_H #include "bubblesort.h" #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \addtogroup sort * @{ */ /** * \class MergeSort * \brief Merge sort an array of data. * * MergeSort can be used to sort any array of objects of type T provided a * compare class is given. MergeSort is not in-place, it requires temporary * storage equal to the size of the array. The temporary storage is allocated * on the heap. * * Objects are not made aware that they are being moved around in memory. * Assignment operators, constructors and destructors are never invoked by the * sort. * * MergeSort runs in worst case O(n*log(n)) time. In most cases it is slower * than QuickSort because more copying is neccessary. But on the other hand, * it is a stable sort, meaning that objects with the same key have their * relative ordering preserved. Also, its worst case is better. MergeSort * switches to a BubbleSort when the size of the array being sorted is small. * This happens when directly sorting a small array or when MergeSort calls * itself recursively on a small portion of a larger array. */ /*@}*/ /* MergeSort. */ template class MergeSort : public BubbleSort { public: /* Sorting interface routine. */ void sort(T *data, long len); private: /* Recursive worker. */ void doSort(T *tmpStor, T *data, long len); }; #define _MS_BUBBLE_THRESH 16 /* Recursive mergesort worker. Split data, make recursive calls, merge * results. */ template< class T, class Compare> void MergeSort:: doSort(T *tmpStor, T *data, long len) { if ( len <= 1 ) return; if ( len <= _MS_BUBBLE_THRESH ) { BubbleSort::sort( data, len ); return; } long mid = len / 2; doSort( tmpStor, data, mid ); doSort( tmpStor + mid, data + mid, len - mid ); /* Merge the data. */ T *endLower = data + mid, *lower = data; T *endUpper = data + len, *upper = data + mid; T *dest = tmpStor; while ( true ) { if ( lower == endLower ) { /* Possibly upper left. */ if ( upper != endUpper ) memcpy( dest, upper, (endUpper - upper) * sizeof(T) ); break; } else if ( upper == endUpper ) { /* Only lower left. */ if ( lower != endLower ) memcpy( dest, lower, (endLower - lower) * sizeof(T) ); break; } else { /* Both upper and lower left. */ if ( compare(*lower, *upper) <= 0 ) memcpy( dest++, lower++, sizeof(T) ); else memcpy( dest++, upper++, sizeof(T) ); } } /* Copy back from the tmpStor array. */ memcpy( data, tmpStor, sizeof( T ) * len ); } /** * \brief Merge sort an array of data. */ template< class T, class Compare> void MergeSort::sort(T *data, long len) { /* Allocate the tmp space needed by merge sort, sort and free. */ T *tmpStor = (T*) new char[sizeof(T) * len]; doSort( tmpStor, data, len ); delete[] (char*) tmpStor; } #ifdef AAPL_NAMESPACE } #endif #endif /* _AAPL_MERGESORT_H */ kelbt-0.16/aapl/avlibasic.h0000664000175000017500000000354012471662307012521 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLIBASIC_H #define _AAPL_AVLIBASIC_H #include "compare.h" /** * \addtogroup avlitree * @{ */ /** * \class AvliBasic * \brief Linked AVL Tree in which the entire element structure is the key. * * AvliBasic is a linked AVL tree that does not distinguish between the * element that it contains and the key. The entire element structure is the * key that is used to compare the relative ordering of elements. This is * similar to the BstSet structure. * * AvliBasic does not assume ownership of elements in the tree. Items must be * explicitly de-allocated. */ /*@}*/ #define BASE_EL(name) name #define BASEKEY(name) name #define AVLMEL_CLASSDEF class Element, class Compare #define AVLMEL_TEMPDEF class Element, class Compare #define AVLMEL_TEMPUSE Element, Compare #define AvlTree AvliBasic #define AVL_BASIC #define WALKABLE #include "avlcommon.h" #undef BASE_EL #undef BASEKEY #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef AVL_BASIC #undef WALKABLE #endif /* _AAPL_AVLIBASIC_H */ kelbt-0.16/aapl/avlmelkey.h0000664000175000017500000000442312471662307012556 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLMELKEY_H #define _AAPL_AVLMELKEY_H #include "compare.h" /** * \addtogroup avltree * @{ */ /** * \class AvlMelKey * \brief AVL tree for elements appearing in multiple trees with different keys. * * AvlMelKey is similar to AvlMel, except that an additional template * parameter, BaseKey, is provided for resolving ambiguous references to * getKey(). This means that if an element is stored in multiple trees, each * tree can use a different key for ordering the elements in it. Using * AvlMelKey an array of data structures can be indexed with an O(log(n)) * search on two or more of the values contained within it and without * allocating any additional data. * * AvlMelKey does not assume ownership of elements in the tree. The destructor * will not delete the elements. If the user wishes to explicitly deallocate * all the items in the tree the empty() routine is available. * * \include ex_avlmelkey.cpp */ /*@}*/ #define BASE_EL(name) BaseEl::name #define BASEKEY(name) BaseKey::name #define AVLMEL_CLASSDEF class Element, class Key, class BaseEl, \ class BaseKey, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Element, class Key, class BaseEl, \ class BaseKey, class Compare #define AVLMEL_TEMPUSE Element, Key, BaseEl, BaseKey, Compare #define AvlTree AvlMelKey #include "avlcommon.h" #undef BASE_EL #undef BASEKEY #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #endif /* _AAPL_AVLMELKEY_H */ kelbt-0.16/aapl/dlist.h0000664000175000017500000000360712471662307011707 00000000000000/* * Copyright 2001 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_DLIST_H #define _AAPL_DLIST_H #define BASE_EL(name) name #define DLMEL_TEMPDEF class Element #define DLMEL_TEMPUSE Element #define DList DList /** * \addtogroup dlist * @{ */ /** * \class DList * \brief Basic doubly linked list. * * DList is the standard by-structure list type. This class requires the * programmer to declare a list element type that has the necessary next and * previous pointers in it. This can be achieved by inheriting from the * DListEl class or by simply adding next and previous pointers directly into * the list element class. * * DList does not assume ownership of elements in the list. If the elements * are known to reside on the heap, the provided empty() routine can be used to * delete all elements, however the destructor will not call this routine, it * will simply abandon all the elements. It is up to the programmer to * explicitly de-allocate items when necessary. * * \include ex_dlist.cpp */ /*@}*/ #include "dlcommon.h" #undef BASE_EL #undef DLMEL_TEMPDEF #undef DLMEL_TEMPUSE #undef DList #endif /* _AAPL_DLIST_H */ kelbt-0.16/aapl/bstmap.h0000664000175000017500000000575012471662307012057 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_BSTMAP_H #define _AAPL_BSTMAP_H #include "compare.h" #include "vector.h" #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \brief Element for BstMap. * * Stores the key and value pair. */ template struct BstMapEl { BstMapEl() {} BstMapEl(const Key &key) : key(key) {} BstMapEl(const Key &key, const Value &val) : key(key), value(val) {} /** \brief The key */ Key key; /** \brief The value. */ Value value; }; #ifdef AAPL_NAMESPACE } #endif /** * \addtogroup bst * @{ */ /** * \class BstMap * \brief Binary search table for key and value pairs. * * BstMap stores key and value pairs in each element. The key and value can be * any type. A compare class for the key must be supplied. */ /*@}*/ #define BST_TEMPL_DECLARE class Key, class Value, \ class Compare = CmpOrd, class Resize = ResizeExpn #define BST_TEMPL_DEF class Key, class Value, class Compare, class Resize #define BST_TEMPL_USE Key, Value, Compare, Resize #define GET_KEY(el) ((el).key) #define BstTable BstMap #define Element BstMapEl #define BSTMAP #include "bstcommon.h" #undef BST_TEMPL_DECLARE #undef BST_TEMPL_DEF #undef BST_TEMPL_USE #undef GET_KEY #undef BstTable #undef Element #undef BSTMAP /** * \fn BstMap::insert(const Key &key, BstMapEl **lastFound) * \brief Insert the given key. * * If the given key does not already exist in the table then a new element * having key is inserted. They key copy constructor and value default * constructor are used to place the pair in the table. If lastFound is given, * it is set to the new entry created. If the insert fails then lastFound is * set to the existing pair of the same key. * * \returns The new element created upon success, null upon failure. */ /** * \fn BstMap::insertMulti(const Key &key) * \brief Insert the given key even if it exists already. * * If the key exists already then the new element having key is placed next * to some other pair of the same key. InsertMulti cannot fail. The key copy * constructor and the value default constructor are used to place the pair in * the table. * * \returns The new element created. */ #endif /* _AAPL_BSTMAP_H */ kelbt-0.16/aapl/avlitree.h0000664000175000017500000000470212471662307012400 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLITREE_H #define _AAPL_AVLITREE_H #include "compare.h" #include "dlistmel.h" /** * \addtogroup avlitree * @{ */ /** * \class AvliTree * \brief Linked AVL tree. * * AvliTree is the standard linked by-structure AVL tree. To use this * structure the user must define an element type and give it the necessary * properties. At the very least it must have a getKey() function that will be * used to compare the relative ordering of elements and tree management data * necessary for the AVL algorithm. An element type can acquire the management * data by inheriting the AvliTreeEl class. * * AvliTree does not presume to manage the allocation of elements in the tree. * The destructor will not delete the items in the tree, instead the elements * must be explicitly de-allocated by the user if necessary and when it is * safe to do so. The empty() routine will traverse the tree and delete all * items. * * Since the tree does not manage the elements, it can contain elements that * are allocated statically or that are part of another data structure. * * \include ex_avlitree.cpp */ /*@}*/ #define BASE_EL(name) name #define BASEKEY(name) name #define BASELIST DListMel< Element, AvliTreeEl > #define AVLMEL_CLASSDEF class Element, class Key, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Element, class Key, class Compare #define AVLMEL_TEMPUSE Element, Key, Compare #define AvlTree AvliTree #define WALKABLE #include "avlcommon.h" #undef BASE_EL #undef BASEKEY #undef BASELIST #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef WALKABLE #endif /* _AAPL_AVLITREE_H */ kelbt-0.16/aapl/table.h0000664000175000017500000001372112471662307011655 00000000000000/* * Copyright 2001, 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_TABLE_H #define _AAPL_TABLE_H #ifdef AAPL_NAMESPACE namespace Aapl { #endif /** * \addtogroup vector * @{ */ /** \class Table * \brief Base class for dynamic arrays. * * Table is used as the common data storage class for vectors. It does not * provide any methods to operate on the data and as such it is not intended * to be used directly. It exists so that algorithms that operatate on dynamic * arrays can be written without knowing about the various vector classes that * my exist. */ /*@}*/ /* Table class. */ template class Table { public: /* Default Constructor. */ inline Table(); /** * \brief Get the length of the vector. * * \returns the length of the vector. */ long length() const { return tabLen; } /** * \brief Table data. * * The pointer to the elements in the vector. Modifying the vector may * cause this pointer to change. */ T *data; /** * \brief Table length. * * The number of items of type T in the table. */ long tabLen; /** * \brief Allocated length. * * The number of items for which there is room in the current allocation. */ long allocLen; }; /** * \brief Default constructor * * Initialize table data to empty. */ template inline Table::Table() : data(0), tabLen(0), allocLen(0) { } /* Default shared table header class. */ struct STabHead { /** * \brief Table length. * * The number of items of type T in the table. */ long tabLen; /** * \brief Allocated length. * * The number of items for which there is room in the current allocation. */ long allocLen; /** * \brief Ref Count. * * The number of shared vectors referencing this data. */ long refCount; }; /** * \addtogroup vector * @{ */ /** \class STable * \brief Base class for implicitly shared dynamic arrays. * * STable is used as the common data storage class for shared vectors. It does * not provide any methods to operate on the data and as such it is not * intended to be used directly. It exists so that algorithms that operatate * on dynamic arrays can be written without knowing about the various shared * vector classes that my exist. */ /*@}*/ /* STable class. */ template class STable { public: /* Default Constructor. */ inline STable(); /** * \brief Get the length of the shared vector. * * \returns the length of the shared vector. */ long length() const { return data == 0 ? 0 : (((STabHead*)data) - 1)->tabLen; } /** * \brief Get header of the shared vector. * * \returns the header of the shared vector. */ STabHead *header() const { return data == 0 ? 0 : (((STabHead*)data) - 1); } /** * \brief Table data. * * The pointer to the elements in the vector. The shared table header is * located just behind the data. Modifying the vector may cause this * pointer to change. */ T *data; }; /** * \brief Default constructor * * Initialize shared table data to empty. */ template inline STable::STable() : data(0) { } /* If needed is greater than existing, give twice needed. */ #define EXPN_UP( existing, needed ) \ needed > existing ? (needed<<1) : existing /* If needed is less than 1 quarter existing, give twice needed. */ #define EXPN_DOWN( existing, needed ) \ needed < (existing>>2) ? (needed<<1) : existing /** * \addtogroup vector * @{ */ /** \class ResizeExpn * \brief Exponential table resizer. * * ResizeExpn is the default table resizer. When an up resize is needed, space * is doubled. When a down resize is needed, space is halved. The result is * that when growing the vector in a linear fashion, the number of resizes of * the allocated space behaves logarithmically. * * If only up resizes are done, there will never be more than 2 times the * needed space allocated. If down resizes are done as well, there will never * be more than 4 times the needed space allocated. ResizeExpn uses this 50% * usage policy on up resizing and 25% usage policy on down resizing to * improve performance when repeatedly inserting and removing a small number * of elements relative to the size of the array. This scheme guarantees that * repetitive inserting and removing of a small number of elements will never * result in repetative reallocation. * * The sizes passed to the resizer from the vectors are in units of T. */ /*@}*/ /* Exponential resizer. */ class ResizeExpn { protected: /** * \brief Determine the new table size when up resizing. * * If the existing size is insufficient for the space needed then allocate * twice the space needed. Otherwise use the existing size. * * \returns The new table size. */ static inline long upResize( long existing, long needed ) { return EXPN_UP( existing, needed ); } /** * \brief Determine the new table size when down resizing. * * If the space needed is less than one quarter of the existing size then * allocate twice the space needed. Otherwise use the exitsing size. * * \returns The new table size. */ static inline long downResize( long existing, long needed ) { return EXPN_DOWN( existing, needed ); } }; #undef EXPN_UP #undef EXPN_DOWN #ifdef AAPL_NAMESPACE } #endif #endif /* _AAPL_TABLE_H */ kelbt-0.16/aapl/avlmel.h0000664000175000017500000000442212471662307012044 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLMEL_H #define _AAPL_AVLMEL_H #include "compare.h" /** * \addtogroup avltree * @{ */ /** * \class AvlMel * \brief AVL tree for elements appearing in multiple trees. * * AvlMel allows for an element to simultaneously be in multiple trees without * the trees interferring with one another. For each tree that the element is * to appear in, there must be a distinct set of AVL Tree management data that * can be unambiguously referenced with some base class name. This name * is passed to the tree as a template parameter and is used in the tree * algorithms. * * The element must use the same key type and value in each tree that it * appears in. If distinct keys are required, the AvlMelKey structure is * available. * * AvlMel does not assume ownership of elements in the tree. The destructor * will not delete the elements. If the user wishes to explicitly deallocate * all the items in the tree the empty() routine is available. * * \include ex_avlmel.cpp */ /*@}*/ #define BASE_EL(name) BaseEl::name #define BASEKEY(name) name #define AVLMEL_CLASSDEF class Element, class Key, \ class BaseEl, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Element, class Key, \ class BaseEl, class Compare #define AVLMEL_TEMPUSE Element, Key, BaseEl, Compare #define AvlTree AvlMel #include "avlcommon.h" #undef BASE_EL #undef BASEKEY #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #endif /* _AAPL_AVLMEL_H */ kelbt-0.16/aapl/avliset.h0000664000175000017500000000406312471662307012234 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLISET_H #define _AAPL_AVLISET_H #include "compare.h" #include "dlist.h" /** * \addtogroup avlitree * @{ */ /** * \class AvliSet * \brief Linked Key-only oriented tree. * * AvliSet stores only keys in elements that are managed by the tree. AvliSet * requires that a Key type and a class containing a compare() routine * for Key be given. Items are inserted with just a key value. * * AvliSet assumes all elements in the tree are allocated on the heap and are * to be managed by the tree. This means that the class destructor will delete * the contents of the tree. A deep copy will cause existing elements to be * deleted first. * * \include ex_avliset.cpp */ /*@}*/ #define AVLTREE_SET #define BASE_EL(name) name #define BASEKEY(name) name #define BASELIST DList< AvliSetEl > #define AVLMEL_CLASSDEF class Key, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Key, class Compare #define AVLMEL_TEMPUSE Key, Compare #define AvlTree AvliSet #define Element AvliSetEl #define WALKABLE #include "avlcommon.h" #undef AVLTREE_SET #undef BASE_EL #undef BASEKEY #undef BASELIST #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef Element #undef WALKABLE #endif /* _AAPL_AVLISET_H */ kelbt-0.16/aapl/bstcommon.h0000664000175000017500000005160412471676216012575 00000000000000/* * Copyright 2001 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* This header is not wrapped in ifndefs because it is * not intended to be included by users directly. */ #ifdef AAPL_NAMESPACE namespace Aapl { #endif /* Binary Search Table */ template < BST_TEMPL_DECLARE > class BstTable : public Compare, public Vector< Element, Resize > { typedef Vector BaseVector; typedef Table BaseTable; public: /** * \brief Default constructor. * * Create an empty binary search table. */ BstTable() { } /** * \brief Construct with initial value. * * Constructs a binary search table with an initial item. Uses the default * constructor for initializing Value. */ BstTable(const Key &key) { insert(key); } #if defined( BSTMAP ) /** * \brief Construct with initial value. * * Constructs a binary search table with an initial key/value pair. */ BstTable(const Key &key, const Value &val) { insert(key, val); } #endif #if ! defined( BSTSET ) /** * \brief Construct with initial value. * * Constructs a binary search table with an initial Element. */ BstTable(const Element &el) { insert(el); } #endif Element *insert(const Key &key, Element **lastFound = 0); Element *insertMulti(const Key &key); bool insert(const BstTable &other); void insertMulti(const BstTable &other); #if defined( BSTMAP ) Element *insert(const Key &key, const Value &val, Element **lastFound = 0); Element *insertMulti(const Key &key, const Value &val ); #endif #if ! defined( BSTSET ) Element *insert(const Element &el, Element **lastFound = 0); Element *insertMulti(const Element &el); #endif Element *find(const Key &key, Element **lastFound = 0) const; bool findMulti( const Key &key, Element *&lower, Element *&upper ) const; bool remove(const Key &key); bool remove(Element *item); long removeMulti(const Key &key); long removeMulti(Element *lower, Element *upper); /* The following provide access to the underlying insert and remove * functions that my be hidden by the BST insert and remove. The insertDup * and insertNew functions will never be hidden. They are provided for * consistency. The difference between the non-shared and the shared * tables is the documentation reference to the invoked function. */ #if !defined( SHARED_BST ) /*@{*/ /** \brief Call the insert of the underlying vector. * * Provides to access to the vector insert, which may become hidden. Care * should be taken to ensure that after the insert the ordering of * elements is preserved. * Invokes Vector::insert( long pos, const T &val ). */ void vinsert(long pos, const Element &val) { Vector< Element, Resize >::insert( pos, &val, 1 ); } /** \brief Call the insert of the underlying vector. * * Provides to access to the vector insert, which may become hidden. Care * should be taken to ensure that after the insert the ordering of * elements is preserved. * Invokes Vector::insert( long pos, const T *val, long len ). */ void vinsert(long pos, const Element *val, long len) { Vector< Element, Resize >::insert( pos, val, len ); } /** \brief Call the insert of the underlying vector. * * Provides to access to the vector insert, which may become hidden. Care * should be taken to ensure that after the insert the ordering of * elements is preserved. * Invokes Vector::insert( long pos, const Vector &v ). */ void vinsert(long pos, const BstTable &v) { Vector< Element, Resize >::insert( pos, v.data, v.tabLen ); } /*@}*/ /*@{*/ /** \brief Call the remove of the underlying vector. * * Provides access to the vector remove, which may become hidden. * Invokes Vector::remove( long pos ). */ void vremove(long pos) { Vector< Element, Resize >::remove( pos, 1 ); } /** \brief Call the remove of the underlying vector. * * Proves access to the vector remove, which may become hidden. * Invokes Vector::remove( long pos, long len ). */ void vremove(long pos, long len) { Vector< Element, Resize >::remove( pos, len ); } /*@}*/ #else /* SHARED_BST */ /*@{*/ /** \brief Call the insert of the underlying vector. * * Provides to access to the vector insert, which may become hidden. Care * should be taken to ensure that after the insert the ordering of * elements is preserved. * Invokes SVector::insert( long pos, const T &val ). */ void vinsert(long pos, const Element &val) { Vector< Element, Resize >::insert( pos, &val, 1 ); } /** \brief Call the insert of the underlying vector. * * Provides to access to the vector insert, which may become hidden. Care * should be taken to ensure that after the insert the ordering of * elements is preserved. * Invokes SVector::insert( long pos, const T *val, long len ). */ void vinsert(long pos, const Element *val, long len) { Vector< Element, Resize >::insert( pos, val, len ); } /** \brief Call the insert of the underlying vector. * * Provides to access to the vector insert, which may become hidden. Care * should be taken to ensure that after the insert the ordering of * elements is preserved. * Invokes SVector::insert( long pos, const SVector &v ). */ void vinsert(long pos, const BstTable &v) { Vector< Element, Resize >::insert( pos, v.data, v.length() ); } /*@}*/ /*@{*/ /** \brief Call the remove of the underlying vector. * * Provides access to the vector remove, which may become hidden. * Invokes SVector::remove( long pos ). */ void vremove(long pos) { Vector< Element, Resize >::remove( pos, 1 ); } /** \brief Call the remove of the underlying vector. * * Proves access to the vector remove, which may become hidden. * Invokes SVector::remove( long pos, long len ). */ void vremove(long pos, long len) { Vector< Element, Resize >::remove( pos, len ); } /*@}*/ #endif /* SHARED_BST */ }; #if 0 #if defined( SHARED_BST ) /** * \brief Construct a binary search table with an initial amount of * allocation. * * The table is initialized to have room for allocLength elements. The * table starts empty. */ template BstTable:: BstTable( long allocLen ) { /* Allocate the space if we are given a positive allocLen. */ if ( allocLen > 0 ) { /* Allocate the data needed. */ STabHead *head = (STabHead*) malloc( sizeof(STabHead) + sizeof(Element) * allocLen ); if ( head == 0 ) throw std::bad_alloc(); /* Set up the header and save the data pointer. */ head->refCount = 1; head->allocLen = allocLen; head->tabLen = 0; BaseTable::data = (Element*) (head + 1); } } #else /** * \brief Construct a binary search table with an initial amount of * allocation. * * The table is initialized to have room for allocLength elements. The * table starts empty. */ template BstTable:: BstTable( long allocLen ) { /* Allocate the space if we are given a positive allocLen. */ BaseTable::allocLen = allocLen; if ( BaseTable::allocLen > 0 ) { BaseTable::data = (Element*) malloc(sizeof(Element) * BaseTable::allocLen); if ( BaseTable::data == NULL ) throw std::bad_alloc(); } } #endif #endif /** * \brief Find the element with the given key and remove it. * * If multiple elements with the given key exist, then it is unspecified which * element will be removed. * * \returns True if an element is found and consequently removed, false * otherwise. */ template bool BstTable:: remove(const Key &key) { Element *el = find(key); if ( el != 0 ) { Vector< Element >::remove(el - BaseTable::data); return true; } return false; } /** * \brief Remove the element pointed to by item. * * If item does not point to an element in the tree, then undefined behaviour * results. If item is null, then remove has no effect. * * \returns True if item is not null, false otherwise. */ template bool BstTable:: remove( Element *item ) { if ( item != 0 ) { Vector< Element >::remove(item - BaseTable::data); return true; } return false; } /** * \brief Find and remove the entire range of elements with the given key. * * \returns The number of elements removed. */ template long BstTable:: removeMulti(const Key &key) { Element *low, *high; if ( findMulti(key, low, high) ) { /* Get the length of the range. */ long num = high - low + 1; Vector< Element >::remove(low - BaseTable::data, num); return num; } return 0; } template long BstTable:: removeMulti(Element *lower, Element *upper) { /* Get the length of the range. */ long num = upper - lower + 1; Vector< Element >::remove(lower - BaseTable::data, num); return num; } /** * \brief Find a range of elements with the given key. * * If any elements with the given key exist then lower and upper are set to * the low and high ends of the continous range of elements with the key. * Lower and upper will point to the first and last elements with the key. * * \returns True if any elements are found, false otherwise. */ template bool BstTable:: findMulti(const Key &key, Element *&low, Element *&high ) const { const Element *lower, *mid, *upper; long keyRelation; const long tblLen = BaseTable::length(); if ( BaseTable::data == 0 ) return false; lower = BaseTable::data; upper = BaseTable::data + tblLen - 1; while ( true ) { if ( upper < lower ) { /* Did not find the fd in the array. */ return false; } mid = lower + ((upper-lower)>>1); keyRelation = compare(key, GET_KEY(*mid)); if ( keyRelation < 0 ) upper = mid - 1; else if ( keyRelation > 0 ) lower = mid + 1; else { Element *lowEnd = BaseTable::data - 1; Element *highEnd = BaseTable::data + tblLen; lower = mid - 1; while ( lower != lowEnd && compare(key, GET_KEY(*lower)) == 0 ) lower--; upper = mid + 1; while ( upper != highEnd && compare(key, GET_KEY(*upper)) == 0 ) upper++; low = (Element*)lower + 1; high = (Element*)upper - 1; return true; } } } /** * \brief Find an element with the given key. * * If the find succeeds then lastFound is set to the element found. If the * find fails then lastFound is set the location where the key would be * inserted. If there is more than one element in the tree with the given key, * then it is unspecified which element is returned as the match. * * \returns The element found on success, null on failure. */ template Element *BstTable:: find( const Key &key, Element **lastFound ) const { const Element *lower, *mid, *upper; long keyRelation; const long tblLen = BaseTable::length(); if ( BaseTable::data == 0 ) return 0; lower = BaseTable::data; upper = BaseTable::data + tblLen - 1; while ( true ) { if ( upper < lower ) { /* Did not find the key. Last found gets the insert location. */ if ( lastFound != 0 ) *lastFound = (Element*)lower; return 0; } mid = lower + ((upper-lower)>>1); keyRelation = this->compare(key, GET_KEY(*mid)); if ( keyRelation < 0 ) upper = mid - 1; else if ( keyRelation > 0 ) lower = mid + 1; else { /* Key is found. Last found gets the found record. */ if ( lastFound != 0 ) *lastFound = (Element*)mid; return (Element*)mid; } } } template Element *BstTable:: insert(const Key &key, Element **lastFound) { const Element *lower, *mid, *upper; long keyRelation, insertPos; const long tblLen = BaseTable::length(); if ( tblLen == 0 ) { /* If the table is empty then go straight to insert. */ lower = BaseTable::data; goto insert; } lower = BaseTable::data; upper = BaseTable::data + tblLen - 1; while ( true ) { if ( upper < lower ) { /* Did not find the key in the array. * Place to insert at is lower. */ goto insert; } mid = lower + ((upper-lower)>>1); keyRelation = this->compare(key, GET_KEY(*mid)); if ( keyRelation < 0 ) upper = mid - 1; else if ( keyRelation > 0 ) lower = mid + 1; else { if ( lastFound != 0 ) *lastFound = (Element*)mid; return 0; } } insert: /* Get the insert pos. */ insertPos = lower - BaseTable::data; /* Do the insert. After makeRawSpaceFor, lower pointer is no good. */ BaseVector::makeRawSpaceFor(insertPos, 1); new(BaseTable::data + insertPos) Element(key); /* Set lastFound */ if ( lastFound != 0 ) *lastFound = BaseTable::data + insertPos; return BaseTable::data + insertPos; } template Element *BstTable:: insertMulti(const Key &key) { const Element *lower, *mid, *upper; long keyRelation, insertPos; const long tblLen = BaseTable::length(); if ( tblLen == 0 ) { /* If the table is empty then go straight to insert. */ lower = BaseTable::data; goto insert; } lower = BaseTable::data; upper = BaseTable::data + tblLen - 1; while ( true ) { if ( upper < lower ) { /* Did not find the key in the array. * Place to insert at is lower. */ goto insert; } mid = lower + ((upper-lower)>>1); keyRelation = compare(key, GET_KEY(*mid)); if ( keyRelation < 0 ) upper = mid - 1; else if ( keyRelation > 0 ) lower = mid + 1; else { lower = mid; goto insert; } } insert: /* Get the insert pos. */ insertPos = lower - BaseTable::data; /* Do the insert. */ BaseVector::makeRawSpaceFor(insertPos, 1); new(BaseTable::data + insertPos) Element(key); /* Return the element inserted. */ return BaseTable::data + insertPos; } /** * \brief Insert each element from other. * * Always attempts to insert all elements even if the insert of some item from * other fails. * * \returns True if all items inserted successfully, false if any insert * failed. */ template bool BstTable:: insert(const BstTable &other) { bool allSuccess = true; long otherLen = other.length(); for ( long i = 0; i < otherLen; i++ ) { Element *el = insert( other.data[i] ); if ( el == 0 ) allSuccess = false; } return allSuccess; } /** * \brief Insert each element from other even if the elements exist already. * * No individual insertMulti can fail. */ template void BstTable:: insertMulti(const BstTable &other) { long otherLen = other.length(); for ( long i = 0; i < otherLen; i++ ) insertMulti( other.data[i] ); } #if ! defined( BSTSET ) /** * \brief Insert the given element. * * If the key in the given element does not already exist in the table then a * new element is inserted. They element copy constructor is used to place the * element into the table. If lastFound is given, it is set to the new element * created. If the insert fails then lastFound is set to the existing element * of the same key. * * \returns The new element created upon success, null upon failure. */ template Element *BstTable:: insert(const Element &el, Element **lastFound ) { const Element *lower, *mid, *upper; long keyRelation, insertPos; const long tblLen = BaseTable::length(); if ( tblLen == 0 ) { /* If the table is empty then go straight to insert. */ lower = BaseTable::data; goto insert; } lower = BaseTable::data; upper = BaseTable::data + tblLen - 1; while ( true ) { if ( upper < lower ) { /* Did not find the key in the array. * Place to insert at is lower. */ goto insert; } mid = lower + ((upper-lower)>>1); keyRelation = this->compare(GET_KEY(el), GET_KEY(*mid)); if ( keyRelation < 0 ) upper = mid - 1; else if ( keyRelation > 0 ) lower = mid + 1; else { if ( lastFound != 0 ) *lastFound = (Element*)mid; return 0; } } insert: /* Get the insert pos. */ insertPos = lower - BaseTable::data; /* Do the insert. After makeRawSpaceFor, lower pointer is no good. */ BaseVector::makeRawSpaceFor(insertPos, 1); new(BaseTable::data + insertPos) Element(el); /* Set lastFound */ if ( lastFound != 0 ) *lastFound = BaseTable::data + insertPos; return BaseTable::data + insertPos; } /** * \brief Insert the given element even if it exists already. * * If the key in the given element exists already then the new element is * placed next to some other element of the same key. InsertMulti cannot fail. * The element copy constructor is used to place the element in the table. * * \returns The new element created. */ template Element *BstTable:: insertMulti(const Element &el) { const Element *lower, *mid, *upper; long keyRelation, insertPos; const long tblLen = BaseTable::length(); if ( tblLen == 0 ) { /* If the table is empty then go straight to insert. */ lower = BaseTable::data; goto insert; } lower = BaseTable::data; upper = BaseTable::data + tblLen - 1; while ( true ) { if ( upper < lower ) { /* Did not find the fd in the array. * Place to insert at is lower. */ goto insert; } mid = lower + ((upper-lower)>>1); keyRelation = compare(GET_KEY(el), GET_KEY(*mid)); if ( keyRelation < 0 ) upper = mid - 1; else if ( keyRelation > 0 ) lower = mid + 1; else { lower = mid; goto insert; } } insert: /* Get the insert pos. */ insertPos = lower - BaseTable::data; /* Do the insert. */ BaseVector::makeRawSpaceFor(insertPos, 1); new(BaseTable::data + insertPos) Element(el); /* Return the element inserted. */ return BaseTable::data + insertPos; } #endif #if defined( BSTMAP ) /** * \brief Insert the given key-value pair. * * If the given key does not already exist in the table then the key-value * pair is inserted. Copy constructors are used to place the pair in the * table. If lastFound is given, it is set to the new entry created. If the * insert fails then lastFound is set to the existing pair of the same key. * * \returns The new element created upon success, null upon failure. */ template Element *BstTable:: insert(const Key &key, const Value &val, Element **lastFound) { const Element *lower, *mid, *upper; long keyRelation, insertPos; const long tblLen = BaseTable::length(); if ( tblLen == 0 ) { /* If the table is empty then go straight to insert. */ lower = BaseTable::data; goto insert; } lower = BaseTable::data; upper = BaseTable::data + tblLen - 1; while ( true ) { if ( upper < lower ) { /* Did not find the fd in the array. * Place to insert at is lower. */ goto insert; } mid = lower + ((upper-lower)>>1); keyRelation = Compare::compare(key, mid->key); if ( keyRelation < 0 ) upper = mid - 1; else if ( keyRelation > 0 ) lower = mid + 1; else { if ( lastFound != NULL ) *lastFound = (Element*)mid; return 0; } } insert: /* Get the insert pos. */ insertPos = lower - BaseTable::data; /* Do the insert. */ BaseVector::makeRawSpaceFor(insertPos, 1); new(BaseTable::data + insertPos) Element(key, val); /* Set lastFound */ if ( lastFound != NULL ) *lastFound = BaseTable::data + insertPos; return BaseTable::data + insertPos; } /** * \brief Insert the given key-value pair even if the key exists already. * * If the key exists already then the key-value pair is placed next to some * other pair of the same key. InsertMulti cannot fail. Copy constructors are * used to place the pair in the table. * * \returns The new element created. */ template Element *BstTable:: insertMulti(const Key &key, const Value &val) { const Element *lower, *mid, *upper; long keyRelation, insertPos; const long tblLen = BaseTable::length(); if ( tblLen == 0 ) { /* If the table is empty then go straight to insert. */ lower = BaseTable::data; goto insert; } lower = BaseTable::data; upper = BaseTable::data + tblLen - 1; while ( true ) { if ( upper < lower ) { /* Did not find the key in the array. * Place to insert at is lower. */ goto insert; } mid = lower + ((upper-lower)>>1); keyRelation = Compare::compare(key, mid->key); if ( keyRelation < 0 ) upper = mid - 1; else if ( keyRelation > 0 ) lower = mid + 1; else { lower = mid; goto insert; } } insert: /* Get the insert pos. */ insertPos = lower - BaseTable::data; /* Do the insert. */ BaseVector::makeRawSpaceFor(insertPos, 1); new(BaseTable::data + insertPos) Element(key, val); /* Return the element inserted. */ return BaseTable::data + insertPos; } #endif #ifdef AAPL_NAMESPACE } #endif kelbt-0.16/aapl/avlimelkey.h0000664000175000017500000000463012471662307012727 00000000000000/* * Copyright 2002 Adrian Thurston */ /* This file is part of Aapl. * * Aapl is free software; you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * Aapl 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 Lesser General Public License for * more details. * * You should have received a copy of the GNU Lesser General Public License * along with Aapl; if not, write to the Free Software Foundation, Inc., 59 * Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _AAPL_AVLIMELKEY_H #define _AAPL_AVLIMELKEY_H #include "compare.h" #include "dlistmel.h" /** * \addtogroup avlitree * @{ */ /** * \class AvliMelKey * \brief Linked AVL tree for element appearing in multiple trees with different keys. * * AvliMelKey is similar to AvliMel, except that an additional template * parameter, BaseKey, is provided for resolving ambiguous references to * getKey(). This means that if an element is stored in multiple trees, each * tree can use a different key for ordering the elements in it. Using * AvliMelKey an array of data structures can be indexed with an O(log(n)) * search on two or more of the values contained within it and without * allocating any additional data. * * AvliMelKey does not assume ownership of elements in the tree. The destructor * will not delete the elements. If the user wishes to explicitly deallocate * all the items in the tree the empty() routine is available. * * \include ex_avlimelkey.cpp */ /*@}*/ #define BASE_EL(name) BaseEl::name #define BASEKEY(name) BaseKey::name #define BASELIST DListMel< Element, BaseEl > #define AVLMEL_CLASSDEF class Element, class Key, class BaseEl, \ class BaseKey, class Compare = CmpOrd #define AVLMEL_TEMPDEF class Element, class Key, class BaseEl, \ class BaseKey, class Compare #define AVLMEL_TEMPUSE Element, Key, BaseEl, BaseKey, Compare #define AvlTree AvliMelKey #define WALKABLE #include "avlcommon.h" #undef BASE_EL #undef BASEKEY #undef BASELIST #undef AVLMEL_CLASSDEF #undef AVLMEL_TEMPDEF #undef AVLMEL_TEMPUSE #undef AvlTree #undef WALKABLE #endif /* _AAPL_AVLIMELKEY_H */ kelbt-0.16/COPYING0000664000175000017500000004326012471662307010534 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. kelbt-0.16/missing0000755000175000017500000001533012261335263011066 00000000000000#! /bin/sh # Common wrapper for a few potentially missing GNU programs. scriptversion=2013-10-28.13; # UTC # Copyright (C) 1996-2013 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # 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. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try '$0 --help' for more information" exit 1 fi case $1 in --is-lightweight) # Used by our autoconf macros to check whether the available missing # script is modern enough. exit 0 ;; --run) # Back-compat with the calling convention used by older automake. shift ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due to PROGRAM being missing or too old. Options: -h, --help display this help and exit -v, --version output version information and exit Supported PROGRAM values: aclocal autoconf autoheader autom4te automake makeinfo bison yacc flex lex help2man Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 'g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: unknown '$1' option" echo 1>&2 "Try '$0 --help' for more information" exit 1 ;; esac # Run the given program, remember its exit status. "$@"; st=$? # If it succeeded, we are done. test $st -eq 0 && exit 0 # Also exit now if we it failed (or wasn't found), and '--version' was # passed; such an option is passed most likely to detect whether the # program is present and works. case $2 in --version|--help) exit $st;; esac # Exit code 63 means version mismatch. This often happens when the user # tries to use an ancient version of a tool on a file that requires a # minimum version. if test $st -eq 63; then msg="probably too old" elif test $st -eq 127; then # Program was missing. msg="missing on your system" else # Program was found and executed, but failed. Give up. exit $st fi perl_URL=http://www.perl.org/ flex_URL=http://flex.sourceforge.net/ gnu_software_URL=http://www.gnu.org/software program_details () { case $1 in aclocal|automake) echo "The '$1' program is part of the GNU Automake package:" echo "<$gnu_software_URL/automake>" echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/autoconf>" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; autoconf|autom4te|autoheader) echo "The '$1' program is part of the GNU Autoconf package:" echo "<$gnu_software_URL/autoconf/>" echo "It also requires GNU m4 and Perl in order to run:" echo "<$gnu_software_URL/m4/>" echo "<$perl_URL>" ;; esac } give_advice () { # Normalize program name to check for. normalized_program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` printf '%s\n' "'$1' is $msg." configure_deps="'configure.ac' or m4 files included by 'configure.ac'" case $normalized_program in autoconf*) echo "You should only need it if you modified 'configure.ac'," echo "or m4 files included by it." program_details 'autoconf' ;; autoheader*) echo "You should only need it if you modified 'acconfig.h' or" echo "$configure_deps." program_details 'autoheader' ;; automake*) echo "You should only need it if you modified 'Makefile.am' or" echo "$configure_deps." program_details 'automake' ;; aclocal*) echo "You should only need it if you modified 'acinclude.m4' or" echo "$configure_deps." program_details 'aclocal' ;; autom4te*) echo "You might have modified some maintainer files that require" echo "the 'autom4te' program to be rebuilt." program_details 'autom4te' ;; bison*|yacc*) echo "You should only need it if you modified a '.y' file." echo "You may want to install the GNU Bison package:" echo "<$gnu_software_URL/bison/>" ;; lex*|flex*) echo "You should only need it if you modified a '.l' file." echo "You may want to install the Fast Lexical Analyzer package:" echo "<$flex_URL>" ;; help2man*) echo "You should only need it if you modified a dependency" \ "of a man page." echo "You may want to install the GNU Help2man package:" echo "<$gnu_software_URL/help2man/>" ;; makeinfo*) echo "You should only need it if you modified a '.texi' file, or" echo "any other file indirectly affecting the aspect of the manual." echo "You might want to install the Texinfo package:" echo "<$gnu_software_URL/texinfo/>" echo "The spurious makeinfo call might also be the consequence of" echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" echo "want to install GNU make:" echo "<$gnu_software_URL/make/>" ;; *) echo "You might have modified some files without having the proper" echo "tools for further handling them. Check the 'README' file, it" echo "often tells you about the needed prerequisites for installing" echo "this package. You may also peek at any GNU archive site, in" echo "case some other package contains this missing '$1' program." ;; esac } give_advice "$1" | sed -e '1s/^/WARNING: /' \ -e '2,$s/^/ /' >&2 # Propagate the correct exit status (expected to be 127 for a program # not found, 63 for a program that failed due to version mismatch). exit $st # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: kelbt-0.16/aclocal.m40000664000175000017500000011536612472121234011336 00000000000000# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file 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. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file 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. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file 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. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file 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. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file 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. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file 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. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file 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. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file 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. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file 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. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file 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. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file 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. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file 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. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file 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. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2013 Free Software Foundation, Inc. # # This file 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. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file 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. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file 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. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file 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. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR kelbt-0.16/DIST0000664000175000017500000000016012603513714010151 00000000000000#!/bin/sh # Change to yes to enable building of parsers # or manual. Reconfigure afterwards. build_parsers=no; kelbt-0.16/depcomp0000755000175000017500000005601612261335263011052 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2013-05-30.07; # UTC # Copyright (C) 1999-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 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. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by 'PROGRAMS ARGS'. object Object file output by 'PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac # Get the directory component of the given path, and save it in the # global variables '$dir'. Note that this directory component will # be either empty or ending with a '/' character. This is deliberate. set_dir_from () { case $1 in */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; *) dir=;; esac } # Get the suffix-stripped basename of the given path, and save it the # global variable '$base'. set_base_from () { base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` } # If no dependency file was actually created by the compiler invocation, # we still have to create a dummy depfile, to avoid errors with the # Makefile "include basename.Plo" scheme. make_dummy_depfile () { echo "#dummy" > "$depfile" } # Factor out some common post-processing of the generated depfile. # Requires the auxiliary global variable '$tmpdepfile' to be set. aix_post_process_depfile () { # If the compiler actually managed to produce a dependency file, # post-process it. if test -f "$tmpdepfile"; then # Each line is of the form 'foo.o: dependency.h'. # Do two passes, one to just change these to # $object: dependency.h # and one to simply output # dependency.h: # which is needed to avoid the deleted-header problem. { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" } > "$depfile" rm -f "$tmpdepfile" else make_dummy_depfile fi } # A tabulation character. tab=' ' # A newline character. nl=' ' # Character ranges might be problematic outside the C locale. # These definitions help. upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ lower=abcdefghijklmnopqrstuvwxyz digits=0123456789 alpha=${upper}${lower} if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Avoid interferences from the environment. gccflag= dashmflag= # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi if test "$depmode" = xlc; then # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. gccflag=-qmakedep=gcc,-MF depmode=gcc fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. ## (see the conditional assignment to $gccflag above). ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). Also, it might not be ## supported by the other compilers which use the 'gcc' depmode. ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The second -e expression handles DOS-style file names with drive # letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the "deleted header file" problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. ## Some versions of gcc put a space before the ':'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like '#:fec' to the end of the # dependency line. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ | tr "$nl" ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" ;; xlc) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts '$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done aix_post_process_depfile ;; tcc) # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 # FIXME: That version still under development at the moment of writing. # Make that this statement remains true also for stable, released # versions. # It will wrap lines (doesn't matter whether long or short) with a # trailing '\', as in: # # foo.o : \ # foo.c \ # foo.h \ # # It will put a trailing '\' even on the last line, and will use leading # spaces rather than leading tabs (at least since its commit 0394caf7 # "Emit spaces for -MD"). "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. # We have to change lines of the first kind to '$object: \'. sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" # And for each line of the second kind, we have to emit a 'dep.h:' # dummy dependency, to avoid the deleted-header problem. sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" rm -f "$tmpdepfile" ;; ## The order of this option in the case statement is important, since the ## shell code in configure will try each of these formats in the order ## listed in this file. A plain '-MD' option would be understood by many ## compilers, so we must ensure this comes after the gcc and icc options. pgcc) # Portland's C compiler understands '-MD'. # Will always output deps to 'file.d' where file is the root name of the # source file under compilation, even if file resides in a subdirectory. # The object file name does not affect the name of the '.d' file. # pgcc 10.2 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using '\' : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... set_dir_from "$object" # Use the source, not the object, to determine the base name, since # that's sadly what pgcc will do too. set_base_from "$source" tmpdepfile=$base.d # For projects that build the same source file twice into different object # files, the pgcc approach of using the *source* file root name can cause # problems in parallel builds. Use a locking strategy to avoid stomping on # the same $tmpdepfile. lockdir=$base.d-lock trap " echo '$0: caught signal, cleaning up...' >&2 rmdir '$lockdir' exit 1 " 1 2 13 15 numtries=100 i=$numtries while test $i -gt 0; do # mkdir is a portable test-and-set. if mkdir "$lockdir" 2>/dev/null; then # This process acquired the lock. "$@" -MD stat=$? # Release the lock. rmdir "$lockdir" break else # If the lock is being held by a different process, wait # until the winning process is done or we timeout. while test -d "$lockdir" && test $i -gt 0; do sleep 1 i=`expr $i - 1` done fi i=`expr $i - 1` done trap - 1 2 13 15 if test $i -le 0; then echo "$0: failed to acquire lock after $numtries attempts" >&2 echo "$0: check lockdir '$lockdir'" >&2 exit 1 fi if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" # Add 'dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else make_dummy_depfile fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in 'foo.d' instead, so we check for that too. # Subdirectories are respected. set_dir_from "$object" set_base_from "$object" if test "$libtool" = yes; then # Libtool generates 2 separate objects for the 2 libraries. These # two compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir$base.o.d # libtool 1.5 tmpdepfile2=$dir.libs/$base.o.d # Likewise. tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d "$@" -MD fi stat=$? if test $stat -ne 0; then rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done # Same post-processing that is required for AIX mode. aix_post_process_depfile ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test $stat -ne 0; then rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/'"$tab"'\1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/'"$tab"'/ G p }' >> "$depfile" echo >> "$depfile" # make sure the fragment doesn't end with a backslash rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for ':' # in the target name. This is to cope with DOS-style filenames: # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. "$@" $dashmflag | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this sed invocation # correctly. Breaking it into two sed invocations is a workaround. tr ' ' "$nl" < "$tmpdepfile" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process the last invocation # correctly. Breaking it into two sed invocations is a workaround. sed '1,2d' "$tmpdepfile" \ | tr ' ' "$nl" \ | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove '-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E \ | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" echo "$tab" >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: kelbt-0.16/Makefile.am0000664000175000017500000000224712472121606011526 00000000000000# # Copyright 2001-2015 Adrian Thurston # # This file is part of Kelbt # # Kelbt 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. # # Kelbt 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 Kelbt; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA SUBDIRS = aapl src # This file is checked for by the configure script and its existence causes the # parsers and the manual to not be built when the distribution is built. dist-hook: ( \ echo "#!/bin/sh"; \ echo ""; \ echo "# Change to yes to enable building of parsers"; \ echo "# or manual. Reconfigure afterwards."; \ echo "build_parsers=no;"; \ ) \ > $(distdir)/DIST kelbt-0.16/install-sh0000755000175000017500000003325512261335263011501 00000000000000#!/bin/sh # install - install a program, script, or datafile scriptversion=2011-11-20.07; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # Calling this script install-sh is preferred over install.sh, to prevent # 'make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg # Protect names problematic for 'test' and other utilities. case $dst_arg in -* | [=\(\)!]) dst_arg=./$dst_arg;; esac done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call 'install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then do_exit='(exit $ret); exit $ret' trap "ret=129; $do_exit" 1 trap "ret=130; $do_exit" 2 trap "ret=141; $do_exit" 13 trap "ret=143; $do_exit" 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names problematic for 'test' and other utilities. case $src in -* | [=\(\)!]) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; [-=\(\)!]*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test X"$d" = X && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: kelbt-0.16/TODO0000664000175000017500000000051012471662307010160 00000000000000Should be possible to define a nonterminal type as some kind of simple type, As it is, the user is forced to make it into a structure which is referenced by a pointer. Should also be possible to set the default type for all nonterminals. The parse tables use up a lot of static memory. Need a compressed table representation. kelbt-0.16/configure.ac0000664000175000017500000000371112472121144011752 00000000000000dnl dnl Copyright 2001, 2005 Adrian Thurston dnl dnl This file is part of Kelbt. dnl dnl Kelbt is free software; you can redistribute it and/or modify dnl it under the terms of the GNU General Public License as published by dnl the Free Software Foundation; either version 2 of the License, or dnl (at your option) any later version. dnl dnl Kelbt is distributed in the hope that it will be useful, dnl but WITHOUT ANY WARRANTY; without even the implied warranty of dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the dnl GNU General Public License for more details. dnl dnl You should have received a copy of the GNU General Public License dnl along with Kelbt; if not, write to the Free Software dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA AC_INIT(kelbt, 0.16) PUBDATE="February 2015" AM_INIT_AUTOMAKE([foreign]) AC_SUBST(PUBDATE) AC_CONFIG_HEADER(src/config.h) : ${CFLAGS="-Wall -g"} : ${CXXFLAGS="-Wall -g"} dnl Choose a default for the build_parsers. If the dist dnl file is present in the root then use it's contents, dnl otherwise default to yes. AS_IF([test -r $srcdir/DIST], [. $srcdir/DIST], [build_parsers=yes;]) AM_CONDITIONAL(BUILD_PARSERS, [test "x$build_parsers" = "xyes"]) if test "x$build_parsers" = "xyes"; then AC_CHECK_PROG(RAGEL, ragel, ragel) if test -z "$RAGEL"; then echo echo "error: ragel is required to build the parsers" echo exit 1 fi AC_CHECK_PROG(KELBT, kelbt, kelbt) if test -z "$KELBT"; then echo echo "error: kelbt is required to build the parsers" echo exit 1 fi fi dnl Checks for programs. AC_PROG_CXX dnl AC_DEFINE_UNQUOTED(CXX,$CXX) dnl dnl Set test on c++ compiler. dnl AC_LANG_CPLUSPLUS dnl dnl Check for definition of MAKE. dnl AC_PROG_MAKE_SET dnl dnl write output files dnl AC_OUTPUT(Makefile kelbt/Makefile) AC_OUTPUT([ Makefile src/Makefile aapl/Makefile ]) echo "configuration of kelbt complete" kelbt-0.16/ChangeLog0000664000175000017500000002510012471662307011244 00000000000000Kelbt 0.15 - Jan 22, 2012 ========================= -Eliminated type-punned pointer warnings GCC emits for generated code. Kelbt 0.14 - Oct 1, 2009 ======================== -Added the -I option for specifying directories to look in for included files. -Added the location of the including file to the list of locations to search for included files. -Applied patch from David Keller: Hardcoded "Token" string should be Token(). -Fixed many of the test cases. Added missing includes and the _tk prefix to _eof. Kelbt 0.13 - Oct 6, 2008 ======================== -The uses statement can now reference nonterminals before they are defined. -Fixed a typo in an 'undefined type' error message. -Fixed graphviz generation. -Check rhs references for undo and final blocks, not just try blocks. -Now tracking the number of reductions that an token causes. -Use causeReduce counting to maintain a queue of un-translated tokens. When pulling off the queue tokens are translated. When causeReduce drops to zero during backtracking the token is put back onto the queue and un-translated. This balances translation with un-translation. -Fixed distclean target. -Production names and language element names should be const char*. -Updated scanner to Ragel 6.X. -Now fixing the ordering timestamps after advancing reductions. When transferring a reduction copy in the min time from the source transitions. Also remove gaps. This does not affect parsing, but improves graphviz output. -Gave the eof token a better name: _tk_eof. Allows multiple parsers in the same program and prevents clashes with "eof" which seems to be common. -Updated email address. -Fixed const correctness problems. Kelbt 0.12 - May 1, 2007 ======================== -Don't emit empty switch blocks for trial, undo and final actions. -Ignore write statements that are not at the root of the include stack. -Added an option (-l) for turning off the writing of line directives. -Improved error messages. -A commit is now always a full commit of the stack. It induces any remaining final actions and cleans up the stack. Motivation: it should be possible to reliably control when final actions are executed. In the previous scheme reliable control was not possible because if retries existed ahead of the scoped commit then the number of retries would not drop to zero and the final actions would not be executed. Further, no important practical uses for the scoped commit have surfaced. That is, there are no examples of needing to commit a production while preserving earlier alternatives. Therefore the added complexity of the scoped commit feature is not justified. -The malloc used by the final action execution/commit code has been eliminated and replaced with a pointer mechanism. -Added a class keyword for nonterminals and the token type. The keyword goes directly in front of the nonterm/type/token name. Constructors and destructors are invoked for nonterminal class types and the token type when it is a class. nonterm class Foo {}; type class Foo {}; token uses class MyToken; -Added the "write finish" statement which invokes destructors for the items still on the stack. -Blocks of LangEls are now tracked and freed in the finish code. -Kelbt now uses Ragel's import feature instead of repeating the definition of tokens inside the section parser. -The branch point printing function (-i) now prints dot sets to give you a sense of where in the grammar the conflicts are. -Added the shortest statement. This changes the default action ordering from a longest-match strategy to a shortest-match strategy. To make this work reliably the nonterminal which is to be made into a shortest match should be wrapped in a fresh nonterminal which is then specified using the shortest statement. This syntax will likely be improved in the future. shortest lifted_list; lifted_list: list; list: list item; list: ; -Did some cleanup of the syntax highlighting. Removed junk left over from the port of the ragel syntax file a long time ago. -Fixed an missing variable initialization. This eliminates errors reported by valgrind. -Added an install target to the makefiles. Kelbt 0.11 - Feb 12, 2007 ========================= -The commit and final block execution code now uses malloc to allocate an array of pointers instead of using a variable-sized array on the stack, which is not portable C. -Applied more fixes to cxxprep from Gilles J. Seguin. -Updated to the latest aapl. Kelbt 0.10 - Jan 27, 2007 ========================= -Applied fixes to cxxprep from Gilles J. Seguin. -Adopted Ragel's write statement style of generating code. The types of statements are: write instance_data; - the runtime data used by the parser. write token_defs; - pound defines for the tokens. write types; - data structures representing language elements. write data; - static data used by the parser. write init; - initialization code. write exec; - the parse loop. -The access statement was added. It can be used to specify where the instance data is located. For example, inside a structure: access parser->; -Removed return statements from the exec loop. Errors and regular exits now just drop out at the bottom of exec. -The generated code has been made compatible with C. -Added a C test. -The generated data structures and static data elements now have their names prefixed with the parser name. -The "token uses" statement was added. This allows the user to change the name of the data structure which contains token data. It defaults to "Token". token uses ParserToken; -Implemented single-line parser specifications. This is useful mostly for write statements. -Fixes to line directive writing were made. Kelbt 0.9 - Jan 22, 2007 ======================== -Fix to initialization code: the sentinel at the top of the stack needs to have its pointers initialized. Kelbt 0.8 - Jan 16, 2007 ======================== -Added a priority mechanism for tweaking control of the parser. Priorities are associated with characters in productions and these take precedence over the default ordered choice strategy. The ordered choice strategy is also an 'innermost' strategy where all the possibilities within a non-terminal take precedence over any characters which follow the non-terminal. Priorities let one override this in particular cases. -Line directives are now generated for inline code blocks which are passed through to the output file. -Access to the non-terminal element and the right hand side elements of the production being reduced now works properly in final actions. Kelbt 0.7 - Dec 8, 2006 ======================= -Added a credits file. -Kelbt no longer generates code which writes 'parse error' when parsing fails. This can be done by the caller of parseLangEl after looking at the return value. -The scanner is now a class. It tracks the current line and guards against passing tokens to the parser if no parser name has been given. -Separated the parsing of the 'parser' and 'include' statements from the scanner. Kelbt 0.6 - Dec 2, 2006 ======================= -Replaced the Flex scanner with a Ragel scanner. -Replaced the Bison parser with a Kelbt-0.5 parser. Kelbt is now self-hosting. Error handling is now broken and must be added back. -The code was cleaned up: a large amount of code left over from the initial fork from Ragel was removed. -Bug fix: when the retry point is at the root of the stack, meaning it is the only real element, we cannot consult the transition that the sentinel element below it took because that transition does not exist. There is no state and no type associated with the sentinel. This case is now caught and uses the start state directly. Kelbt 0.5 - Nov 18, 2006 ======================== -Fixed production-based commits which became broken when the state table construction was improved in the previous version. -The commit, execFinal and final functions were moved into the main processing loop. The execFinal that was called in finish() is now called from the main loop by setting a commit on the final shift of the eof transition which completes the parse. -The specified parser name is now used as the name of parser class when the functions are generated. -The startState variable was moved to the static table data section. The mutable parser data is no longer static. -The struct block was removed, as it is now depreciated. -Can no longer compile test cases with -pedantic and -ansi due to variable length arrays on stack. Kelbt 0.4 - Oct 30, 2006 ======================== -A considerable amount of code cleanup and was done. This includes removal of unused code, simplification of data structures and rewrites of LR state table construction functions. The unnecessary complexity was because kelbt was derived from a version of a keller which supported right-regular parsing. Along with the cleanup comes a speedup in LR table construction. -An improvement was made to the ordering algorithm. When it's time to assign an ordering to a reduction after recursing down a production, the old way was to find the expand-to state of the production and assign an ordering to any transition which had a reduction of the production. The problem here is that it assumes that every transition that has the reduction can follow that instance of the production. In reality this is not true. There may be some transitions that have the reduction, but which come from a different instance of the production. Now we make sure that we assign a time only to reductions on characters which can follow the production instance. We do this by computing the characters on the fly. This gives a more accurate ordering. Kelbt 0.3 - Aug 8, 2006 ======================= -Fixed a bug in LALR(1) state table construction which caused reductions actions for some middle-recursive grammars to not be added. For example this grammar fails to set a reduce of A-2 on the ')' character. S: A; S: B; A: '(' A ')'; A: '(' 'x' ')'; B: '(' B ')'; B: '(' 'x' ')'; Kelbt 0.2 - Aug 1, 2006 ======================= -Fixed the rejection command: It now immediately shifts the nonterminal being rejected before jumping to the parse error handling. Previously this nonterminal would get lost and would muck things up. -Added a test showing variable length list processing. -The cxxprep example can use the aapl in the root kelbt package. Kelbt 0.1 - Jun 26, 2006 ======================== -Initial release.