pure-lang-svn Mailing List for Pure (Page 29)
Status: Beta
Brought to you by:
agraef
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
(141) |
Jun
(184) |
Jul
(97) |
Aug
(232) |
Sep
(196) |
Oct
|
Nov
|
Dec
|
---|
From: <ag...@us...> - 2008-06-04 06:59:21
|
Revision: 166 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=166&view=rev Author: agraef Date: 2008-06-03 23:59:28 -0700 (Tue, 03 Jun 2008) Log Message: ----------- Comment change. Modified Paths: -------------- pure/trunk/Makefile.in Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-03 22:21:33 UTC (rev 165) +++ pure/trunk/Makefile.in 2008-06-04 06:59:28 UTC (rev 166) @@ -25,8 +25,7 @@ mandir = @mandir@ man1dir = $(mandir)/man1 -# Staging directory for 'make install'. If you use this, make sure that it -# ends in a slash. +# Staging directory for 'make install'. DESTDIR= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-03 22:21:25
|
Revision: 165 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=165&view=rev Author: agraef Date: 2008-06-03 15:21:33 -0700 (Tue, 03 Jun 2008) Log Message: ----------- Add autoconf support. Modified Paths: -------------- pure/trunk/pure.cc pure/trunk/util.cc Added Paths: ----------- pure/trunk/Makefile.in pure/trunk/aclocal.m4 pure/trunk/config.h.in pure/trunk/configure pure/trunk/configure.ac Removed Paths: ------------- pure/trunk/Makefile Deleted: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-06-01 20:14:57 UTC (rev 164) +++ pure/trunk/Makefile 2008-06-03 22:21:33 UTC (rev 165) @@ -1,265 +0,0 @@ - -# This Makefile requires GNU make. Really. - -# Basic setup. You can change the version number and installation paths here. - -# For instance, to install under /usr instead of /usr/local, run 'make -# prefix=/usr && make install prefix=/usr'. Please note that the 'prefix' -# option must be specified *both* at build and at installation time. At -# installation time, you can also specify a DESTDIR path if you want to -# install into a staging directory, e.g.: 'make install DESTDIR=$PWD/BUILD'. - -version = 0.3 -dist = pure-$(version) - -prefix = /usr/local -bindir = $(prefix)/bin -libdir = $(prefix)/lib -mandir = $(prefix)/share/man/man1 - -# Shared library suffix. The default should work on most Linux and Unix -# systems. Use DLL=dll on Windows. - -DLL=so - -# Staging directory for 'make install'. If you use this, make sure that this -# ends in a slash. - -DESTDIR= - -# Linker flags. Adjust these as necessary for your system. - -# LDFLAGS is for additional linker options, LIBS for additional libraries that -# might be needed (e.g., -liconv on OSX and Windows). - -LDFLAGS= -LIBS= - -# Compilation flags. We currently provide the following build profiles: - -# 'default' compiles with extra runtime checks and debugging information. -# 'release' optimizes for execution speed (release version). -# 'debug' like 'default', but without any optimizations. -# 'debug2' extensive debugging output, useful to debug the interpreter. - -# The 'default' build should be suitable for most purposes. As of Pure 0.3, -# this build now also does basic optimizations and so isn't much slower than -# the 'release' build any more. In contrast to 'release', this build also -# provides diagnostics useful for maintainers if anything is wrong with the -# interpreter. - -# The 'release' build disables all runtime checks and debugging information -# and compiles with additional optimizations which makes programs go a little -# faster (some 5-10% on a single-cpu AMD system running Linux and gcc 4.1, -# YMMV); use this if performance is critical. - -# The 'debug' build is like 'default' but without any optimizations; it builds -# faster than 'default', but runs *much* slower, and isn't recommended for -# anything but debugging the interpreter. The 'debug2' build generates massive -# amounts of additional debugging messages, and is really only to be used by -# maintainers debugging the interpreter. - -# To build with a given profile, just say 'make build=<profile>', e.g.: 'make -# build=release'. (This option only has to be specified at build time, not for -# installation or any other targets except 'all'.) Just 'make' builds with the -# default flags. - -build=default - -LLVM_FLAGS = `llvm-config --cppflags` -LLVM_LIBS = `llvm-config --ldflags --libs core jit native` - -# NOTE: Some of the following flags are gcc-specific, so you'll have to fiddle -# with the options if you're using a different compiler. - -ifeq ($(build),default) -CXXFLAGS = -g -O -Wall $(LLVM_FLAGS) -CFLAGS = -g -O -Wall -else -ifeq ($(build),release) -CXXFLAGS = -O3 -DNDEBUG -DDEBUG=0 -Wall $(LLVM_FLAGS) -CFLAGS = -O3 -DNDEBUG -DDEBUG=0 -Wall -else -ifeq ($(build),debug) -CXXFLAGS = -g -Wall $(LLVM_FLAGS) -CFLAGS = -g -Wall -else -ifeq ($(build),debug2) -CXXFLAGS = -g -Wall -DDEBUG=2 $(LLVM_FLAGS) -CFLAGS = -g -Wall -DDEBUG=2 -else -CXXFLAGS = -g -O -Wall $(LLVM_FLAGS) -CFLAGS = -g -O -Wall -.PHONY: warn -warn: all - @echo "WARNING: Invalid build profile '$(build)'." - @echo "WARNING: Must be one of 'default', 'release', 'debug' and 'debug2'." - @echo "WARNING: Assuming 'default' profile." -endif -endif -endif -endif - -# Pure library name. Currently we use a simple versioning scheme, which -# requires that the library version matches that of the interpreter. With some -# fiddling, this enables you to install different versions of the Pure -# interpreter on the same system. - -libpure = libpure-$(version).$(DLL) - -# No need to edit below this line. Unless you really have to. :) ############ - -SOURCE = expr.cc expr.hh funcall.h interpreter.cc interpreter.hh lexer.ll \ -matcher.cc matcher.hh parser.yy printer.cc printer.hh \ -runtime.cc runtime.h symtable.cc symtable.hh util.cc util.hh -EXTRA_SOURCE = lexer.cc parser.cc parser.hh location.hh position.hh stack.hh -OBJECT = $(subst .cc,.o,$(filter %.cc,$(SOURCE) $(EXTRA_SOURCE))) -ALL_LIBS = -lreadline -lgmp $(LIBS) - -examples = $(wildcard examples/*.pure) -lib = $(wildcard lib/*.pure) -tests = $(wildcard test/*.pure) -logs = test/prelude.log $(tests:.pure=.log) -distlogs = $(wildcard test/*.log) - -DISTFILES = COPYING ChangeLog INSTALL NEWS README TODO Makefile \ -$(SOURCE) $(EXTRA_SOURCE) w3centities.c pure.cc pure.1 pure.xml pure.vim \ -$(examples) $(lib) $(tests) $(distlogs) - -.PHONY: all html dvi ps pdf clean realclean depend install uninstall strip \ -dist distcheck cleanlogs logs check - -# compilation - -all: pure - -pure: pure.o $(libpure) - $(CXX) -o $@ $(LDFLAGS) pure.o -L. -lpure-$(version) $(ALL_LIBS) - -$(libpure): $(OBJECT) - $(CXX) -shared -o $@ $(LDFLAGS) $(OBJECT) $(LLVM_LIBS) $(ALL_LIBS) - ln -sf $(libpure) libpure.$(DLL) - -pure.o: pure.cc - $(CXX) $(CXXFLAGS) -DVERSION='"$(version)"' -DPURELIB='"$(libdir)/pure"' -c -o $@ $< - -lexer.cc: lexer.ll - flex -o lexer.cc $< - -parser.cc: parser.yy - bison -v -o parser.cc $< - -parser.hh location.hh position.hh stack.hh: parser.cc - -# documentation in various formats (requires groff) - -html: pure.html -dvi: pure.dvi -ps: pure.ps -pdf: pure.pdf - -%.html: %.1 - groff -man -Thtml $< > $@ - -%.dvi: %.1 - groff -man -Tdvi $< > $@ - -%.ps: %.1 - groff -man -Tps $< > $@ - -%.pdf: %.1 - groff -man -Tps $< | ps2pdf - $@ - -# cleaning - -clean: - rm -f *~ *.bak *.html *.dvi *.ps pure $(OBJECT) pure.o libpure.$(DLL) $(libpure) parser.output - -cleanlogs: - rm -f $(logs) - -realclean: clean - rm -f $(EXTRA_SOURCE) $(logs) $(dist).tar.gz - -# dependencies - -depend: $(SOURCE) $(EXTRA_SOURCE) - makedepend -Y $(SOURCE) $(EXTRA_SOURCE) 2> /dev/null - -# installation - -install: pure $(lib) - install -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(mandir) - install pure $(DESTDIR)$(bindir)/pure - install $(libpure) $(DESTDIR)$(libdir)/$(libpure) - ln -sf $(libdir)/$(libpure) $(DESTDIR)$(libdir)/libpure.$(DLL) - install -m 644 $(lib) $(DESTDIR)$(libdir)/pure - install -m 644 pure.1 $(DESTDIR)$(mandir)/pure.1 - -uninstall: - rm -rf $(DESTDIR)$(bindir)/pure $(DESTDIR)$(libdir)/$(libpure) $(DESTDIR)$(libdir)/libpure.$(DLL) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(mandir)/pure.1 - -# roll a distribution tarball - -dist: $(DISTFILES) - rm -rf $(dist) - mkdir $(dist) && mkdir $(dist)/examples && mkdir $(dist)/lib && \ -mkdir $(dist)/test - for x in $(DISTFILES); do ln -sf $$PWD/$$x $(dist)/$$x; done - rm -f $(dist).tar.gz - tar cfzh $(dist).tar.gz $(dist) - rm -rf $(dist) - -distcheck: dist - tar xfz $(dist).tar.gz - cd $(dist) && make && make check && make install DESTDIR=./BUILD - rm -rf $(dist) - -# test logs, make check - -level=7 - -logs: $(logs) - -check: pure - @ echo Running tests. - @ (export LD_LIBRARY_PATH=.; export PURELIB=./lib; echo -n "prelude.pure: "; if ./pure -n -v$(level) lib/prelude.pure 2>&1 | diff -q - test/prelude.log > /dev/null; then echo passed; else echo FAILED; fi) - @ (cd test; export LD_LIBRARY_PATH=..; export PURELIB=../lib; for x in $(tests); do f="`basename $$x`"; l="`basename $$x .pure`.log"; echo -n "$$x: "; if ../pure -v$(level) < $$f 2>&1 | diff -q - $$l > /dev/null; then echo passed; else echo FAILED; fi; done) - -test/prelude.log: lib/prelude.pure lib/primitives.pure lib/strings.pure - LD_LIBRARY_PATH=. PURELIB=./lib ./pure -n -v$(level) $< > $@ 2>&1 - -%.log: %.pure - LD_LIBRARY_PATH=. PURELIB=./lib ./pure -v$(level) < $< > $@ 2>&1 - -# DO NOT DELETE - -expr.o: expr.hh interpreter.hh matcher.hh symtable.hh printer.hh runtime.h -expr.o: parser.hh stack.hh util.hh location.hh position.hh -interpreter.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh -interpreter.o: runtime.h parser.hh stack.hh util.hh location.hh position.hh -interpreter.o: expr.hh matcher.hh symtable.hh printer.hh runtime.h parser.hh -interpreter.o: stack.hh util.hh location.hh position.hh -lexer.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h -lexer.o: parser.hh stack.hh util.hh location.hh position.hh -matcher.o: matcher.hh expr.hh -matcher.o: expr.hh -parser.o: expr.hh printer.hh matcher.hh runtime.h util.hh interpreter.hh -parser.o: symtable.hh parser.hh stack.hh location.hh position.hh -printer.o: printer.hh expr.hh matcher.hh runtime.h interpreter.hh symtable.hh -printer.o: parser.hh stack.hh util.hh location.hh position.hh -printer.o: expr.hh matcher.hh runtime.h -pure.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h -pure.o: parser.hh stack.hh util.hh location.hh position.hh -runtime.o: runtime.h expr.hh interpreter.hh matcher.hh symtable.hh printer.hh -runtime.o: parser.hh stack.hh util.hh location.hh position.hh funcall.h -symtable.o: symtable.hh expr.hh printer.hh matcher.hh runtime.h -symtable.o: expr.hh printer.hh matcher.hh runtime.h -util.o: util.hh w3centities.c -lexer.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h -lexer.o: parser.hh stack.hh util.hh location.hh position.hh -parser.o: parser.hh stack.hh expr.hh printer.hh matcher.hh runtime.h util.hh -parser.o: location.hh position.hh interpreter.hh symtable.hh -parser.o: stack.hh expr.hh printer.hh matcher.hh runtime.h util.hh -parser.o: location.hh position.hh -location.o: position.hh Added: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in (rev 0) +++ pure/trunk/Makefile.in 2008-06-03 22:21:33 UTC (rev 165) @@ -0,0 +1,231 @@ + +# This Makefile requires GNU make. Really. + +SHELL = /bin/sh + +# Package information. + +name = @PACKAGE_NAME@ +version = @PACKAGE_VERSION@ +dist = $(name)-$(version) + +# Source and installation paths. + +srcdir = @srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datarootdir = @datarootdir@ + +bindir = @bindir@ +includedir = @includedir@ +libdir = @libdir@ +datadir = @datadir@ +mandir = @mandir@ +man1dir = $(mandir)/man1 + +# Staging directory for 'make install'. If you use this, make sure that it +# ends in a slash. + +DESTDIR= + +# OS-specific file suffixes. Windows (EXE=.exe, DLL=.dll) is handled +# automatically by configure, for other systems with unusual conventions set +# these as needed. + +EXE=@EXEEXT@ +ifeq ($(EXE),.exe) +DLL=.dll +else +DLL=.so +endif + +# Linker flags and required libraries. These are determined automatically by +# configure. Use EXTRA_LIBS to add any additional platform-specific libraries +# that might be required. + +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ $(EXTRA_LIBS) + +ifeq ($(EXE),.exe) +EXTRA_LIBS = -limagehlp -lpsapi +else +EXTRA_LIBS = +endif + +# Compilation flags. + +LLVM_FLAGS = `llvm-config --cppflags` +LLVM_LIBS = `llvm-config --ldflags --libs core jit native` + +CPPFLAGS = @CPPFLAGS@ $(LLVM_FLAGS) +CXXFLAGS = @CXXFLAGS@ -Wall + +# Pure library name. Currently we use a simple versioning scheme, which +# requires that the library version matches that of the interpreter. With some +# fiddling, this enables you to install different versions of the Pure +# interpreter on the same system. + +libpure_base = $(name) +libpure_vers = $(libpure_base)-$(version) + +libpure = lib$(libpure_vers)$(DLL) +libpurelnk = lib$(libpure_base)$(DLL) +LIBPURE = -l$(libpure_vers) + +# No need to edit below this line. Unless you really have to. :) ############ + +SOURCE = expr.cc expr.hh funcall.h interpreter.cc interpreter.hh lexer.ll \ +matcher.cc matcher.hh parser.yy printer.cc printer.hh \ +runtime.cc runtime.h symtable.cc symtable.hh util.cc util.hh +EXTRA_SOURCE = lexer.cc parser.cc parser.hh location.hh position.hh stack.hh +OBJECT = $(subst .cc,.o,$(filter %.cc,$(SOURCE) $(EXTRA_SOURCE))) + +DISTFILES = COPYING ChangeLog INSTALL NEWS README TODO \ +Makefile.in aclocal.m4 configure.ac configure config.h.in \ +$(SOURCE) $(EXTRA_SOURCE) w3centities.c pure.cc pure.1 pure.xml pure.vim \ +examples/*.pure lib/*.pure test/*.pure test/*.log + +.PHONY: all html dvi ps pdf clean realclean depend install uninstall strip \ +dist distcheck cleanlogs logs check + +# compilation + +all: pure$(EXE) + +pure$(EXE): pure.o $(libpure) + $(CXX) -o $@ $(LDFLAGS) pure.o -L. $(LIBPURE) $(LIBS) + +$(libpure): $(OBJECT) + $(CXX) -shared -o $@ $(LDFLAGS) $(OBJECT) $(LLVM_LIBS) $(LIBS) + ln -sf $(libpure) $(libpurelnk) + +pure.o: pure.cc + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -DPURELIB='"$(libdir)/pure"' -c -o $@ $< + +lexer.cc: lexer.ll + flex -o lexer.cc $< + +parser.cc: parser.yy + bison -v -o parser.cc $< + +parser.hh location.hh position.hh stack.hh: parser.cc + +# documentation in various formats (requires groff) + +html: pure.html +dvi: pure.dvi +ps: pure.ps +pdf: pure.pdf + +%.html: %.1 + groff -man -Thtml $< > $@ + +%.dvi: %.1 + groff -man -Tdvi $< > $@ + +%.ps: %.1 + groff -man -Tps $< > $@ + +%.pdf: %.1 + groff -man -Tps $< | ps2pdf - $@ + +# cleaning + +clean: + rm -f *~ *.bak *.html *.dvi *.ps *.pdf pure$(EXE) $(OBJECT) pure.o $(libpurelnk) $(libpure) parser.output + +distclean: clean + rm -f Makefile config.h config.log config.status $(dist).tar.gz + +realclean: distclean + rm -f $(addprefix $(srcdir)/, test/*.log $(EXTRA_SOURCE)) + +# dependencies (rerun configure after this) + +depend: $(SOURCE) $(EXTRA_SOURCE) + (cd $(srcdir) && makedepend -f Makefile.in -Y pure.cc $(SOURCE) $(EXTRA_SOURCE) 2> /dev/null) + +# installation + +install: pure$(EXE) + install -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(man1dir) + install pure$(EXE) $(DESTDIR)$(bindir)/pure$(EXE) + install $(libpure) $(DESTDIR)$(libdir)/$(libpure) + ln -sf $(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) + install -m 644 $(srcdir)/lib/*.pure $(DESTDIR)$(libdir)/pure + install -m 644 pure.1 $(DESTDIR)$(man1dir)/pure.1 + +uninstall: + rm -rf $(DESTDIR)$(bindir)/pure$(EXE) $(DESTDIR)$(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(man1dir)/pure.1 + +# roll a distribution tarball + +dist: + rm -rf $(dist) + mkdir $(dist) && mkdir $(dist)/examples && mkdir $(dist)/lib && mkdir $(dist)/test + (builddir=$$PWD; cd $(srcdir); for x in $(DISTFILES); do ln -sf $$PWD/$$x $$builddir/$(dist)/$$x; done) + rm -f $(dist).tar.gz + tar cfzh $(dist).tar.gz $(dist) + rm -rf $(dist) + +distcheck: dist + tar xfz $(dist).tar.gz + cd $(dist) && ./configure && make && make check && make install DESTDIR=./BUILD + rm -rf $(dist) + +# test logs, make check + +level=7 + +tests = $(wildcard $(srcdir)/test/*.pure) +logs = $(srcdir)/test/prelude.log $(tests:.pure=.log) + +logs: $(logs) + +cleanlogs: + rm -f $(srcdir)/test/*.log + +$(srcdir)/test/prelude.log: lib/prelude.pure lib/primitives.pure lib/strings.pure + LD_LIBRARY_PATH=. PURELIB=$(srcdir)/lib ./pure -n -v$(level) $< > $@ 2>&1 + +%.log: %.pure + LD_LIBRARY_PATH=. PURELIB=$(srcdir)/lib ./pure -v$(level) < $< > $@ 2>&1 + +check: pure + @ echo Running tests. + @ (export LD_LIBRARY_PATH=.; export PURELIB=$(srcdir)/lib; echo -n "prelude.pure: "; if ./pure -n -v$(level) $(srcdir)/lib/prelude.pure 2>&1 | diff -q - $(srcdir)/test/prelude.log > /dev/null; then echo passed; else echo FAILED; fi) + @ (export LD_LIBRARY_PATH=.; export PURELIB=$(srcdir)/lib; for x in $(notdir $(tests)); do echo -n "$$x: "; if ./pure -v$(level) < $(srcdir)/test/$$x 2>&1 | diff -q - $(srcdir)/test/"`basename $$x .pure`.log" > /dev/null; then echo passed; else echo FAILED; fi; done) + +# DO NOT DELETE + +pure.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h +pure.o: parser.hh stack.hh util.hh location.hh position.hh config.h +expr.o: expr.hh interpreter.hh matcher.hh symtable.hh printer.hh runtime.h +expr.o: parser.hh stack.hh util.hh location.hh position.hh +interpreter.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh +interpreter.o: runtime.h parser.hh stack.hh util.hh location.hh position.hh +interpreter.o: expr.hh matcher.hh symtable.hh printer.hh runtime.h parser.hh +interpreter.o: stack.hh util.hh location.hh position.hh +lexer.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h +lexer.o: parser.hh stack.hh util.hh location.hh position.hh +matcher.o: matcher.hh expr.hh +matcher.o: expr.hh +parser.o: expr.hh printer.hh matcher.hh runtime.h util.hh interpreter.hh +parser.o: symtable.hh parser.hh stack.hh location.hh position.hh +printer.o: printer.hh expr.hh matcher.hh runtime.h interpreter.hh symtable.hh +printer.o: parser.hh stack.hh util.hh location.hh position.hh +printer.o: expr.hh matcher.hh runtime.h +runtime.o: runtime.h expr.hh interpreter.hh matcher.hh symtable.hh printer.hh +runtime.o: parser.hh stack.hh util.hh location.hh position.hh funcall.h +symtable.o: symtable.hh expr.hh printer.hh matcher.hh runtime.h +symtable.o: expr.hh printer.hh matcher.hh runtime.h +util.o: util.hh config.h w3centities.c +lexer.o: interpreter.hh expr.hh matcher.hh symtable.hh printer.hh runtime.h +lexer.o: parser.hh stack.hh util.hh location.hh position.hh +parser.o: parser.hh stack.hh expr.hh printer.hh matcher.hh runtime.h util.hh +parser.o: location.hh position.hh interpreter.hh symtable.hh +parser.o: stack.hh expr.hh printer.hh matcher.hh runtime.h util.hh +parser.o: location.hh position.hh +location.o: position.hh Added: pure/trunk/aclocal.m4 =================================================================== --- pure/trunk/aclocal.m4 (rev 0) +++ pure/trunk/aclocal.m4 2008-06-03 22:21:33 UTC (rev 165) @@ -0,0 +1,84 @@ +dnl iconv check from Bruno Haible. + +AC_DEFUN([AM_ICONV], +[ + dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and + dnl those with the standalone portable GNU libiconv installed). + + am_cv_lib_iconv_ldpath= + AC_ARG_WITH([libiconv-prefix], +[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [ + for dir in `echo "$withval" | tr : ' '`; do + if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi + if test -d $dir/lib; then am_cv_lib_iconv_ldpath="-L$dir/lib"; fi + done + ]) + + AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [ + am_cv_func_iconv="no, consider installing GNU libiconv" + am_cv_lib_iconv=no + AC_TRY_LINK([#include <stdlib.h> +#include <iconv.h>], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_func_iconv=yes) + if test "$am_cv_func_iconv" != yes; then + am_save_LIBS="$LIBS" + LIBS="$LIBS $am_cv_libiconv_ldpath -liconv" + AC_TRY_LINK([#include <stdlib.h> +#include <iconv.h>], + [iconv_t cd = iconv_open("",""); + iconv(cd,NULL,NULL,NULL,NULL); + iconv_close(cd);], + am_cv_lib_iconv=yes + am_cv_func_iconv=yes) + LIBS="$am_save_LIBS" + fi + ]) + if test "$am_cv_func_iconv" = yes; then + AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.]) + AC_MSG_CHECKING([for iconv declaration]) + AC_CACHE_VAL(am_cv_proto_iconv, [ + AC_TRY_COMPILE([ +#include <stdlib.h> +#include <iconv.h> +extern +#ifdef __cplusplus +"C" +#endif +#if defined(__STDC__) || defined(__cplusplus) +size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); +#else +size_t iconv(); +#endif +], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const") + am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) + am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` + AC_MSG_RESULT([$]{ac_t:- + }[$]am_cv_proto_iconv) + AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1, + [Define as const if the declaration of iconv() needs const.]) + fi + LIBICONV= + if test "$am_cv_lib_iconv" = yes; then + LIBICONV="$am_cv_lib_iconv_ldpath -liconv" + fi + AC_SUBST(LIBICONV) +]) + +dnl nl_langinfo/CODESET check from Bruno Haible. + +AC_DEFUN([AM_LANGINFO_CODESET], +[ + AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset, + [AC_TRY_LINK([#include <langinfo.h>], + [char* cs = nl_langinfo(CODESET);], + am_cv_langinfo_codeset=yes, + am_cv_langinfo_codeset=no) + ]) + if test $am_cv_langinfo_codeset = yes; then + AC_DEFINE(HAVE_LANGINFO_CODESET, 1, + [Define if you have <langinfo.h> and nl_langinfo(CODESET).]) + fi +]) Added: pure/trunk/config.h.in =================================================================== --- pure/trunk/config.h.in (rev 0) +++ pure/trunk/config.h.in 2008-06-03 22:21:33 UTC (rev 165) @@ -0,0 +1,37 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define if you have the iconv() function. */ +#undef HAVE_ICONV + +/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */ +#undef HAVE_LANGINFO_CODESET + +/* Define to 1 if you have the `glob' library (-lglob). */ +#undef HAVE_LIBGLOB + +/* Define to 1 if you have the `gmp' library (-lgmp). */ +#undef HAVE_LIBGMP + +/* Define to 1 if you have the `readline' library (-lreadline). */ +#undef HAVE_LIBREADLINE + +/* Define to 1 if you have the `regex' library (-lregex). */ +#undef HAVE_LIBREGEX + +/* Define as const if the declaration of iconv() needs const. */ +#undef ICONV_CONST + +/* 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 version of this package. */ +#undef PACKAGE_VERSION Added: pure/trunk/configure =================================================================== --- pure/trunk/configure (rev 0) +++ pure/trunk/configure 2008-06-03 22:21:33 UTC (rev 165) @@ -0,0 +1,4587 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61 for pure 0.3. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 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=: + # Zsh 3.x and 4.x performs 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 + + + + +# PATH needs CR +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +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.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +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 + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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 + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell aut...@gn... about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. 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" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # 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 +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +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 +fi +echo >conf$$.file +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 -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +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=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# 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 7<&0 </dev/null 6>&1 + +# Name of the host. +# hostname on some systems (SVR3.2, 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= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='pure' +PACKAGE_TARNAME='pure' +PACKAGE_VERSION='0.3' +PACKAGE_STRING='pure 0.3' +PACKAGE_BUGREPORT='' + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +CXX +CXXFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CXX +EXEEXT +OBJEXT +CC +CFLAGS +ac_ct_CC +LIBICONV +LIBOBJS +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CXX +CXXFLAGS +LDFLAGS +LIBS +CPPFLAGS +CCC +CC +CFLAGS' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# 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=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_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=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_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=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 ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + 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'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +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 + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +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 + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + 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 .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# 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 -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + 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 .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + 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 pure 0.3 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/pure] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of pure 0.3:";; + esac + cat <<\_ACEOF + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib + +Some influential environment variables: + CXX C++ compiler command + CXXFLAGS C++ compiler flags + LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a + nonstandard directory <lib dir> + LIBS libraries to pass to the linker, e.g. -l<library> + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if + you have headers in a nonstandard directory <include dir> + CC C compiler command + CFLAGS C compiler flags + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_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" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`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 + 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 +pure configure 0.3 +generated by GNU Autoconf 2.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 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 +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 pure $as_me 0.3, which was +generated by GNU Autoconf 2.61. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || ... [truncated message content] |
From: <ag...@us...> - 2008-06-01 20:14:50
|
Revision: 164 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=164&view=rev Author: agraef Date: 2008-06-01 13:14:57 -0700 (Sun, 01 Jun 2008) Log Message: ----------- Make libpure.so a symbolic link to libpure-$(version).so. Modified Paths: -------------- pure/trunk/Makefile Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-06-01 19:54:01 UTC (rev 163) +++ pure/trunk/Makefile 2008-06-01 20:14:57 UTC (rev 164) @@ -138,6 +138,7 @@ $(libpure): $(OBJECT) $(CXX) -shared -o $@ $(LDFLAGS) $(OBJECT) $(LLVM_LIBS) $(ALL_LIBS) + ln -sf $(libpure) libpure.$(DLL) pure.o: pure.cc $(CXX) $(CXXFLAGS) -DVERSION='"$(version)"' -DPURELIB='"$(libdir)/pure"' -c -o $@ $< @@ -196,7 +197,7 @@ install -m 644 pure.1 $(DESTDIR)$(mandir)/pure.1 uninstall: - rm -rf $(DESTDIR)$(bindir)/pure $(DESTDIR)$(libdir)/$(libpure) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(mandir)/pure.1 + rm -rf $(DESTDIR)$(bindir)/pure $(DESTDIR)$(libdir)/$(libpure) $(DESTDIR)$(libdir)/libpure.$(DLL) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(mandir)/pure.1 # roll a distribution tarball This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-01 19:53:53
|
Revision: 163 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=163&view=rev Author: agraef Date: 2008-06-01 12:54:01 -0700 (Sun, 01 Jun 2008) Log Message: ----------- Update installation instructions. Modified Paths: -------------- pure/trunk/INSTALL Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-06-01 19:53:09 UTC (rev 162) +++ pure/trunk/INSTALL 2008-06-01 19:54:01 UTC (rev 163) @@ -82,9 +82,9 @@ $ sudo /sbin/ldconfig (The latter step is required on Linux systems to tell the dynamic linker to -update its cache so that it finds the Pure runtime library, libpure-x.y.so. -On other systems it may be sufficient to install the library in a location -which is searched by the dynamic linker.) +update its cache so that it finds the Pure runtime library, libpure.so. On +other systems it may be sufficient to install the library in a location which +is searched by the dynamic linker.) After the build is complete, you can check that Pure is working correctly on your computer, as follows: @@ -150,11 +150,11 @@ OTHER COMPILATION OPTIONS ===== =========== ======= -By default, the pure program is installed under /usr/local/bin, the -libpure-x.y.so library under /usr/local/lib, and the library scripts under -/usr/local/lib/pure. The installation directory can be changed by editing the -definition of the 'prefix' variable in the Makefile, or by specifying the -desired value on the 'make' command line, e.g.: +By default, the pure program goes to /usr/local/bin, the libpure.so library to +/usr/local/lib, and the Pure library scripts to /usr/local/lib/pure. The +installation directory can be changed by editing the definition of the +'prefix' variable in the Makefile, or by specifying the desired value on the +'make' command line, e.g.: $ make all install prefix=/usr @@ -163,7 +163,7 @@ be changed at runtime by setting corresponding environment variables, see the manpage for details). Also note that if you install Pure into a non-standard location, you may have to set the LD_LIBRARY_PATH variable so that the dynamic -linker finds the Pure runtime library, libpure-x.y.so. +linker finds the Pure runtime library, libpure.so. After your build is done, you can (and should) also run 'make check' to verify that your Pure interpreter works correctly. This can be done without @@ -171,7 +171,7 @@ if you just want to take it for a test drive, you can simply run it from the source directory, if you set up the following environment variables: -- LD_LIBRARY_PATH=. This is required on Linux systems so that libpure-x.y.so +- LD_LIBRARY_PATH=. This is required on Linux systems so that libpure.so is found. Other systems may require an analogous setting, or none at all. - PURELIB=./lib This is required on all systems so that the interpreter finds This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-01 19:53:08
|
Revision: 162 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=162&view=rev Author: agraef Date: 2008-06-01 12:53:09 -0700 (Sun, 01 Jun 2008) Log Message: ----------- Make libpure.so a symbolic link to libpure-$(version).so. Modified Paths: -------------- pure/trunk/Makefile Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-06-01 19:40:15 UTC (rev 161) +++ pure/trunk/Makefile 2008-06-01 19:53:09 UTC (rev 162) @@ -172,7 +172,7 @@ # cleaning clean: - rm -f *~ *.bak *.html *.dvi *.ps pure $(OBJECT) pure.o $(libpure) parser.output + rm -f *~ *.bak *.html *.dvi *.ps pure $(OBJECT) pure.o libpure.$(DLL) $(libpure) parser.output cleanlogs: rm -f $(logs) @@ -191,6 +191,7 @@ install -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(mandir) install pure $(DESTDIR)$(bindir)/pure install $(libpure) $(DESTDIR)$(libdir)/$(libpure) + ln -sf $(libdir)/$(libpure) $(DESTDIR)$(libdir)/libpure.$(DLL) install -m 644 $(lib) $(DESTDIR)$(libdir)/pure install -m 644 pure.1 $(DESTDIR)$(mandir)/pure.1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-01 19:40:10
|
Revision: 161 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=161&view=rev Author: agraef Date: 2008-06-01 12:40:15 -0700 (Sun, 01 Jun 2008) Log Message: ----------- Update installation instructions. Modified Paths: -------------- pure/trunk/INSTALL Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-06-01 19:29:20 UTC (rev 160) +++ pure/trunk/INSTALL 2008-06-01 19:40:15 UTC (rev 161) @@ -182,8 +182,9 @@ There are a number of other variables you can set on the 'make' command line if you need special compiler (CXXFLAGS) or linker flags (LDFLAGS), or if you -have to add platform-specific libraries (LIBS). Please see the Makefile for -additional information on these. +have to add platform-specific libraries (LIBS). The DLL variable allows you to +change the shared library suffix as appropriate for your system. Please see +the Makefile for additional information on these. As of Pure 0.3, the 'default' build now also includes basic optimizations (-O). This build should be ok for most purposes, and has the advantage that it @@ -197,13 +198,14 @@ This disables all runtime checks and debugging information in the interpreter and also uses a higher level of optimization. The 'release' build will usually give you faster execution times, but the differences aren't really that big -anymore (5-10% compared to the default flags on my Linux system running gcc -4.1, YMMV), so you are encouraged to use the 'default' build unless +anymore (less than 5% compared to the default flags on my Linux system running +gcc 4.1, YMMV), so you are encouraged to use the 'default' build unless performance is really critical. To get smaller executables with either the default or the release build, add 'LDFLAGS=-s' to the 'make' command (gcc only, other compilers may provide a -similar flag to strip compiled executables and libraries). +similar flag or a separate command to strip compiled executables and +libraries). You can also do a 'debug' build as follows: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-01 19:29:25
|
Revision: 160 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=160&view=rev Author: agraef Date: 2008-06-01 12:29:20 -0700 (Sun, 01 Jun 2008) Log Message: ----------- Move dll suffix into separate DLL variable. Modified Paths: -------------- pure/trunk/Makefile Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-06-01 18:29:47 UTC (rev 159) +++ pure/trunk/Makefile 2008-06-01 19:29:20 UTC (rev 160) @@ -17,16 +17,11 @@ libdir = $(prefix)/lib mandir = $(prefix)/share/man/man1 -# Pure library name. Currently we use a simple versioning scheme, which -# requires that the library version matches that of the interpreter. With some -# extra fiddling, this enables you to install different versions of the Pure -# interpreter on the same system. +# Shared library suffix. The default should work on most Linux and Unix +# systems. Use DLL=dll on Windows. -# NOTE: You might have to change the suffix .so for your system (e.g., use -# .dll on Windows). +DLL=so -libpure = libpure-$(version).so - # Staging directory for 'make install'. If you use this, make sure that this # ends in a slash. @@ -105,6 +100,13 @@ endif endif +# Pure library name. Currently we use a simple versioning scheme, which +# requires that the library version matches that of the interpreter. With some +# fiddling, this enables you to install different versions of the Pure +# interpreter on the same system. + +libpure = libpure-$(version).$(DLL) + # No need to edit below this line. Unless you really have to. :) ############ SOURCE = expr.cc expr.hh funcall.h interpreter.cc interpreter.hh lexer.ll \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-01 18:29:39
|
Revision: 159 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=159&view=rev Author: agraef Date: 2008-06-01 11:29:47 -0700 (Sun, 01 Jun 2008) Log Message: ----------- Comment change. Modified Paths: -------------- pure/trunk/examples/recursive.pure Modified: pure/trunk/examples/recursive.pure =================================================================== --- pure/trunk/examples/recursive.pure 2008-06-01 18:24:53 UTC (rev 158) +++ pure/trunk/examples/recursive.pure 2008-06-01 18:29:47 UTC (rev 159) @@ -3,13 +3,12 @@ (http://shootout.alioth.debian.org/). It can be used to measure aspects of the performance of the Pure interpreter and compiler. 2008-22-04 AG */ -/* Pure 0.1 (release build using gcc 4.1 on Linux) does the benchmark with an - input value of n=11 in 1m28s on my Athlon 2500+. (This is the user cpu time - as reported by 'time', which includes startup and compilation times.) - That's a factor of 34 against the C benchmark on the same machine, which - puts Pure in about the same league as MZScheme. That's not bad considering - that Pure is a fully dynamic language. Most of the credit goes to LLVM, of - course. ;-) */ +/* Pure 0.3 (release build using gcc 4.1 on Linux) does the benchmark with an + input value of n=11 in 1m23s on my Athlon 2500+. (This is the user cpu time + as reported by 'time', which includes startup and compilation times.) That + corresponds to a factor of 31 against the C benchmark on the same machine, + which isn't bad considering that Pure is a fully dynamic language. Most of + the credit goes to LLVM, of course. ;-) */ ack x::int y::int = y+1 if x == 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-01 18:24:50
|
Revision: 158 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=158&view=rev Author: agraef Date: 2008-06-01 11:24:53 -0700 (Sun, 01 Jun 2008) Log Message: ----------- Put runtime and interpreter into a shared library. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/INSTALL pure/trunk/Makefile pure/trunk/interpreter.cc Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-28 07:52:52 UTC (rev 157) +++ pure/trunk/ChangeLog 2008-06-01 18:24:53 UTC (rev 158) @@ -1,3 +1,12 @@ +2008-06-01 Albert Graef <Dr....@t-...> + + * Makefile, interpreter.cc: Put the runtime and interpreter into a + separate shared library, to make it possible for modules to link + against the runtime, and to reduce the memory footprint when + multiple instances of the interpreter are run as different + processes. Also, this makes it possible to access the runtime + routines on systems where a program cannot dlopen itself. + 2008-05-28 Albert Graef <Dr....@t-...> * interpreter.cc, runtime.cc: Optimization pure_freenew calls. Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-05-28 07:52:52 UTC (rev 157) +++ pure/trunk/INSTALL 2008-06-01 18:24:53 UTC (rev 158) @@ -4,11 +4,11 @@ These instructions (mostly by courtesy of Eddie Rucker, thanks Eddie!) explain how to compile and install LLVM (which is the compiler backend required by -Pure) and the Pure interpreter itself. More information about installing LLVM -and the required LLVM source packages can be found at http://llvm.org. Please -also have a look at the SYSTEM NOTES section at the end of this file which -describes the tweaks necessary to make Pure compile and run on various -platforms. +Pure) and the Pure interpreter itself. The instructions are for Linux and +similar Unix-like systems; the SYSTEM NOTES section at the end of this file +details the tweaks necessary to make Pure compile and run on various other +platforms. More information about installing LLVM and the required LLVM source +packages can be found at http://llvm.org. Pure is known to work on Linux and Mac OSX, but should compile (with the usual amount of tweaking) on all UNIX/POSIX-based platforms. We recommend using @@ -57,12 +57,15 @@ STEP 3. Configure, build and install LLVM as follows: $ cd llvm-2.2 -$ ./configure +$ ./configure --enable-optimized --disable-assertions --disable-expensive-checks --enable-targets=host-only $ make ENABLE_OPTIMIZED=1 $ sudo make install -(To do a debug build of LLVM, leave away the 'ENABLE_OPTIMIZED=1' parameter. -Note, however, that this will considerably slow down the Pure compiler.) +Note the configure flags; these are for an optimized (non-debug) build and +disable all compilation targets except the one for your system. To do a debug +build of LLVM, simply leave away all the extra configure parameters (except +possibly --enable-targets=host-only). Note, however, that this will +considerably slow down the Pure compiler. STEP 4. Get and unpack the Pure sources at: http://pure-lang.sf.net/ @@ -76,9 +79,12 @@ $ cd pure-x.y $ make $ sudo make install +$ sudo /sbin/ldconfig -Note that compiling Pure with optimizations enabled (this is the default) may -take quite a while, so please have some patience. +(The latter step is required on Linux systems to tell the dynamic linker to +update its cache so that it finds the Pure runtime library, libpure-x.y.so. +On other systems it may be sufficient to install the library in a location +which is searched by the dynamic linker.) After the build is complete, you can check that Pure is working correctly on your computer, as follows: @@ -138,35 +144,42 @@ $ cd pure-lang/pure/trunk $ make $ sudo make install +$ sudo /sbin/ldconfig OTHER COMPILATION OPTIONS ===== =========== ======= -By default, the pure program is installed under /usr/local/bin, with the -library files going into /usr/local/lib/pure. The installation directory can -be changed by editing the definition of the 'prefix' variable in the Makefile, -or by specifying the desired value on the 'make' command line, e.g.: +By default, the pure program is installed under /usr/local/bin, the +libpure-x.y.so library under /usr/local/lib, and the library scripts under +/usr/local/lib/pure. The installation directory can be changed by editing the +definition of the 'prefix' variable in the Makefile, or by specifying the +desired value on the 'make' command line, e.g.: $ make all install prefix=/usr Note that you should specify this option *both* at compile and installation time since certain default paths are hardcoded into the interpreter (but can be changed at runtime by setting corresponding environment variables, see the -manpage for details). +manpage for details). Also note that if you install Pure into a non-standard +location, you may have to set the LD_LIBRARY_PATH variable so that the dynamic +linker finds the Pure runtime library, libpure-x.y.so. After your build is done, you can (and should) also run 'make check' to verify that your Pure interpreter works correctly. This can be done without installing the software. In fact, there's no need to install the interpreter if you just want to take it for a test drive, you can simply run it from the -source directory. Just make sure that you set the PURELIB environment variable -to the lib directory in the sources which holds the prelude and the other -library scripts. The following command, +source directory, if you set up the following environment variables: -$ PURELIB=./lib ./pure +- LD_LIBRARY_PATH=. This is required on Linux systems so that libpure-x.y.so + is found. Other systems may require an analogous setting, or none at all. -will run the Pure interpreter with that setting in Bourne-compatible shells. +- PURELIB=./lib This is required on all systems so that the interpreter finds + the prelude and other library scripts. +After that you should be able to run the Pure interpreter from the source +directory, by typing './pure'. + There are a number of other variables you can set on the 'make' command line if you need special compiler (CXXFLAGS) or linker flags (LDFLAGS), or if you have to add platform-specific libraries (LIBS). Please see the Makefile for @@ -188,6 +201,10 @@ 4.1, YMMV), so you are encouraged to use the 'default' build unless performance is really critical. +To get smaller executables with either the default or the release build, add +'LDFLAGS=-s' to the 'make' command (gcc only, other compilers may provide a +similar flag to strip compiled executables and libraries). + You can also do a 'debug' build as follows: $ make build=debug @@ -241,20 +258,18 @@ ----- Linux is the primary development platform for this software, and the sources -should build out of the box on all recent Linux distributions. However, note -the issues on 64 bit Linux systems described above. +should build out of the box on all recent Linux distributions. MAC OSX --- --- A port by Ryan Schmidt exists in the MacPorts collection at http://www.macports.org/. If you compile Pure from the original sources -yourself, you should remove the -rdynamic option from the link line (it's not -needed on OSX) and add the -liconv flag instead. To these ends, build Pure -with the following make command (add the build=release option for the release -build): +yourself, you should add the -liconv flag to the link line. To these ends, +build Pure with the following make command (add the build=release option for +the release build): -$ make LDFLAGS="" LIBS="-liconv" +$ make LIBS="-liconv" Also note that with at least some current versions of the Apple gcc compiler (4.0.1 and similar) you'll get the (bogus) warning "control reaches end of @@ -266,12 +281,12 @@ MS WINDOWS -- ------- -Nobody has reported a successful port to this platform yet, but it should be -rather straightforward (albeit arduous) to do this with either Cygwin -(http://www.cygwin.com/) or Mingw (http://www.mingw.org/), once you have all -the necessary dependencies and a suitable version of LLVM installed. So *you* -can still be the hero who first got Pure up and running on Windows; if you do, -please let us know! :) +Jiri Spitz is currently working on a Windows port using Mingw. Once this is +finished, we'll provide Windows installation instructions here. For the time +being, you can try for yourself; porting should be rather straightforward with +either Cygwin (http://www.cygwin.com/) or Mingw (http://www.mingw.org/), once +you have all the necessary dependencies and a suitable version of LLVM +installed. May 2008 Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-28 07:52:52 UTC (rev 157) +++ pure/trunk/Makefile 2008-06-01 18:24:53 UTC (rev 158) @@ -14,9 +14,19 @@ prefix = /usr/local bindir = $(prefix)/bin -libdir = $(prefix)/lib/pure +libdir = $(prefix)/lib mandir = $(prefix)/share/man/man1 +# Pure library name. Currently we use a simple versioning scheme, which +# requires that the library version matches that of the interpreter. With some +# extra fiddling, this enables you to install different versions of the Pure +# interpreter on the same system. + +# NOTE: You might have to change the suffix .so for your system (e.g., use +# .dll on Windows). + +libpure = libpure-$(version).so + # Staging directory for 'make install'. If you use this, make sure that this # ends in a slash. @@ -25,12 +35,9 @@ # Linker flags. Adjust these as necessary for your system. # LDFLAGS is for additional linker options, LIBS for additional libraries that -# might be needed (e.g., -liconv on OSX). Note that the -rdynamic flag is -# required when using gcc with the ELF linker (e.g., Linux on x86) to enable -# the dlopening of the program executable. On OSX this option isn't needed -# (pass LDFLAGS="" to 'make' instead). +# might be needed (e.g., -liconv on OSX and Windows). -LDFLAGS=-rdynamic +LDFLAGS= LIBS= # Compilation flags. We currently provide the following build profiles: @@ -62,9 +69,6 @@ # installation or any other targets except 'all'.) Just 'make' builds with the # default flags. -# Note that both the 'default' and the 'release' build may take quite a while -# to compile (especially runtime.cc), so please be patient. ;-) - build=default LLVM_FLAGS = `llvm-config --cppflags` @@ -104,11 +108,11 @@ # No need to edit below this line. Unless you really have to. :) ############ SOURCE = expr.cc expr.hh funcall.h interpreter.cc interpreter.hh lexer.ll \ -matcher.cc matcher.hh parser.yy printer.cc printer.hh pure.cc \ +matcher.cc matcher.hh parser.yy printer.cc printer.hh \ runtime.cc runtime.h symtable.cc symtable.hh util.cc util.hh EXTRA_SOURCE = lexer.cc parser.cc parser.hh location.hh position.hh stack.hh OBJECT = $(subst .cc,.o,$(filter %.cc,$(SOURCE) $(EXTRA_SOURCE))) -ALL_LIBS = $(LLVM_LIBS) -lreadline -lgmp $(LIBS) +ALL_LIBS = -lreadline -lgmp $(LIBS) examples = $(wildcard examples/*.pure) lib = $(wildcard lib/*.pure) @@ -117,7 +121,7 @@ distlogs = $(wildcard test/*.log) DISTFILES = COPYING ChangeLog INSTALL NEWS README TODO Makefile \ -$(SOURCE) $(EXTRA_SOURCE) w3centities.c pure.1 pure.xml pure.vim \ +$(SOURCE) $(EXTRA_SOURCE) w3centities.c pure.cc pure.1 pure.xml pure.vim \ $(examples) $(lib) $(tests) $(distlogs) .PHONY: all html dvi ps pdf clean realclean depend install uninstall strip \ @@ -127,11 +131,14 @@ all: pure -pure: $(OBJECT) - $(CXX) -o $@ $(LDFLAGS) $(OBJECT) $(ALL_LIBS) +pure: pure.o $(libpure) + $(CXX) -o $@ $(LDFLAGS) pure.o -L. -lpure-$(version) $(ALL_LIBS) +$(libpure): $(OBJECT) + $(CXX) -shared -o $@ $(LDFLAGS) $(OBJECT) $(LLVM_LIBS) $(ALL_LIBS) + pure.o: pure.cc - $(CXX) $(CXXFLAGS) -DVERSION='"$(version)"' -DPURELIB='"$(libdir)"' -c -o $@ $< + $(CXX) $(CXXFLAGS) -DVERSION='"$(version)"' -DPURELIB='"$(libdir)/pure"' -c -o $@ $< lexer.cc: lexer.ll flex -o lexer.cc $< @@ -163,7 +170,7 @@ # cleaning clean: - rm -f *~ *.bak *.html *.dvi *.ps pure $(OBJECT) parser.output + rm -f *~ *.bak *.html *.dvi *.ps pure $(OBJECT) pure.o $(libpure) parser.output cleanlogs: rm -f $(logs) @@ -176,24 +183,17 @@ depend: $(SOURCE) $(EXTRA_SOURCE) makedepend -Y $(SOURCE) $(EXTRA_SOURCE) 2> /dev/null -# Strip symbols from the executable. You might want to run this on Linux -# systems before installation to get a smaller executable. *Never* do this on -# OSX though, as the symbols are needed to properly resolve the runtime -# externals which are linked into the executable. - -strip: pure - strip pure - # installation install: pure $(lib) - install -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(mandir) + install -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(mandir) install pure $(DESTDIR)$(bindir)/pure - install -m 644 $(lib) $(DESTDIR)$(libdir) + install $(libpure) $(DESTDIR)$(libdir)/$(libpure) + install -m 644 $(lib) $(DESTDIR)$(libdir)/pure install -m 644 pure.1 $(DESTDIR)$(mandir)/pure.1 uninstall: - rm -rf $(DESTDIR)$(bindir)/pure $(DESTDIR)$(libdir) $(DESTDIR)$(mandir)/pure.1 + rm -rf $(DESTDIR)$(bindir)/pure $(DESTDIR)$(libdir)/$(libpure) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(mandir)/pure.1 # roll a distribution tarball @@ -219,14 +219,14 @@ check: pure @ echo Running tests. - @ (export PURELIB=./lib; echo -n "prelude.pure: "; if ./pure -n -v$(level) lib/prelude.pure 2>&1 | diff -q - test/prelude.log > /dev/null; then echo passed; else echo FAILED; fi) - @ (cd test; export PURELIB=../lib; for x in $(tests); do f="`basename $$x`"; l="`basename $$x .pure`.log"; echo -n "$$x: "; if ../pure -v$(level) < $$f 2>&1 | diff -q - $$l > /dev/null; then echo passed; else echo FAILED; fi; done) + @ (export LD_LIBRARY_PATH=.; export PURELIB=./lib; echo -n "prelude.pure: "; if ./pure -n -v$(level) lib/prelude.pure 2>&1 | diff -q - test/prelude.log > /dev/null; then echo passed; else echo FAILED; fi) + @ (cd test; export LD_LIBRARY_PATH=..; export PURELIB=../lib; for x in $(tests); do f="`basename $$x`"; l="`basename $$x .pure`.log"; echo -n "$$x: "; if ../pure -v$(level) < $$f 2>&1 | diff -q - $$l > /dev/null; then echo passed; else echo FAILED; fi; done) test/prelude.log: lib/prelude.pure lib/primitives.pure lib/strings.pure - PURELIB=./lib ./pure -n -v$(level) $< > $@ 2>&1 + LD_LIBRARY_PATH=. PURELIB=./lib ./pure -n -v$(level) $< > $@ 2>&1 %.log: %.pure - PURELIB=./lib ./pure -v$(level) < $< > $@ 2>&1 + LD_LIBRARY_PATH=. PURELIB=./lib ./pure -v$(level) < $< > $@ 2>&1 # DO NOT DELETE Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-28 07:52:52 UTC (rev 157) +++ pure/trunk/interpreter.cc 2008-06-01 18:24:53 UTC (rev 158) @@ -61,6 +61,7 @@ if (!g_interp) { g_interp = this; stackdir = c_stack_dir(); + llvm::sys::DynamicLibrary::LoadLibraryPermanently("libpure", 0); } sstk_sz = 0; sstk_cap = 0x10000; // 64K This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 07:52:43
|
Revision: 157 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=157&view=rev Author: agraef Date: 2008-05-28 00:52:52 -0700 (Wed, 28 May 2008) Log Message: ----------- Update manual. Modified Paths: -------------- pure/trunk/pure.1 Modified: pure/trunk/pure.1 =================================================================== --- pure/trunk/pure.1 2008-05-28 06:30:29 UTC (rev 156) +++ pure/trunk/pure.1 2008-05-28 07:52:52 UTC (rev 157) @@ -185,6 +185,15 @@ with external C functions). Truth values are encoded as machine integers (as you might expect, zero denotes ``false'' and any non-zero value ``true''). .PP +Expressions are generally evaluated from left to right, innermost expressions +first, i.e., using +.I call by value +semantics. Pure also has a few built-in special forms (most notably, +conditional expressions and the short-circuit logical connectives && and ||) +which take some of their arguments using +.I call by name +semantics. +.PP Expressions consist of the following elements: .TP .B Constants: \fR4711, 4711G, 1.2e-3, \(dqHello,\ world!\en\(dq @@ -282,7 +291,11 @@ .TP .B Conditional expressions: if\fR\ x\ \fBthen\fR\ y\ \fBelse\fR\ z Evaluates to y or z depending on whether x is ``true'' (i.e., a nonzero -integer). +integer). An exception is generated if the condition is not an +integer. Conditional expressions are special forms with call-by-name arguments +y and z; only one of the branches is actually evaluated. (The logical +operators && and || are treated in a similar fashion, in order to implement +short-circuit semantics.) .TP .B Lambdas: \fR\ex\ ->\ y These work pretty much like in Haskell. More than one variable may be bound @@ -372,6 +385,20 @@ causes the given value to be evaluated (and the result to be printed, when running in interactive mode). .PP +Expressions are parsed according to the following precedence rules: Lambda +binds most weakly, followed by +.BR when , +.B with +and +.BR case , +followed by conditional expressions (\fBif\fP-\fBthen\fP-\fBelse\fP), followed +by the ``simple'' expressions (i.e., all other kinds of expressions involving +operators, function applications, constants, symbols and other primary +expressions). Precedence and associativity of operator symbols are given by +their declarations (in the prelude or the user's program), and function +application binds stronger than all operators. Parentheses can be used to +override default precedences and associativities as usual. +.PP For instance, here are two more function definitions showing most of these elements in action: .sp @@ -439,8 +466,8 @@ the built-in special form .B catch with the exception handler (a function to be applied to the exception value) -as the first and the expression to be evaluated as the second argument. For -instance: +as the first and the expression to be evaluated as the second (call-by-name) +argument. For instance: .sp .nf > catch error (throw hello_world); @@ -592,17 +619,32 @@ .PP The interpreter makes sure that the parameters in a call match; if not, the call is treated as a normal form expression. The range of supported C types is -a bit limited right now (void, bool, char, int, double, as well as arbitrary -pointer types, i.e.: void*, char*, etc.), but in practice these should cover -most kinds of calls that need to be done when interfacing to C libraries. Note -that char* is for string arguments and return values which need translation -between Pure's internal utf-8 representation and the system encoding, while -void* is for any generic kind of pointer (including strings, which are -\fInot\fP translated when passed/returned as void*). Any other kind of pointer -(except expr*, see below), is effectively treated as void* right now, although -in a future version the interpreter may keep track of the type names for the -purpose of checking parameter types. +a bit limited right now (void, bool, char, short, int, long, double, as well +as arbitrary pointer types, i.e.: void*, char*, etc.), but in practice these +should cover most kinds of calls that need to be done when interfacing to C +libraries. .PP +Since Pure only has 32 bit machine integers and GMP bigints, a variety of C +integer types are provided which are converted from/to the Pure types in a +straightfoward way. The short type indicates 16 bit integers which are +converted from/to Pure machine ints using truncation and sign extension, +respectively. The long type +.I always +denotes 64 bit integers, even if the corresponding C type is actually 32 bit +(as it usually is on most contemporary systems). This type is to be used if a +C function takes or returns 64 bit integer values. For a long parameter you +can either pass a Pure machine int (which is sign-extended to 64 bit) or a +Pure bigint (which is truncated to 64 bit if necessary). 64 bit return values +are always converted to (signed) Pure bigints. +.PP +Concerning the pointer types, char* is for string arguments and return values +which need translation between Pure's internal utf-8 representation and the +system encoding, while void* is for any generic kind of pointer (including +strings, which are \fInot\fP translated when passed/returned as void*). Any +other kind of pointer (except expr*, see below) is effectively treated as +void* right now, although in a future version the interpreter may keep track +of the type names for the purpose of checking parameter types. +.PP The expr* pointer type is special; it indicates a Pure expression parameter or return value which is just passed through unchanged. All other types of values have to be ``unboxed'' when they are passed as arguments (i.e., from Pure to @@ -685,8 +727,8 @@ file for details on the provided operations. Also, the beginnings of a system interface can be found in the .B system.pure -module. In particular, this also includes operations to do basic I/O using -text files. More stuff will be provided in future releases. +module. In particular, this also includes operations to do basic I/O. More +stuff will be provided in future releases. .SH INTERACTIVE USAGE In interactive mode, the interpreter reads definitions and expressions and processes them as usual. The input language is just the same as for source @@ -1011,6 +1053,13 @@ a list of tuples, you must use the syntax (1,2):(3,4):[] instead; this is also the notation used when the interpreter prints such objects. .PP +.B Special forms. +Special forms are recognized at compile time only. Thus the catch function as +well as the short-circuit logical connectives && and || are only treated as +special forms in direct (saturated) calls. They can still be used if you pass +them around as function values or partial applications, but in this case they +lose all their special call-by-name argument processing. +.PP .B Manipulating function applications. The ``head = function'' rule means that the head symbol f of an application f x1 ... xn occurring on (or inside) the left-hand side of an equation, pattern @@ -1109,6 +1158,13 @@ without having to recompile the entire program.) However, mutual tail recursion does work with \fIlocal\fP functions, so it's easy to work around this limitation. +.PP +Scheme programmers should note that conditional expressions +(\fBif\fP-\fBthen\fP-\fBelse\fP) are tail-recursive in both branches, just +like in Scheme, while the logical operators && and || are +.I not +tail-recursive. This is because the logical operators always return a proper +truth value (0 or 1) which wouldn't be possible with tail call semantics. .SH FILES .TP .B ~/.pure_history This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 06:30:21
|
Revision: 156 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=156&view=rev Author: agraef Date: 2008-05-27 23:30:29 -0700 (Tue, 27 May 2008) Log Message: ----------- Update keyword table. Modified Paths: -------------- pure/trunk/pure.vim pure/trunk/pure.xml Modified: pure/trunk/pure.vim =================================================================== --- pure/trunk/pure.vim 2008-05-28 06:10:33 UTC (rev 155) +++ pure/trunk/pure.vim 2008-05-28 06:30:29 UTC (rev 156) @@ -35,7 +35,8 @@ syn keyword pureKeyword infix infixl infixr prefix postfix nullary syn keyword pureKeyword case else end extern if let of otherwise then syn keyword pureKeyword using when with -syn keyword pureIdentifier bigint bool char double expr int string pointer void +syn keyword pureIdentifier bigint bool char short int long double +syn keyword pureIdentifier expr string pointer void syn match pureNumber "\<[0-9]*\>" syn match pureHexNumber "\<0[Xx][0-9A-Fa-f]*\>" Modified: pure/trunk/pure.xml =================================================================== --- pure/trunk/pure.xml 2008-05-28 06:10:33 UTC (rev 155) +++ pure/trunk/pure.xml 2008-05-28 06:30:29 UTC (rev 156) @@ -28,7 +28,9 @@ <item> char </item> <item> double </item> <item> expr </item> + <item> short </item> <item> int </item> + <item> long </item> <item> string </item> <item> pointer </item> <item> void </item> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 06:10:25
|
Revision: 155 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=155&view=rev Author: agraef Date: 2008-05-27 23:10:33 -0700 (Tue, 27 May 2008) Log Message: ----------- Remove obsolete debugging code. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-28 06:08:40 UTC (rev 154) +++ pure/trunk/interpreter.cc 2008-05-28 06:10:33 UTC (rev 155) @@ -3669,12 +3669,6 @@ // local arg reference Env &e = act_env(); uint32_t k = 0; - if (e.b && e.n == 0) { - llvm::cerr << e.name << ": vref: " << symtab.sym(tag).s << ":"; - for (size_t i = 0; i < p.len(); i++) - llvm::cerr << (unsigned)p[i]; - llvm::cerr << endl; - } if (e.b) // pattern binding assert(e.n==1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 06:08:35
|
Revision: 154 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=154&view=rev Author: agraef Date: 2008-05-27 23:08:40 -0700 (Tue, 27 May 2008) Log Message: ----------- Flush stdout before printing error messages. This hopefully fixes error messages being printed too early, as reported by Jiri Spitz for the eee PC. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-28 05:58:54 UTC (rev 153) +++ pure/trunk/interpreter.cc 2008-05-28 06:08:40 UTC (rev 154) @@ -23,6 +23,7 @@ { // This is just to give a little more informative error message before we // bail out anyway. + cout.flush(); cerr << "error trying to resolve external: " << name << endl; assert(0); return 0; @@ -317,6 +318,7 @@ interpreter::error(const yy::location& l, const string& m) { nerrs++; + cout.flush(); if (!source_s) cerr << l << ": " << m << endl; } @@ -324,18 +326,21 @@ interpreter::error(const string& m) { nerrs++; + cout.flush(); if (!source_s) cerr << m << endl; } void interpreter::warning(const yy::location& l, const string& m) { + cout.flush(); if (!source_s) cerr << l << ": " << m << endl; } void interpreter::warning(const string& m) { + cout.flush(); if (!source_s) cerr << m << endl; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 05:58:46
|
Revision: 153 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=153&view=rev Author: agraef Date: 2008-05-27 22:58:54 -0700 (Tue, 27 May 2008) Log Message: ----------- Remove obsolete debugging code. Modified Paths: -------------- pure/trunk/runtime.cc Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-05-28 05:50:36 UTC (rev 152) +++ pure/trunk/runtime.cc 2008-05-28 05:58:54 UTC (rev 153) @@ -491,7 +491,6 @@ (sizeof(mp_limb_t) == 8) ? (uint64_t)mpz_getlimbn(x->data.z, 0) : (mpz_getlimbn(x->data.z, 0) + (((uint64_t)mpz_getlimbn(x->data.z, 1))<<32)); - cerr << "v = " << v << endl; return (mpz_sgn(x->data.z) < 0) ? -(int64_t)v : (int64_t)v; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 05:50:28
|
Revision: 152 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=152&view=rev Author: agraef Date: 2008-05-27 22:50:36 -0700 (Tue, 27 May 2008) Log Message: ----------- Optimization pure_freenew calls. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/interpreter.cc pure/trunk/runtime.cc Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-28 04:58:13 UTC (rev 151) +++ pure/trunk/ChangeLog 2008-05-28 05:50:36 UTC (rev 152) @@ -1,5 +1,7 @@ 2008-05-28 Albert Graef <Dr....@t-...> + * interpreter.cc, runtime.cc: Optimization pure_freenew calls. + * lib/strings.pure: Make 'cycle' work on strings. Reported by Eddie Rucker. Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-28 04:58:13 UTC (rev 151) +++ pure/trunk/interpreter.cc 2008-05-28 05:50:36 UTC (rev 152) @@ -2823,8 +2823,10 @@ Value *u = codegen(x); Value *p = e.builder.CreateBitCast(u, IntExprPtrTy, "intexpr"); Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "intval"); +#if 0 // collect the temporary, it's not needed any more call("pure_freenew", u); +#endif return v; } else { // double variable, needs unboxing and int conversion @@ -2833,8 +2835,10 @@ Value *p = e.builder.CreateBitCast(u, DblExprPtrTy, "dblexpr"); Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "dblval"); v = e.builder.CreateFPToSI(v, Type::Int32Ty); +#if 0 // collect the temporary, it's not needed any more call("pure_freenew", u); +#endif return v; } } else { @@ -2876,8 +2880,10 @@ Value *p = e.builder.CreateBitCast(u, IntExprPtrTy, "intexpr"); Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "intval"); v = e.builder.CreateSIToFP(v, Type::DoubleTy); +#if 0 // collect the temporary, it's not needed any more call("pure_freenew", u); +#endif return v; } else { // double variable, needs unboxing @@ -2885,8 +2891,10 @@ Value *u = codegen(x); Value *p = e.builder.CreateBitCast(u, DblExprPtrTy, "dblexpr"); Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "dblval"); +#if 0 // collect the temporary, it's not needed any more call("pure_freenew", u); +#endif return v; } } else { Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-05-28 04:58:13 UTC (rev 151) +++ pure/trunk/runtime.cc 2008-05-28 05:50:36 UTC (rev 152) @@ -806,7 +806,8 @@ extern "C" void pure_freenew(pure_expr *x) { - pure_free_internal(pure_new_internal(x)); + if (x->refc == 0) + pure_free_internal(pure_new_internal(x)); } extern "C" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 04:58:09
|
Revision: 151 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=151&view=rev Author: agraef Date: 2008-05-27 21:58:13 -0700 (Tue, 27 May 2008) Log Message: ----------- Wrapper should do a tail call of the Pure function if possible. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-28 03:56:18 UTC (rev 150) +++ pure/trunk/interpreter.cc 2008-05-28 04:58:13 UTC (rev 151) @@ -4115,6 +4115,7 @@ f.builder.SetInsertPoint(bb); CallInst* v = f.builder.CreateCall(f.f, myargs.begin(), myargs.end()); v->setCallingConv(cc); + if (cc == CallingConv::Fast) v->setTailCall(); f.builder.CreateRet(v); // validate the generated code, checking for consistency verifyFunction(*f.h); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 03:56:09
|
Revision: 150 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=150&view=rev Author: agraef Date: 2008-05-27 20:56:18 -0700 (Tue, 27 May 2008) Log Message: ----------- Overhaul of prelude. Modified Paths: -------------- pure/trunk/lib/strings.pure pure/trunk/test/prelude.log Modified: pure/trunk/lib/strings.pure =================================================================== --- pure/trunk/lib/strings.pure 2008-05-28 03:55:48 UTC (rev 149) +++ pure/trunk/lib/strings.pure 2008-05-28 03:56:18 UTC (rev 150) @@ -140,6 +140,9 @@ /* Define the customary list operations on strings, so that these can mostly be used as if they were lists. */ +list s::string = chars s; +tuple s::string = tuple (chars s); + reverse s::string = strcat (reverse (chars s)); cat (s::string:xs) = cat (chars s:xs); Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-05-28 03:55:48 UTC (rev 149) +++ pure/trunk/test/prelude.log 2008-05-28 03:56:18 UTC (rev 150) @@ -293,6 +293,8 @@ <var> state 1 state 1: #0 } end if not null delim/*0:01*/; +list s/*0:1*/::string = chars s/*0:1*/; +tuple s/*0:1*/::string = tuple (chars s/*0:1*/); reverse s/*0:1*/::string = strcat (reverse (chars s/*0:1*/)); cat (s/*0:101*/::string:xs/*0:11*/) = cat (chars s/*0:101*/:xs/*0:11*/); cycle n/*0:01*/::int "" = ""; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 03:55:42
|
Revision: 149 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=149&view=rev Author: agraef Date: 2008-05-27 20:55:48 -0700 (Tue, 27 May 2008) Log Message: ----------- Add missing dependencies on prelude.log. Modified Paths: -------------- pure/trunk/Makefile Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-28 03:41:08 UTC (rev 148) +++ pure/trunk/Makefile 2008-05-28 03:55:48 UTC (rev 149) @@ -222,7 +222,7 @@ @ (export PURELIB=./lib; echo -n "prelude.pure: "; if ./pure -n -v$(level) lib/prelude.pure 2>&1 | diff -q - test/prelude.log > /dev/null; then echo passed; else echo FAILED; fi) @ (cd test; export PURELIB=../lib; for x in $(tests); do f="`basename $$x`"; l="`basename $$x .pure`.log"; echo -n "$$x: "; if ../pure -v$(level) < $$f 2>&1 | diff -q - $$l > /dev/null; then echo passed; else echo FAILED; fi; done) -test/prelude.log: lib/prelude.pure +test/prelude.log: lib/prelude.pure lib/primitives.pure lib/strings.pure PURELIB=./lib ./pure -n -v$(level) $< > $@ 2>&1 %.log: %.pure This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 03:41:03
|
Revision: 148 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=148&view=rev Author: agraef Date: 2008-05-27 20:41:08 -0700 (Tue, 27 May 2008) Log Message: ----------- Overhaul of prelude. Modified Paths: -------------- pure/trunk/test/prelude.log Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-05-28 03:40:55 UTC (rev 147) +++ pure/trunk/test/prelude.log 2008-05-28 03:41:08 UTC (rev 148) @@ -295,6 +295,22 @@ } end if not null delim/*0:01*/; reverse s/*0:1*/::string = strcat (reverse (chars s/*0:1*/)); cat (s/*0:101*/::string:xs/*0:11*/) = cat (chars s/*0:101*/:xs/*0:11*/); +cycle n/*0:01*/::int "" = ""; +cycle n/*0:01*/::int s/*0:1*/::string = "" if n/*0:01*/<=0; +cycle n/*0:01*/::int s/*0:1*/::string = accum/*0*/ [] n/*1:01*/ with accum ys/*0:01*/ n/*0:1*/ = strcat ys/*0:01*/+take n/*0:1*/ s/*2:1*/ if n/*0:1*/<=m/*1:*/; accum ys/*0:01*/ n/*0:1*/ = accum/*1*/ (s/*2:1*/:ys/*0:01*/) (n/*0:1*/-m/*1:*/) { + rule #0: accum ys n = strcat ys+take n s if n<=m + rule #1: accum ys n = accum (s:ys) (n-m) + state 0: #0 #1 + <var> state 1 + state 1: #0 #1 + <var> state 2 + state 2: #0 #1 +} end when m/*0:*/::int = #s/*0:1*/ { + rule #0: m::int = #s + state 0: #0 + <var>::int state 1 + state 1: #0 +} end; all p/*0:01*/ s/*0:1*/::string = all p/*0:01*/ (chars s/*0:1*/); any p/*0:01*/ s/*0:1*/::string = any p/*0:01*/ (chars s/*0:1*/); do f/*0:01*/ s/*0:1*/::string = do f/*0:01*/ (chars s/*0:1*/); @@ -1033,6 +1049,46 @@ state 28: #2 #3 #4 } end; catmap f/*0:01*/ xs/*0:1*/ = cat (map f/*0:01*/ xs/*0:1*/); +index [] _/*0:1*/ = -1; +index (x/*0:0101*/:xs/*0:011*/) y/*0:1*/ = search/*0*/ 0 (x/*0:0101*/:xs/*0:011*/) with search _/*0:01*/ [] = -1; search n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = n/*0:01*/ if x/*0:101*/==y/*1:1*/; search n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = search/*1*/ (n/*0:01*/+1) xs/*0:11*/; search _/*0:01*/ xs/*0:1*/ = index xs/*0:1*/ y/*1:1*/ { + rule #0: search _ [] = -1 + rule #1: search n::int (x:xs) = n if x==y + rule #2: search n::int (x:xs) = search (n+1) xs + rule #3: search _ xs = index xs y + state 0: #0 #1 #2 #3 + <var> state 1 + <var>::int state 4 + state 1: #0 #3 + <var> state 2 + [] state 3 + state 2: #3 + state 3: #0 #3 + state 4: #0 #1 #2 #3 + <var> state 5 + [] state 6 + <app> state 7 + state 5: #3 + state 6: #0 #3 + state 7: #1 #2 #3 + <var> state 8 + <app> state 10 + state 8: #3 + <var> state 9 + state 9: #3 + state 10: #1 #2 #3 + <var> state 11 + : state 14 + state 11: #3 + <var> state 12 + state 12: #3 + <var> state 13 + state 13: #3 + state 14: #1 #2 #3 + <var> state 15 + state 15: #1 #2 #3 + <var> state 16 + state 16: #1 #2 #3 +} end; repeat n/*0:01*/::int x/*0:1*/ = accum/*0*/ [] n/*0:01*/ x/*0:1*/ with accum xs/*0:001*/ n/*0:01*/::int x/*0:1*/ = xs/*0:001*/ if n/*0:01*/<=0; accum xs/*0:001*/ n/*0:01*/::int x/*0:1*/ = accum/*1*/ (x/*0:1*/:xs/*0:001*/) (n/*0:01*/-1) x/*0:1*/ { rule #0: accum xs n::int x = xs if n<=0 rule #1: accum xs n::int x = accum (x:xs) (n-1) x @@ -1046,24 +1102,25 @@ } end; cycle n/*0:01*/::int [] = []; cycle n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = [] if n/*0:01*/<=0; -cycle n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [] (#xs/*0:*/) n/*1:01*/ xs/*0:*/ with accum ys/*0:0001*/ m/*0:001*/::int n/*0:01*/::int xs/*0:1*/ = cat ys/*0:0001*/+take n/*0:01*/ xs/*0:1*/ if n/*0:01*/<=m/*0:001*/; accum ys/*0:0001*/ m/*0:001*/::int n/*0:01*/::int xs/*0:1*/ = accum/*1*/ (xs/*0:1*/:ys/*0:0001*/) m/*0:001*/ (n/*0:01*/-m/*0:001*/) xs/*0:1*/ { - rule #0: accum ys m::int n::int xs = cat ys+take n xs if n<=m - rule #1: accum ys m::int n::int xs = accum (xs:ys) m (n-m) xs +cycle n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [] n/*2:01*/ with accum ys/*0:01*/ n/*0:1*/::int = cat ys/*0:01*/+take n/*0:1*/ xs/*2:*/ if n/*0:1*/<=m/*1:*/; accum ys/*0:01*/ n/*0:1*/::int = accum/*1*/ (xs/*2:*/:ys/*0:01*/) (n/*0:1*/-m/*1:*/) { + rule #0: accum ys n::int = cat ys+take n xs if n<=m + rule #1: accum ys n::int = accum (xs:ys) (n-m) state 0: #0 #1 <var> state 1 state 1: #0 #1 <var>::int state 2 state 2: #0 #1 - <var>::int state 3 - state 3: #0 #1 - <var> state 4 - state 4: #0 #1 -} end when xs/*0:*/ = x/*0:101*/:xs/*0:11*/ { +} end when xs/*0:*/ = x/*0:101*/:xs/*0:11*/; m/*0:*/::int = #xs/*0:*/ { + rule #0: m::int = #xs + state 0: #0 + <var>::int state 1 + state 1: #0 +} { rule #0: xs = x:xs state 0: #0 <var> state 1 state 1: #0 -} end; +} end if listp xs/*0:11*/; while p/*0:001*/ f/*0:01*/ a/*0:1*/ = accum/*0*/ [] p/*0:001*/ f/*0:01*/ a/*0:1*/ with accum as/*0:0001*/ p/*0:001*/ f/*0:01*/ a/*0:1*/ = accum/*1*/ (a/*0:1*/:as/*0:0001*/) p/*0:001*/ f/*0:01*/ (f/*0:01*/ a/*0:1*/) if p/*0:001*/ a/*0:1*/; accum as/*0:0001*/ p/*0:001*/ f/*0:01*/ a/*0:1*/ = reverse as/*0:0001*/ { rule #0: accum as p f a = accum (a:as) p f (f a) if p a rule #1: accum as p f a = reverse as This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 03:40:47
|
Revision: 147 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=147&view=rev Author: agraef Date: 2008-05-27 20:40:55 -0700 (Tue, 27 May 2008) Log Message: ----------- Overhaul of prelude. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/lib/prelude.pure pure/trunk/lib/strings.pure Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-27 19:17:52 UTC (rev 146) +++ pure/trunk/ChangeLog 2008-05-28 03:40:55 UTC (rev 147) @@ -1,3 +1,11 @@ +2008-05-28 Albert Graef <Dr....@t-...> + + * lib/strings.pure: Make 'cycle' work on strings. Reported by + Eddie Rucker. + + * lib/prelude.pure: Make 'index' work on lists. Code contributed + by Eddie Rucker. + 2008-05-27 Albert Graef <Dr....@t-...> * lib/prelude.pure: Rewrite prelude operations to make them Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-05-27 19:17:52 UTC (rev 146) +++ pure/trunk/lib/prelude.pure 2008-05-28 03:40:55 UTC (rev 147) @@ -339,6 +339,17 @@ catmap f xs = cat (map f xs); +/* Search an element in a list. Returns -1 if not found, index of first + occurrence otherwise. */ + +index [] _ = -1; +index (x:xs) y = search 0 (x:xs) with + search _ [] = -1; + search n::int (x:xs) = n if x==y; + = search (n+1) xs; + search _ xs = index xs y; +end; + /* Some useful list generators. */ repeat n::int x = accum [] n x with @@ -349,11 +360,10 @@ cycle n::int [] = []; cycle n::int (x:xs) = [] if n<=0; - = accum [] (#xs) n xs with - accum ys m::int n::int xs - = cat ys+take n xs if n<=m; - = accum (xs:ys) m (n-m) xs otherwise; - end when xs = x:xs end; + = accum [] n with + accum ys n::int = cat ys+take n xs if n<=m; + = accum (xs:ys) (n-m) otherwise; + end when xs = x:xs; m::int = #xs end if listp xs; while p f a = accum [] p f a with accum as p f a = accum (a:as) p f (f a) if p a; @@ -367,44 +377,43 @@ /* zip, unzip and friends. */ -zip xs ys = accum [] xs ys with +zip xs ys = accum [] xs ys with accum us (x:xs) (y:ys) = accum ((x,y):us) xs ys; accum us _ _ = reverse us; end; -zip3 xs ys zs = accum [] xs ys zs with +zip3 xs ys zs = accum [] xs ys zs with accum us (x:xs) (y:ys) (z:zs) = accum ((x,y,z):us) xs ys zs; accum us _ _ _ = reverse us; end; -zipwith f xs ys = accum [] xs ys with +zipwith f xs ys = accum [] xs ys with accum us (x:xs) (y:ys) = accum (f x y:us) xs ys; accum us _ _ = reverse us; end; -zipwith3 f xs ys zs = accum [] xs ys zs with +zipwith3 f xs ys zs = accum [] xs ys zs with accum us (x:xs) (y:ys) (z:zs) = accum (f x y z:us) xs ys zs; accum us _ _ _ = reverse us; end; -dowith f (x:xs) (y:ys) - = dowith f xs ys when _ = f x y end; -dowith f _ _ = () otherwise; +dowith f (x:xs) (y:ys) = dowith f xs ys when _ = f x y end; +dowith f _ _ = () otherwise; dowith3 f (x:xs) (y:ys) (z:zs) - = dowith3 f xs ys zs when _ = f x y z end; -dowith3 f _ _ _ = () otherwise; + = dowith3 f xs ys zs when _ = f x y z end; +dowith3 f _ _ _ = () otherwise; -unzip [] = [],[]; -unzip ((x,y):us) = x:xs,y:ys when xs,ys = accum [] [] us end +unzip [] = [],[]; +unzip ((x,y):us) = x:xs,y:ys when xs,ys = accum [] [] us end with accum xs ys [] = reverse xs,reverse ys; accum xs ys ((x,y):us) = accum (x:xs) (y:ys) us; accum _ _ us = throw (bad_list_value us); end; -unzip3 [] = [],[],[]; -unzip3 ((x,y,z):us) = x:xs,y:ys,z:zs when xs,ys,zs = accum [] [] [] us end +unzip3 [] = [],[],[]; +unzip3 ((x,y,z):us) = x:xs,y:ys,z:zs when xs,ys,zs = accum [] [] [] us end with accum xs ys zs [] = reverse xs,reverse ys,reverse zs; accum xs ys zs ((x,y,z):us) = accum (x:xs) (y:ys) (z:zs) us; Modified: pure/trunk/lib/strings.pure =================================================================== --- pure/trunk/lib/strings.pure 2008-05-27 19:17:52 UTC (rev 146) +++ pure/trunk/lib/strings.pure 2008-05-28 03:40:55 UTC (rev 147) @@ -143,6 +143,13 @@ reverse s::string = strcat (reverse (chars s)); cat (s::string:xs) = cat (chars s:xs); +cycle n::int "" = ""; +cycle n::int s::string = "" if n<=0; + = accum [] n with + accum ys n = strcat ys+take n s if n<=m; + = accum (s:ys) (n-m) otherwise; + end when m::int = #s end; + all p s::string = all p (chars s); any p s::string = any p (chars s); do f s::string = do f (chars s); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-27 19:18:03
|
Revision: 146 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=146&view=rev Author: agraef Date: 2008-05-27 12:17:52 -0700 (Tue, 27 May 2008) Log Message: ----------- Get rid of silly empty_list exceptions. Modified Paths: -------------- pure/trunk/lib/prelude.pure pure/trunk/test/prelude.log Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-05-27 18:13:58 UTC (rev 145) +++ pure/trunk/lib/prelude.pure 2008-05-27 19:17:52 UTC (rev 146) @@ -35,7 +35,6 @@ need to work from the end of a list towards its front. */ nullary out_of_bounds; // tuple or list index is out of bounds (!) -nullary empty_list; // empty list (head, tail, etc.) // bad_list_value xs; // not a proper list value (reverse, etc.) // xs denotes the offending tail of the list @@ -256,7 +255,6 @@ foldr1 f (x:xs) = foldr f x xs; head (x:xs) = x; -head [] = throw empty_list; init [x] = []; init (x:xs) = accum [x] xs with @@ -264,11 +262,9 @@ accum ys (x:xs) = accum (x:ys) xs; accum ys xs = reverse ys+init xs; end; -init [] = throw empty_list; last [x] = x; last (x:xs) = last xs; -last [] = throw empty_list; map f [] = []; map f (x:xs) = accum [f x] xs with @@ -307,7 +303,6 @@ end; tail (x:xs) = xs; -tail [] = throw empty_list; take n::int [] = []; take n::int (x:xs) Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-05-27 18:13:58 UTC (rev 145) +++ pure/trunk/test/prelude.log 2008-05-27 19:17:52 UTC (rev 146) @@ -708,7 +708,6 @@ foldr1 f/*0:01*/ [x/*0:101*/] = x/*0:101*/; foldr1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = foldr f/*0:01*/ x/*0:101*/ xs/*0:11*/; head (x/*0:101*/:xs/*0:11*/) = x/*0:101*/; -head [] = throw empty_list; init [x/*0:101*/] = []; init (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [x/*0:101*/] xs/*0:11*/ with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+init xs/*0:1*/ { rule #0: accum ys [] = reverse ys @@ -742,10 +741,8 @@ <var> state 13 state 13: #1 #2 } end; -init [] = throw empty_list; last [x/*0:101*/] = x/*0:101*/; last (x/*0:101*/:xs/*0:11*/) = last xs/*0:11*/; -last [] = throw empty_list; map f/*0:01*/ [] = []; map f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [f/*0:01*/ x/*0:101*/] xs/*0:11*/ with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (f/*1:01*/ x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+map f/*1:01*/ xs/*0:1*/ { rule #0: accum ys [] = reverse ys @@ -891,7 +888,6 @@ state 1: #0 } end; tail (x/*0:101*/:xs/*0:11*/) = xs/*0:11*/; -tail [] = throw empty_list; take n/*0:01*/::int [] = []; take n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = accum/*0*/ n/*0:01*/ [] (x/*0:101*/:xs/*0:11*/) with accum _/*0:001*/ ys/*0:01*/ [] = reverse ys/*0:01*/; accum n/*0:001*/::int ys/*0:01*/ _/*0:1*/ = reverse ys/*0:01*/ if n/*0:001*/<=0; accum n/*0:001*/::int ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (n/*0:001*/-1) (x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum n/*0:001*/ ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+take n/*0:001*/ xs/*0:1*/ { rule #0: accum _ ys [] = reverse ys This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-27 18:13:52
|
Revision: 145 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=145&view=rev Author: agraef Date: 2008-05-27 11:13:58 -0700 (Tue, 27 May 2008) Log Message: ----------- Overhaul of prelude. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/lib/prelude.pure pure/trunk/test/prelude.log Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-27 09:28:46 UTC (rev 144) +++ pure/trunk/ChangeLog 2008-05-27 18:13:58 UTC (rev 145) @@ -1,5 +1,8 @@ 2008-05-27 Albert Graef <Dr....@t-...> + * lib/prelude.pure: Rewrite prelude operations to make them + tail-recursive. + * interpreter.cc (toplevel_codegen): Experimental support for tail-recursive logical operators (&& and ||). This works but is disabled, since it makes these operations behave in different ways @@ -16,9 +19,6 @@ 2008-05-25 Albert Graef <Dr....@t-...> - * lib/prelude.pure: Rewrite prelude operations to make them - tail-recursive. - * interpreter.cc, runtime.cc: Add marshalling between long (64 bit) ints and Pure bigints in the C interface. This means that both Pure ints and bigints can now be passed for 'long' arguments Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-05-27 09:28:46 UTC (rev 144) +++ pure/trunk/lib/prelude.pure 2008-05-27 18:13:58 UTC (rev 145) @@ -28,16 +28,16 @@ nullary failed_match; // failed pattern match (lambda, case, etc.) nullary stack_fault; // not enough stack space (PURE_STACK limit) -/* Other exceptions defined by the prelude. Note that some of the list - operations require that their list arguments are "proper" lists (ending in - []) and will raise a 'bad_list_value xs' exception otherwise; in this case - xs denotes the offending tail. Likewise, some operations will raise the - 'empty_list' exception if a nonempty list is required. */ +/* Other exceptions defined by the prelude. We use exceptions sparingly, to + not interfere with symbolic evaluation, but in some cases it makes sense to + raise special kinds of exceptions in response to obvious error conditions. + In particular, the 'bad_list_value' exception is raised by functions which + need to work from the end of a list towards its front. */ nullary out_of_bounds; // tuple or list index is out of bounds (!) nullary empty_list; // empty list (head, tail, etc.) // bad_list_value xs; // not a proper list value (reverse, etc.) -// bad_value x; // invalid argument type + // xs denotes the offending tail of the list /* Other constants. */ @@ -114,10 +114,10 @@ accum n::int x = n+1; end; +(x,xs)!n::int = throw out_of_bounds if n<0; (x,xs)!0 = x; -(x,y,xs)!n::int = (y,xs)!(n-1) if n>0; +(x,y,xs)!n::int = (y,xs)!(n-1); (x,y)!1 = y; -(x,xs)!n::int = throw out_of_bounds; reverse () = (); reverse (x,xs) = accum x xs with @@ -150,12 +150,12 @@ #(x:xs) = accum 1 xs with accum n::int (x:xs) = accum (n+1) xs; accum n::int [] = n; - accum _ xs = throw (bad_list_value xs); + accum n::int xs = n+#xs; end; +(x,xs)!n::int = throw out_of_bounds if n<0; (x:xs)!0 = x; -(x:xs)!n::int = xs!(n-1) if n>0 && assert (listnp xs) (bad_list_value xs); -(x:xs)!n::int = throw out_of_bounds; +(x:xs)!n::int = xs!(n-1); []!n::int = throw out_of_bounds; []+ys = ys; @@ -183,7 +183,7 @@ tuple (x:xs) = accum x xs with accum ys (x:xs) = accum (x,ys) xs; accum ys [] = if tuplep ys then reverse ys else ys; - accum _ xs = throw (bad_list_value xs); + accum ys xs = ys,xs; end; /* Slicing. xs!ns returns the list of xs!n for all members n of the index list @@ -192,11 +192,13 @@ structures defined above. */ xs![] = []; -xs!(n:ns) = accum [] (reverse (n:ns)) with - accum ys [] = ys; +xs!(n:ns) = accum [] (n:ns) with + accum ys [] = reverse ys; accum ys (n::int:ns) = accum (xs!n:ys) ns if n>=0 && n<m; = accum ys ns otherwise; - accum _ (n:_) = throw (bad_value n); + accum ys (n:ns) = accum (xs!n:ys) ns if n>=0 && n<m; + = accum ys ns otherwise; + accum ys ns = reverse ys+xs!ns; end when m::int = #xs end; /* Arithmetic sequences. */ @@ -222,9 +224,10 @@ do f [] = (); do f (x:xs) = do f xs when _ = f x end; -drop n [] = []; -drop n (x:xs) = drop (n-1) xs if n>0; - = (x:xs) otherwise; +drop n::int [] = []; +drop n::int (x:xs) + = drop (n-1) xs if n>0; + = x:xs otherwise; dropwhile p [] = []; dropwhile p (x:xs) @@ -232,8 +235,12 @@ = x:xs otherwise; filter p [] = []; -filter p (x:xs) = x:filter p xs if p x; - = filter p xs otherwise; +filter p (x:xs) = accum [] (x:xs) with + accum ys [] = reverse ys; + accum ys (x:xs) = accum (x:ys) xs if p x; + = accum ys xs otherwise; + accum ys xs = reverse ys+filter p xs; + end; foldl f a [] = a; foldl f a (x:xs) @@ -246,30 +253,44 @@ = f x (foldl (flip f) a (reverse xs)); foldr1 f [x] = x; -foldr1 f (x:y:xs) - = f x (foldl1 (flip f) (reverse (y:xs))); +foldr1 f (x:xs) = foldr f x xs; head (x:xs) = x; +head [] = throw empty_list; init [x] = []; -init (x:xs) = x:init xs; +init (x:xs) = accum [x] xs with + accum ys [] = reverse ys; + accum ys (x:xs) = accum (x:ys) xs; + accum ys xs = reverse ys+init xs; + end; +init [] = throw empty_list; last [x] = x; last (x:xs) = last xs; +last [] = throw empty_list; map f [] = []; -map f (x:xs) = f x:map f xs; +map f (x:xs) = accum [f x] xs with + accum ys [] = reverse ys; + accum ys (x:xs) = accum (f x:ys) xs; + accum ys xs = reverse ys+map f xs; + end; scanl f a [] = [a]; scanl f a (x:xs) - = accum [a] f (f a x) xs with - accum ys f a [] = reverse (a:ys); - accum ys f a (x:xs) = accum (a:ys) f (f a x) xs; - accum _ _ _ xs = throw (bad_list_value xs); + = accum [a] (f a x) xs with + accum ys a [] = reverse (a:ys); + accum ys a (x:xs) = accum (a:ys) (f a x) xs; + accum _ _ xs = throw (bad_list_value xs); end; scanl1 f [] = []; -scanl1 f (x:xs) = scanl f x xs; +scanl1 f (x:xs) = accum [] x xs with + accum ys a [] = reverse (a:ys); + accum ys a (x:xs) = accum (a:ys) (f a x) xs; + accum _ _ xs = throw (bad_list_value xs); + end; scanr f a [] = [a]; scanr f a (x:xs) @@ -286,15 +307,26 @@ end; tail (x:xs) = xs; +tail [] = throw empty_list; -take n [] = []; -take n (x:xs) = x:take (n-1) xs if n>0; - = [] otherwise; +take n::int [] = []; +take n::int (x:xs) + = accum n [] (x:xs) with + accum _ ys [] = reverse ys; + accum n::int ys _ = reverse ys if n<=0; + accum n::int ys (x:xs) + = accum (n-1) (x:ys) xs; + accum n ys xs = reverse ys+take n xs; + end; takewhile p [] = []; takewhile p (x:xs) - = x:takewhile p xs if p x; - = [] otherwise; + = accum [] (x:xs) with + accum ys [] = reverse ys; + accum ys (x:xs) = accum (x:ys) xs if p x; + = reverse ys otherwise; + accum ys xs = reverse ys+takewhile p xs; + end; /* Concatenate a list of lists. */ @@ -340,22 +372,25 @@ /* zip, unzip and friends. */ -zip (x:xs) (y:ys) - = (x,y):zip xs ys; -zip _ _ = [] otherwise; +zip xs ys = accum [] xs ys with + accum us (x:xs) (y:ys) = accum ((x,y):us) xs ys; + accum us _ _ = reverse us; +end; -zip3 (x:xs) (y:ys) (z:zs) - = (x,y,z):zip3 xs ys zs; -zip3 _ _ _ = [] otherwise; +zip3 xs ys zs = accum [] xs ys zs with + accum us (x:xs) (y:ys) (z:zs) = accum ((x,y,z):us) xs ys zs; + accum us _ _ _ = reverse us; +end; -zipwith f (x:xs) (y:ys) - = f x y:zipwith f xs ys; -zipwith f _ _ = [] otherwise; +zipwith f xs ys = accum [] xs ys with + accum us (x:xs) (y:ys) = accum (f x y:us) xs ys; + accum us _ _ = reverse us; +end; -zipwith3 f (x:xs) (y:ys) (z:zs) - = f x y z:zipwith3 f xs ys zs; -zipwith3 f _ _ _ - = [] otherwise; +zipwith3 f xs ys zs = accum [] xs ys zs with + accum us (x:xs) (y:ys) (z:zs) = accum (f x y z:us) xs ys zs; + accum us _ _ _ = reverse us; +end; dowith f (x:xs) (y:ys) = dowith f xs ys when _ = f x y end; @@ -365,10 +400,18 @@ = dowith3 f xs ys zs when _ = f x y z end; dowith3 f _ _ _ = () otherwise; -unzip ((x,y):us) - = x:xs,y:ys when xs,ys = unzip us end; unzip [] = [],[]; +unzip ((x,y):us) = x:xs,y:ys when xs,ys = accum [] [] us end +with + accum xs ys [] = reverse xs,reverse ys; + accum xs ys ((x,y):us) = accum (x:xs) (y:ys) us; + accum _ _ us = throw (bad_list_value us); +end; -unzip3 ((x,y,z):us) - = x:xs,y:ys,z:zs when xs,ys,zs = unzip3 us end; unzip3 [] = [],[],[]; +unzip3 ((x,y,z):us) = x:xs,y:ys,z:zs when xs,ys,zs = accum [] [] [] us end +with + accum xs ys zs [] = reverse xs,reverse ys,reverse zs; + accum xs ys zs ((x,y,z):us) = accum (x:xs) (y:ys) (z:zs) us; + accum _ _ _ us = throw (bad_list_value us); +end; Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-05-27 09:28:46 UTC (rev 144) +++ pure/trunk/test/prelude.log 2008-05-27 18:13:58 UTC (rev 145) @@ -375,10 +375,10 @@ <var> state 12 state 12: #0 #1 } end; +(x/*0:0101*/,xs/*0:011*/)!n/*0:1*/::int = throw out_of_bounds if n/*0:1*/<0; (x/*0:0101*/,xs/*0:011*/)!0 = x/*0:0101*/; -(x/*0:0101*/,y/*0:01101*/,xs/*0:0111*/)!n/*0:1*/::int = (y/*0:01101*/,xs/*0:0111*/)!(n/*0:1*/-1) if n/*0:1*/>0; +(x/*0:0101*/,y/*0:01101*/,xs/*0:0111*/)!n/*0:1*/::int = (y/*0:01101*/,xs/*0:0111*/)!(n/*0:1*/-1); (x/*0:0101*/,y/*0:011*/)!1 = y/*0:011*/; -(x/*0:0101*/,xs/*0:011*/)!n/*0:1*/::int = throw out_of_bounds; reverse () = (); reverse (x/*0:101*/,xs/*0:11*/) = accum/*0*/ x/*0:101*/ xs/*0:11*/ with accum ys/*0:01*/ (x/*0:101*/,xs/*0:11*/) = accum/*1*/ (x/*0:101*/,ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ x/*0:1*/ = x/*0:1*/,ys/*0:01*/ { rule #0: accum ys (x,xs) = accum (x,ys) xs @@ -420,45 +420,41 @@ null [] = 1; null (x/*0:101*/:xs/*0:11*/) = 0; #[] = 0; -#(x/*0:101*/:xs/*0:11*/) = accum/*0*/ 1 xs/*0:11*/ with accum n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (n/*0:01*/+1) xs/*0:11*/; accum n/*0:01*/::int [] = n/*0:01*/; accum _/*0:01*/ xs/*0:1*/ = throw (bad_list_value xs/*0:1*/) { +#(x/*0:101*/:xs/*0:11*/) = accum/*0*/ 1 xs/*0:11*/ with accum n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (n/*0:01*/+1) xs/*0:11*/; accum n/*0:01*/::int [] = n/*0:01*/; accum n/*0:01*/::int xs/*0:1*/ = n/*0:01*/+#xs/*0:1*/ { rule #0: accum n::int (x:xs) = accum (n+1) xs rule #1: accum n::int [] = n - rule #2: accum _ xs = throw (bad_list_value xs) + rule #2: accum n::int xs = n+#xs state 0: #0 #1 #2 - <var> state 1 - <var>::int state 3 - state 1: #2 + <var>::int state 1 + state 1: #0 #1 #2 <var> state 2 + <app> state 3 + [] state 13 state 2: #2 - state 3: #0 #1 #2 + state 3: #0 #2 <var> state 4 - <app> state 5 - [] state 15 + <app> state 6 state 4: #2 - state 5: #0 #2 - <var> state 6 - <app> state 8 - state 6: #2 + <var> state 5 + state 5: #2 + state 6: #0 #2 <var> state 7 + : state 10 state 7: #2 - state 8: #0 #2 + <var> state 8 + state 8: #2 <var> state 9 - : state 12 state 9: #2 - <var> state 10 - state 10: #2 + state 10: #0 #2 <var> state 11 - state 11: #2 + state 11: #0 #2 + <var> state 12 state 12: #0 #2 - <var> state 13 - state 13: #0 #2 - <var> state 14 - state 14: #0 #2 - state 15: #1 #2 + state 13: #1 #2 } end; +(x/*0:0101*/,xs/*0:011*/)!n/*0:1*/::int = throw out_of_bounds if n/*0:1*/<0; (x/*0:0101*/:xs/*0:011*/)!0 = x/*0:0101*/; -(x/*0:0101*/:xs/*0:011*/)!n/*0:1*/::int = xs/*0:011*/!(n/*0:1*/-1) if n/*0:1*/>0&&assert (listnp xs/*0:011*/) (bad_list_value xs/*0:011*/); -(x/*0:0101*/:xs/*0:011*/)!n/*0:1*/::int = throw out_of_bounds; +(x/*0:0101*/:xs/*0:011*/)!n/*0:1*/::int = xs/*0:011*/!(n/*0:1*/-1); []!n/*0:1*/::int = throw out_of_bounds; []+ys/*0:1*/ = ys/*0:1*/; (x/*0:0101*/:xs/*0:011*/)+ys/*0:1*/ = x/*0:0101*/:accum/*0*/ ys/*0:1*/ (reverse xs/*0:011*/) with accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ [] = ys/*0:01*/ { @@ -544,10 +540,10 @@ state 12: #0 #1 } end; tuple [] = (); -tuple (x/*0:101*/:xs/*0:11*/) = accum/*0*/ x/*0:101*/ xs/*0:11*/ with accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/,ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ [] = if tuplep ys/*0:01*/ then reverse ys/*0:01*/ else ys/*0:01*/; accum _/*0:01*/ xs/*0:1*/ = throw (bad_list_value xs/*0:1*/) { +tuple (x/*0:101*/:xs/*0:11*/) = accum/*0*/ x/*0:101*/ xs/*0:11*/ with accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/,ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ [] = if tuplep ys/*0:01*/ then reverse ys/*0:01*/ else ys/*0:01*/; accum ys/*0:01*/ xs/*0:1*/ = ys/*0:01*/,xs/*0:1*/ { rule #0: accum ys (x:xs) = accum (x,ys) xs rule #1: accum ys [] = if tuplep ys then reverse ys else ys - rule #2: accum _ xs = throw (bad_list_value xs) + rule #2: accum ys xs = ys,xs state 0: #0 #1 #2 <var> state 1 state 1: #0 #1 #2 @@ -577,30 +573,44 @@ state 13: #1 #2 } end; xs/*0:01*/![] = []; -xs/*0:01*/!(n/*0:101*/:ns/*0:11*/) = accum/*0*/ [] (reverse (n/*1:101*/:ns/*1:11*/)) with accum ys/*0:01*/ [] = ys/*0:01*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ (xs/*2:01*/!n/*0:101*/:ys/*0:01*/) ns/*0:11*/ if n/*0:101*/>=0&&n/*0:101*/<m/*1:*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ ys/*0:01*/ ns/*0:11*/; accum _/*0:01*/ (n/*0:101*/:_/*0:11*/) = throw (bad_value n/*0:101*/) { - rule #0: accum ys [] = ys +xs/*0:01*/!(n/*0:101*/:ns/*0:11*/) = accum/*0*/ [] (n/*1:101*/:ns/*1:11*/) with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ (xs/*2:01*/!n/*0:101*/:ys/*0:01*/) ns/*0:11*/ if n/*0:101*/>=0&&n/*0:101*/<m/*1:*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ ys/*0:01*/ ns/*0:11*/; accum ys/*0:01*/ (n/*0:101*/:ns/*0:11*/) = accum/*1*/ (xs/*2:01*/!n/*0:101*/:ys/*0:01*/) ns/*0:11*/ if n/*0:101*/>=0&&n/*0:101*/<m/*1:*/; accum ys/*0:01*/ (n/*0:101*/:ns/*0:11*/) = accum/*1*/ ys/*0:01*/ ns/*0:11*/; accum ys/*0:01*/ ns/*0:1*/ = reverse ys/*0:01*/+xs/*2:01*/!ns/*0:1*/ { + rule #0: accum ys [] = reverse ys rule #1: accum ys (n::int:ns) = accum (xs!n:ys) ns if n>=0&&n<m rule #2: accum ys (n::int:ns) = accum ys ns - rule #3: accum _ (n:_) = throw (bad_value n) - state 0: #0 #1 #2 #3 + rule #3: accum ys (n:ns) = accum (xs!n:ys) ns if n>=0&&n<m + rule #4: accum ys (n:ns) = accum ys ns + rule #5: accum ys ns = reverse ys+xs!ns + state 0: #0 #1 #2 #3 #4 #5 <var> state 1 - state 1: #0 #1 #2 #3 - [] state 2 - <app> state 3 - state 2: #0 - state 3: #1 #2 #3 + state 1: #0 #1 #2 #3 #4 #5 + <var> state 2 + [] state 3 <app> state 4 - state 4: #1 #2 #3 - : state 5 - state 5: #1 #2 #3 + state 2: #5 + state 3: #0 #5 + state 4: #1 #2 #3 #4 #5 + <var> state 5 + <app> state 7 + state 5: #5 <var> state 6 - <var>::int state 8 - state 6: #3 - <var> state 7 - state 7: #3 - state 8: #1 #2 #3 + state 6: #5 + state 7: #1 #2 #3 #4 #5 + <var> state 8 + : state 11 + state 8: #5 <var> state 9 - state 9: #1 #2 #3 + state 9: #5 + <var> state 10 + state 10: #5 + state 11: #1 #2 #3 #4 #5 + <var> state 12 + <var>::int state 14 + state 12: #3 #4 #5 + <var> state 13 + state 13: #3 #4 #5 + state 14: #1 #2 #3 #4 #5 + <var> state 15 + state 15: #1 #2 #3 #4 #5 } end when m/*0:*/::int = #xs/*0:01*/ { rule #0: m::int = #xs state 0: #0 @@ -650,68 +660,195 @@ <var> state 1 state 1: #0 } end; -drop n/*0:01*/ [] = []; -drop n/*0:01*/ (x/*0:101*/:xs/*0:11*/) = drop (n/*0:01*/-1) xs/*0:11*/ if n/*0:01*/>0; -drop n/*0:01*/ (x/*0:101*/:xs/*0:11*/) = x/*0:101*/:xs/*0:11*/; +drop n/*0:01*/::int [] = []; +drop n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = drop (n/*0:01*/-1) xs/*0:11*/ if n/*0:01*/>0; +drop n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = x/*0:101*/:xs/*0:11*/; dropwhile p/*0:01*/ [] = []; dropwhile p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = dropwhile p/*0:01*/ xs/*0:11*/ if p/*0:01*/ x/*0:101*/; dropwhile p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = x/*0:101*/:xs/*0:11*/; filter p/*0:01*/ [] = []; -filter p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = x/*0:101*/:filter p/*0:01*/ xs/*0:11*/ if p/*0:01*/ x/*0:101*/; -filter p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = filter p/*0:01*/ xs/*0:11*/; +filter p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [] (x/*0:101*/:xs/*0:11*/) with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/:ys/*0:01*/) xs/*0:11*/ if p/*1:01*/ x/*0:101*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ ys/*0:01*/ xs/*0:11*/; accum ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+filter p/*1:01*/ xs/*0:1*/ { + rule #0: accum ys [] = reverse ys + rule #1: accum ys (x:xs) = accum (x:ys) xs if p x + rule #2: accum ys (x:xs) = accum ys xs + rule #3: accum ys xs = reverse ys+filter p xs + state 0: #0 #1 #2 #3 + <var> state 1 + state 1: #0 #1 #2 #3 + <var> state 2 + [] state 3 + <app> state 4 + state 2: #3 + state 3: #0 #3 + state 4: #1 #2 #3 + <var> state 5 + <app> state 7 + state 5: #3 + <var> state 6 + state 6: #3 + state 7: #1 #2 #3 + <var> state 8 + : state 11 + state 8: #3 + <var> state 9 + state 9: #3 + <var> state 10 + state 10: #3 + state 11: #1 #2 #3 + <var> state 12 + state 12: #1 #2 #3 + <var> state 13 + state 13: #1 #2 #3 +} end; foldl f/*0:001*/ a/*0:01*/ [] = a/*0:01*/; foldl f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = foldl f/*0:001*/ (f/*0:001*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/; foldl1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = foldl f/*0:01*/ x/*0:101*/ xs/*0:11*/; foldr f/*0:001*/ a/*0:01*/ [] = a/*0:01*/; foldr f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*0:001*/ x/*0:101*/ (foldl (flip f/*0:001*/) a/*0:01*/ (reverse xs/*0:11*/)); foldr1 f/*0:01*/ [x/*0:101*/] = x/*0:101*/; -foldr1 f/*0:01*/ (x/*0:101*/:y/*0:1101*/:xs/*0:111*/) = f/*0:01*/ x/*0:101*/ (foldl1 (flip f/*0:01*/) (reverse (y/*0:1101*/:xs/*0:111*/))); +foldr1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = foldr f/*0:01*/ x/*0:101*/ xs/*0:11*/; head (x/*0:101*/:xs/*0:11*/) = x/*0:101*/; +head [] = throw empty_list; init [x/*0:101*/] = []; -init (x/*0:101*/:xs/*0:11*/) = x/*0:101*/:init xs/*0:11*/; +init (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [x/*0:101*/] xs/*0:11*/ with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+init xs/*0:1*/ { + rule #0: accum ys [] = reverse ys + rule #1: accum ys (x:xs) = accum (x:ys) xs + rule #2: accum ys xs = reverse ys+init xs + state 0: #0 #1 #2 + <var> state 1 + state 1: #0 #1 #2 + <var> state 2 + [] state 3 + <app> state 4 + state 2: #2 + state 3: #0 #2 + state 4: #1 #2 + <var> state 5 + <app> state 7 + state 5: #2 + <var> state 6 + state 6: #2 + state 7: #1 #2 + <var> state 8 + : state 11 + state 8: #2 + <var> state 9 + state 9: #2 + <var> state 10 + state 10: #2 + state 11: #1 #2 + <var> state 12 + state 12: #1 #2 + <var> state 13 + state 13: #1 #2 +} end; +init [] = throw empty_list; last [x/*0:101*/] = x/*0:101*/; last (x/*0:101*/:xs/*0:11*/) = last xs/*0:11*/; +last [] = throw empty_list; map f/*0:01*/ [] = []; -map f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*0:01*/ x/*0:101*/:map f/*0:01*/ xs/*0:11*/; +map f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [f/*0:01*/ x/*0:101*/] xs/*0:11*/ with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (f/*1:01*/ x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+map f/*1:01*/ xs/*0:1*/ { + rule #0: accum ys [] = reverse ys + rule #1: accum ys (x:xs) = accum (f x:ys) xs + rule #2: accum ys xs = reverse ys+map f xs + state 0: #0 #1 #2 + <var> state 1 + state 1: #0 #1 #2 + <var> state 2 + [] state 3 + <app> state 4 + state 2: #2 + state 3: #0 #2 + state 4: #1 #2 + <var> state 5 + <app> state 7 + state 5: #2 + <var> state 6 + state 6: #2 + state 7: #1 #2 + <var> state 8 + : state 11 + state 8: #2 + <var> state 9 + state 9: #2 + <var> state 10 + state 10: #2 + state 11: #1 #2 + <var> state 12 + state 12: #1 #2 + <var> state 13 + state 13: #1 #2 +} end; scanl f/*0:001*/ a/*0:01*/ [] = [a/*0:01*/]; -scanl f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [a/*0:01*/] f/*0:001*/ (f/*0:001*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/ with accum ys/*0:0001*/ f/*0:001*/ a/*0:01*/ [] = reverse (a/*0:01*/:ys/*0:0001*/); accum ys/*0:0001*/ f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (a/*0:01*/:ys/*0:0001*/) f/*0:001*/ (f/*0:001*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/; accum _/*0:0001*/ _/*0:001*/ _/*0:01*/ xs/*0:1*/ = throw (bad_list_value xs/*0:1*/) { - rule #0: accum ys f a [] = reverse (a:ys) - rule #1: accum ys f a (x:xs) = accum (a:ys) f (f a x) xs - rule #2: accum _ _ _ xs = throw (bad_list_value xs) +scanl f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [a/*0:01*/] (f/*0:001*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/ with accum ys/*0:001*/ a/*0:01*/ [] = reverse (a/*0:01*/:ys/*0:001*/); accum ys/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (a/*0:01*/:ys/*0:001*/) (f/*1:001*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/; accum _/*0:001*/ _/*0:01*/ xs/*0:1*/ = throw (bad_list_value xs/*0:1*/) { + rule #0: accum ys a [] = reverse (a:ys) + rule #1: accum ys a (x:xs) = accum (a:ys) (f a x) xs + rule #2: accum _ _ xs = throw (bad_list_value xs) state 0: #0 #1 #2 <var> state 1 state 1: #0 #1 #2 <var> state 2 state 2: #0 #1 #2 <var> state 3 - state 3: #0 #1 #2 - <var> state 4 - [] state 5 - <app> state 6 - state 4: #2 - state 5: #0 #2 - state 6: #1 #2 + [] state 4 + <app> state 5 + state 3: #2 + state 4: #0 #2 + state 5: #1 #2 + <var> state 6 + <app> state 8 + state 6: #2 <var> state 7 - <app> state 9 state 7: #2 - <var> state 8 - state 8: #2 - state 9: #1 #2 + state 8: #1 #2 + <var> state 9 + : state 12 + state 9: #2 <var> state 10 - : state 13 state 10: #2 <var> state 11 state 11: #2 - <var> state 12 - state 12: #2 + state 12: #1 #2 + <var> state 13 state 13: #1 #2 <var> state 14 state 14: #1 #2 - <var> state 15 - state 15: #1 #2 } end; scanl1 f/*0:01*/ [] = []; -scanl1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = scanl f/*0:01*/ x/*0:101*/ xs/*0:11*/; +scanl1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [] x/*0:101*/ xs/*0:11*/ with accum ys/*0:001*/ a/*0:01*/ [] = reverse (a/*0:01*/:ys/*0:001*/); accum ys/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (a/*0:01*/:ys/*0:001*/) (f/*1:01*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/; accum _/*0:001*/ _/*0:01*/ xs/*0:1*/ = throw (bad_list_value xs/*0:1*/) { + rule #0: accum ys a [] = reverse (a:ys) + rule #1: accum ys a (x:xs) = accum (a:ys) (f a x) xs + rule #2: accum _ _ xs = throw (bad_list_value xs) + state 0: #0 #1 #2 + <var> state 1 + state 1: #0 #1 #2 + <var> state 2 + state 2: #0 #1 #2 + <var> state 3 + [] state 4 + <app> state 5 + state 3: #2 + state 4: #0 #2 + state 5: #1 #2 + <var> state 6 + <app> state 8 + state 6: #2 + <var> state 7 + state 7: #2 + state 8: #1 #2 + <var> state 9 + : state 12 + state 9: #2 + <var> state 10 + state 10: #2 + <var> state 11 + state 11: #2 + state 12: #1 #2 + <var> state 13 + state 13: #1 #2 + <var> state 14 + state 14: #1 #2 +} end; scanr f/*0:001*/ a/*0:01*/ [] = [a/*0:01*/]; scanr f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*2:001*/ x/*2:101*/ y/*0:01*/:ys/*1:*/ when ys/*0:*/ = reverse (scanl (flip f/*0:001*/) a/*0:01*/ (reverse xs/*0:11*/)); y/*0:01*/:_/*0:1*/ = ys/*0:*/ { rule #0: y:_ = ys @@ -754,12 +891,85 @@ state 1: #0 } end; tail (x/*0:101*/:xs/*0:11*/) = xs/*0:11*/; -take n/*0:01*/ [] = []; -take n/*0:01*/ (x/*0:101*/:xs/*0:11*/) = x/*0:101*/:take (n/*0:01*/-1) xs/*0:11*/ if n/*0:01*/>0; -take n/*0:01*/ (x/*0:101*/:xs/*0:11*/) = []; +tail [] = throw empty_list; +take n/*0:01*/::int [] = []; +take n/*0:01*/::int (x/*0:101*/:xs/*0:11*/) = accum/*0*/ n/*0:01*/ [] (x/*0:101*/:xs/*0:11*/) with accum _/*0:001*/ ys/*0:01*/ [] = reverse ys/*0:01*/; accum n/*0:001*/::int ys/*0:01*/ _/*0:1*/ = reverse ys/*0:01*/ if n/*0:001*/<=0; accum n/*0:001*/::int ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (n/*0:001*/-1) (x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum n/*0:001*/ ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+take n/*0:001*/ xs/*0:1*/ { + rule #0: accum _ ys [] = reverse ys + rule #1: accum n::int ys _ = reverse ys if n<=0 + rule #2: accum n::int ys (x:xs) = accum (n-1) (x:ys) xs + rule #3: accum n ys xs = reverse ys+take n xs + state 0: #0 #1 #2 #3 + <var> state 1 + <var>::int state 5 + state 1: #0 #3 + <var> state 2 + state 2: #0 #3 + <var> state 3 + [] state 4 + state 3: #3 + state 4: #0 #3 + state 5: #0 #1 #2 #3 + <var> state 6 + state 6: #0 #1 #2 #3 + <var> state 7 + [] state 8 + <app> state 9 + state 7: #1 #3 + state 8: #0 #1 #3 + state 9: #1 #2 #3 + <var> state 10 + <app> state 12 + state 10: #1 #3 + <var> state 11 + state 11: #1 #3 + state 12: #1 #2 #3 + <var> state 13 + : state 16 + state 13: #1 #3 + <var> state 14 + state 14: #1 #3 + <var> state 15 + state 15: #1 #3 + state 16: #1 #2 #3 + <var> state 17 + state 17: #1 #2 #3 + <var> state 18 + state 18: #1 #2 #3 +} end; takewhile p/*0:01*/ [] = []; -takewhile p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = x/*0:101*/:takewhile p/*0:01*/ xs/*0:11*/ if p/*0:01*/ x/*0:101*/; -takewhile p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = []; +takewhile p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [] (x/*0:101*/:xs/*0:11*/) with accum ys/*0:01*/ [] = reverse ys/*0:01*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/:ys/*0:01*/) xs/*0:11*/ if p/*1:01*/ x/*0:101*/; accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = reverse ys/*0:01*/; accum ys/*0:01*/ xs/*0:1*/ = reverse ys/*0:01*/+takewhile p/*1:01*/ xs/*0:1*/ { + rule #0: accum ys [] = reverse ys + rule #1: accum ys (x:xs) = accum (x:ys) xs if p x + rule #2: accum ys (x:xs) = reverse ys + rule #3: accum ys xs = reverse ys+takewhile p xs + state 0: #0 #1 #2 #3 + <var> state 1 + state 1: #0 #1 #2 #3 + <var> state 2 + [] state 3 + <app> state 4 + state 2: #3 + state 3: #0 #3 + state 4: #1 #2 #3 + <var> state 5 + <app> state 7 + state 5: #3 + <var> state 6 + state 6: #3 + state 7: #1 #2 #3 + <var> state 8 + : state 11 + state 8: #3 + <var> state 9 + state 9: #3 + <var> state 10 + state 10: #3 + state 11: #1 #2 #3 + <var> state 12 + state 12: #1 #2 #3 + <var> state 13 + state 13: #1 #2 #3 +} end; cat [] = []; cat [xs/*0:101*/] = xs/*0:101*/; cat (xs/*0:101*/:xss/*0:11*/) = accum/*0*/ (reverse xs/*0:101*/) xss/*0:11*/ with accum xs/*0:01*/ [] = reverse xs/*0:01*/; accum xs/*0:01*/ ([]:yss/*0:11*/) = accum/*1*/ xs/*0:01*/ yss/*0:11*/; accum xs/*0:01*/ ((y/*0:10101*/:ys/*0:1011*/):yss/*0:11*/) = accum/*1*/ (y/*0:10101*/:xs/*0:01*/) (ys/*0:1011*/:yss/*0:11*/); accum _/*0:01*/ (ys/*0:101*/:_/*0:11*/) = throw (bad_list_value ys/*0:101*/); accum _/*0:01*/ yss/*0:1*/ = throw (bad_list_value yss/*0:1*/) { @@ -884,14 +1094,302 @@ <var> state 4 state 4: #0 #1 } end; -zip (x/*0:0101*/:xs/*0:011*/) (y/*0:101*/:ys/*0:11*/) = (x/*0:0101*/,y/*0:101*/):zip xs/*0:011*/ ys/*0:11*/; -zip _/*0:01*/ _/*0:1*/ = []; -zip3 (x/*0:00101*/:xs/*0:0011*/) (y/*0:0101*/:ys/*0:011*/) (z/*0:101*/:zs/*0:11*/) = (x/*0:00101*/,y/*0:0101*/,z/*0:101*/):zip3 xs/*0:0011*/ ys/*0:011*/ zs/*0:11*/; -zip3 _/*0:001*/ _/*0:01*/ _/*0:1*/ = []; -zipwith f/*0:001*/ (x/*0:0101*/:xs/*0:011*/) (y/*0:101*/:ys/*0:11*/) = f/*0:001*/ x/*0:0101*/ y/*0:101*/:zipwith f/*0:001*/ xs/*0:011*/ ys/*0:11*/; -zipwith f/*0:001*/ _/*0:01*/ _/*0:1*/ = []; -zipwith3 f/*0:0001*/ (x/*0:00101*/:xs/*0:0011*/) (y/*0:0101*/:ys/*0:011*/) (z/*0:101*/:zs/*0:11*/) = f/*0:0001*/ x/*0:00101*/ y/*0:0101*/ z/*0:101*/:zipwith3 f/*0:0001*/ xs/*0:0011*/ ys/*0:011*/ zs/*0:11*/; -zipwith3 f/*0:0001*/ _/*0:001*/ _/*0:01*/ _/*0:1*/ = []; +zip xs/*0:01*/ ys/*0:1*/ = accum/*0*/ [] xs/*0:01*/ ys/*0:1*/ with accum us/*0:001*/ (x/*0:0101*/:xs/*0:011*/) (y/*0:101*/:ys/*0:11*/) = accum/*1*/ ((x/*0:0101*/,y/*0:101*/):us/*0:001*/) xs/*0:011*/ ys/*0:11*/; accum us/*0:001*/ _/*0:01*/ _/*0:1*/ = reverse us/*0:001*/ { + rule #0: accum us (x:xs) (y:ys) = accum ((x,y):us) xs ys + rule #1: accum us _ _ = reverse us + state 0: #0 #1 + <var> state 1 + state 1: #0 #1 + <var> state 2 + <app> state 4 + state 2: #1 + <var> state 3 + state 3: #1 + state 4: #0 #1 + <var> state 5 + <app> state 8 + state 5: #1 + <var> state 6 + state 6: #1 + <var> state 7 + state 7: #1 + state 8: #0 #1 + <var> state 9 + : state 13 + state 9: #1 + <var> state 10 + state 10: #1 + <var> state 11 + state 11: #1 + <var> state 12 + state 12: #1 + state 13: #0 #1 + <var> state 14 + state 14: #0 #1 + <var> state 15 + state 15: #0 #1 + <var> state 16 + <app> state 17 + state 16: #1 + state 17: #0 #1 + <var> state 18 + <app> state 20 + state 18: #1 + <var> state 19 + state 19: #1 + state 20: #0 #1 + <var> state 21 + : state 24 + state 21: #1 + <var> state 22 + state 22: #1 + <var> state 23 + state 23: #1 + state 24: #0 #1 + <var> state 25 + state 25: #0 #1 + <var> state 26 + state 26: #0 #1 +} end; +zip3 xs/*0:001*/ ys/*0:01*/ zs/*0:1*/ = accum/*0*/ [] xs/*0:001*/ ys/*0:01*/ zs/*0:1*/ with accum us/*0:0001*/ (x/*0:00101*/:xs/*0:0011*/) (y/*0:0101*/:ys/*0:011*/) (z/*0:101*/:zs/*0:11*/) = accum/*1*/ ((x/*0:00101*/,y/*0:0101*/,z/*0:101*/):us/*0:0001*/) xs/*0:0011*/ ys/*0:011*/ zs/*0:11*/; accum us/*0:0001*/ _/*0:001*/ _/*0:01*/ _/*0:1*/ = reverse us/*0:0001*/ { + rule #0: accum us (x:xs) (y:ys) (z:zs) = accum ((x,y,z):us) xs ys zs + rule #1: accum us _ _ _ = reverse us + state 0: #0 #1 + <var> state 1 + state 1: #0 #1 + <var> state 2 + <app> state 5 + state 2: #1 + <var> state 3 + state 3: #1 + <var> state 4 + state 4: #1 + state 5: #0 #1 + <var> state 6 + <app> state 10 + state 6: #1 + <var> state 7 + state 7: #1 + <var> state 8 + state 8: #1 + <var> state 9 + state 9: #1 + state 10: #0 #1 + <var> state 11 + : state 16 + state 11: #1 + <var> state 12 + state 12: #1 + <var> state 13 + state 13: #1 + <var> state 14 + state 14: #1 + <var> state 15 + state 15: #1 + state 16: #0 #1 + <var> state 17 + state 17: #0 #1 + <var> state 18 + state 18: #0 #1 + <var> state 19 + <app> state 21 + state 19: #1 + <var> state 20 + state 20: #1 + state 21: #0 #1 + <var> state 22 + <app> state 25 + state 22: #1 + <var> state 23 + state 23: #1 + <var> state 24 + state 24: #1 + state 25: #0 #1 + <var> state 26 + : state 30 + state 26: #1 + <var> state 27 + state 27: #1 + <var> state 28 + state 28: #1 + <var> state 29 + state 29: #1 + state 30: #0 #1 + <var> state 31 + state 31: #0 #1 + <var> state 32 + state 32: #0 #1 + <var> state 33 + <app> state 34 + state 33: #1 + state 34: #0 #1 + <var> state 35 + <app> state 37 + state 35: #1 + <var> state 36 + state 36: #1 + state 37: #0 #1 + <var> state 38 + : state 41 + state 38: #1 + <var> state 39 + state 39: #1 + <var> state 40 + state 40: #1 + state 41: #0 #1 + <var> state 42 + state 42: #0 #1 + <var> state 43 + state 43: #0 #1 +} end; +zipwith f/*0:001*/ xs/*0:01*/ ys/*0:1*/ = accum/*0*/ [] xs/*0:01*/ ys/*0:1*/ with accum us/*0:001*/ (x/*0:0101*/:xs/*0:011*/) (y/*0:101*/:ys/*0:11*/) = accum/*1*/ (f/*1:001*/ x/*0:0101*/ y/*0:101*/:us/*0:001*/) xs/*0:011*/ ys/*0:11*/; accum us/*0:001*/ _/*0:01*/ _/*0:1*/ = reverse us/*0:001*/ { + rule #0: accum us (x:xs) (y:ys) = accum (f x y:us) xs ys + rule #1: accum us _ _ = reverse us + state 0: #0 #1 + <var> state 1 + state 1: #0 #1 + <var> state 2 + <app> state 4 + state 2: #1 + <var> state 3 + state 3: #1 + state 4: #0 #1 + <var> state 5 + <app> state 8 + state 5: #1 + <var> state 6 + state 6: #1 + <var> state 7 + state 7: #1 + state 8: #0 #1 + <var> state 9 + : state 13 + state 9: #1 + <var> state 10 + state 10: #1 + <var> state 11 + state 11: #1 + <var> state 12 + state 12: #1 + state 13: #0 #1 + <var> state 14 + state 14: #0 #1 + <var> state 15 + state 15: #0 #1 + <var> state 16 + <app> state 17 + state 16: #1 + state 17: #0 #1 + <var> state 18 + <app> state 20 + state 18: #1 + <var> state 19 + state 19: #1 + state 20: #0 #1 + <var> state 21 + : state 24 + state 21: #1 + <var> state 22 + state 22: #1 + <var> state 23 + state 23: #1 + state 24: #0 #1 + <var> state 25 + state 25: #0 #1 + <var> state 26 + state 26: #0 #1 +} end; +zipwith3 f/*0:0001*/ xs/*0:001*/ ys/*0:01*/ zs/*0:1*/ = accum/*0*/ [] xs/*0:001*/ ys/*0:01*/ zs/*0:1*/ with accum us/*0:0001*/ (x/*0:00101*/:xs/*0:0011*/) (y/*0:0101*/:ys/*0:011*/) (z/*0:101*/:zs/*0:11*/) = accum/*1*/ (f/*1:0001*/ x/*0:00101*/ y/*0:0101*/ z/*0:101*/:us/*0:0001*/) xs/*0:0011*/ ys/*0:011*/ zs/*0:11*/; accum us/*0:0001*/ _/*0:001*/ _/*0:01*/ _/*0:1*/ = reverse us/*0:0001*/ { + rule #0: accum us (x:xs) (y:ys) (z:zs) = accum (f x y z:us) xs ys zs + rule #1: accum us _ _ _ = reverse us + state 0: #0 #1 + <var> state 1 + state 1: #0 #1 + <var> state 2 + <app> state 5 + state 2: #1 + <var> state 3 + state 3: #1 + <var> state 4 + state 4: #1 + state 5: #0 #1 + <var> state 6 + <app> state 10 + state 6: #1 + <var> state 7 + state 7: #1 + <var> state 8 + state 8: #1 + <var> state 9 + state 9: #1 + state 10: #0 #1 + <var> state 11 + : state 16 + state 11: #1 + <var> state 12 + state 12: #1 + <var> state 13 + state 13: #1 + <var> state 14 + state 14: #1 + <var> state 15 + state 15: #1 + state 16: #0 #1 + <var> state 17 + state 17: #0 #1 + <var> state 18 + state 18: #0 #1 + <var> state 19 + <app> state 21 + state 19: #1 + <var> state 20 + state 20: #1 + state 21: #0 #1 + <var> state 22 + <app> state 25 + state 22: #1 + <var> state 23 + state 23: #1 + <var> state 24 + state 24: #1 + state 25: #0 #1 + <var> state 26 + : state 30 + state 26: #1 + <var> state 27 + state 27: #1 + <var> state 28 + state 28: #1 + <var> state 29 + state 29: #1 + state 30: #0 #1 + <var> state 31 + state 31: #0 #1 + <var> state 32 + state 32: #0 #1 + <var> state 33 + <app> state 34 + state 33: #1 + state 34: #0 #1 + <var> state 35 + <app> state 37 + state 35: #1 + <var> state 36 + state 36: #1 + state 37: #0 #1 + <var> state 38 + : state 41 + state 38: #1 + <var> state 39 + state 39: #1 + <var> state 40 + state 40: #1 + state 41: #0 #1 + <var> state 42 + state 42: #0 #1 + <var> state 43 + state 43: #0 #1 +} end; dowith f/*0:001*/ (x/*0:0101*/:xs/*0:011*/) (y/*0:101*/:ys/*0:11*/) = dowith f/*1:001*/ xs/*1:011*/ ys/*1:11*/ when _/*0:*/ = f/*0:001*/ x/*0:0101*/ y/*0:101*/ { rule #0: _ = f x y state 0: #0 @@ -906,8 +1404,9 @@ state 1: #0 } end; dowith3 f/*0:0001*/ _/*0:001*/ _/*0:01*/ _/*0:1*/ = (); -unzip ((x/*0:10101*/,y/*0:1011*/):us/*0:11*/) = x/*1:10101*/:xs/*0:01*/,y/*1:1011*/:ys/*0:1*/ when xs/*0:01*/,ys/*0:1*/ = unzip us/*0:11*/ { - rule #0: xs,ys = unzip us +unzip [] = [],[]; +unzip ((x/*0:10101*/,y/*0:1011*/):us/*0:11*/) = x/*1:10101*/:xs/*0:01*/,y/*1:1011*/:ys/*0:1*/ when xs/*0:01*/,ys/*0:1*/ = accum/*0*/ [] [] us/*0:11*/ { + rule #0: xs,ys = accum [] [] us state 0: #0 <app> state 1 state 1: #0 @@ -919,10 +1418,69 @@ state 4: #0 <var> state 5 state 5: #0 +} end with accum xs/*0:001*/ ys/*0:01*/ [] = reverse xs/*0:001*/,reverse ys/*0:01*/; accum xs/*0:001*/ ys/*0:01*/ ((x/*0:10101*/,y/*0:1011*/):us/*0:11*/) = accum/*1*/ (x/*0:10101*/:xs/*0:001*/) (y/*0:1011*/:ys/*0:01*/) us/*0:11*/; accum _/*0:001*/ _/*0:01*/ us/*0:1*/ = throw (bad_list_value us/*0:1*/) { + rule #0: accum xs ys [] = reverse xs,reverse ys + rule #1: accum xs ys ((x,y):us) = accum (x:xs) (y:ys) us + rule #2: accum _ _ us = throw (bad_list_value us) + state 0: #0 #1 #2 + <var> state 1 + state 1: #0 #1 #2 + <var> state 2 + state 2: #0 #1 #2 + <var> state 3 + [] state 4 + <app> state 5 + state 3: #2 + state 4: #0 #2 + state 5: #1 #2 + <var> state 6 + <app> state 8 + state 6: #2 + <var> state 7 + state 7: #2 + state 8: #1 #2 + <var> state 9 + : state 12 + state 9: #2 + <var> state 10 + state 10: #2 + <var> state 11 + state 11: #2 + state 12: #1 #2 + <var> state 13 + <app> state 15 + state 13: #2 + <var> state 14 + state 14: #2 + state 15: #1 #2 + <var> state 16 + <app> state 19 + state 16: #2 + <var> state 17 + state 17: #2 + <var> state 18 + state 18: #2 + state 19: #1 #2 + <var> state 20 + , state 24 + state 20: #2 + <var> state 21 + state 21: #2 + <var> state 22 + state 22: #2 + <var> state 23 + state 23: #2 + state 24: #1 #2 + <var> state 25 + state 25: #1 #2 + <var> state 26 + state 26: #1 #2 + <var> state 27 + state 27: #1 #2 } end; -unzip [] = [],[]; -unzip3 ((x/*0:10101*/,y/*0:101101*/,z/*0:10111*/):us/*0:11*/) = x/*1:10101*/:xs/*0:01*/,y/*1:101101*/:ys/*0:101*/,z/*1:10111*/:zs/*0:11*/ when xs/*0:01*/,ys/*0:101*/,zs/*0:11*/ = unzip3 us/*0:11*/ { - rule #0: xs,ys,zs = unzip3 us +unzip3 [] = [],[],[]; +unzip3 ((x/*0:10101*/,y/*0:101101*/,z/*0:10111*/):us/*0:11*/) = x/*1:10101*/:xs/*0:01*/,y/*1:101101*/:ys/*0:101*/,z/*1:10111*/:zs/*0:11*/ when xs/*0:01*/,ys/*0:101*/,zs/*0:11*/ = accum/*0*/ [] [] [] us/*0:11*/ { + rule #0: xs,ys,zs = accum [] [] [] us state 0: #0 <app> state 1 state 1: #0 @@ -942,5 +1500,91 @@ state 8: #0 <var> state 9 state 9: #0 +} end with accum xs/*0:0001*/ ys/*0:001*/ zs/*0:01*/ [] = reverse xs/*0:0001*/,reverse ys/*0:001*/,reverse zs/*0:01*/; accum xs/*0:0001*/ ys/*0:001*/ zs/*0:01*/ ((x/*0:10101*/,y/*0:101101*/,z/*0:10111*/):us/*0:11*/) = accum/*1*/ (x/*0:10101*/:xs/*0:0001*/) (y/*0:101101*/:ys/*0:001*/) (z/*0:10111*/:zs/*0:01*/) us/*0:11*/; accum _/*0:0001*/ _/*0:001*/ _/*0:01*/ us/*0:1*/ = throw (bad_list_value us/*0:1*/) { + rule #0: accum xs ys zs [] = reverse xs,reverse ys,reverse zs + rule #1: accum xs ys zs ((x,y,z):us) = accum (x:xs) (y:ys) (z:zs) us + rule #2: accum _ _ _ us = throw (bad_list_value us) + state 0: #0 #1 #2 + <var> state 1 + state 1: #0 #1 #2 + <var> state 2 + state 2: #0 #1 #2 + <var> state 3 + state 3: #0 #1 #2 + <var> state 4 + [] state 5 + <app> state 6 + state 4: #2 + state 5: #0 #2 + state 6: #1 #2 + <var> state 7 + <app> state 9 + state 7: #2 + <var> state 8 + state 8: #2 + state 9: #1 #2 + <var> state 10 + : state 13 + state 10: #2 + <var> state 11 + state 11: #2 + <var> state 12 + state 12: #2 + state 13: #1 #2 + <var> state 14 + <app> state 16 + state 14: #2 + <var> state 15 + state 15: #2 + state 16: #1 #2 + <var> state 17 + <app> state 20 + state 17: #2 + <var> state 18 + state 18: #2 + <var> state 19 + state 19: #2 + state 20: #1 #2 + <var> state 21 + , state 25 + state 21: #2 + <var> state 22 + state 22: #2 + <var> state 23 + state 23: #2 + <var> state 24 + state 24: #2 + state 25: #1 #2 + <var> state 26 + state 26: #1 #2 + <var> state 27 + <app> state 29 + state 27: #2 + <var> state 28 + state 28: #2 + state 29: #1 #2 + <var> state 30 + <app> state 33 + state 30: #2 + <var> state 31 + state 31: #2 + <var> state 32 + state 32: #2 + state 33: #1 #2 + <var> state 34 + , state 38 + state 34: #2 + <var> state 35 + state 35: #2 + <var> state 36 + state 36: #2 + <var> state 37 + state 37: #2 + state 38: #1 #2 + <var> state 39 + state 39: #1 #2 + <var> state 40 + state 40: #1 #2 + <var> state 41 + state 41: #1 #2 } end; -unzip3 [] = [],[],[]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-27 09:28:37
|
Revision: 144 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=144&view=rev Author: agraef Date: 2008-05-27 02:28:46 -0700 (Tue, 27 May 2008) Log Message: ----------- Disable TCO of logical operators, it's broken by design. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/interpreter.cc pure/trunk/interpreter.hh pure/trunk/lib/prelude.pure pure/trunk/test/prelude.log Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-27 09:18:50 UTC (rev 143) +++ pure/trunk/ChangeLog 2008-05-27 09:28:46 UTC (rev 144) @@ -1,10 +1,10 @@ 2008-05-27 Albert Graef <Dr....@t-...> * interpreter.cc (toplevel_codegen): Experimental support for - tail-recursive short-circuit logical operators (&& and ||). Note - that this makes these operations behave slightly differently (more - like if-then-else) if they form the right-hand side of an - equation. But the advantages seem to outweigh the semantic quirks. + tail-recursive logical operators (&& and ||). This works but is + disabled, since it makes these operations behave in different ways + depending on the context, which is a really bad idea because it + violates referential transparency. 2008-05-26 Albert Graef <Dr....@t-...> Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-27 09:18:50 UTC (rev 143) +++ pure/trunk/interpreter.cc 2008-05-27 09:28:46 UTC (rev 144) @@ -3224,6 +3224,11 @@ return 0; } +/* Experimental support for tail-recursive logical operators (&& and ||). This + works, but is inherently broken (e.g., 0||-1 might return either -1 or 1, + depending on whether the code is TCO'ed or not). Never use this. */ +#define TAILOPS 0 + void interpreter::toplevel_codegen(expr x) { #if USE_FASTCC Modified: pure/trunk/interpreter.hh =================================================================== --- pure/trunk/interpreter.hh 2008-05-27 09:18:50 UTC (rev 143) +++ pure/trunk/interpreter.hh 2008-05-27 09:28:46 UTC (rev 144) @@ -28,11 +28,6 @@ /* Experimental support for the "fast" calling convention which is needed to get tail call elimination. */ #define USE_FASTCC 1 -/* Experimental support for tail-recursive short-circuit logical operators (&& - and ||). This will only have an effect if USE_FASTCC is enabled. Note that - if you disable this option, && and || will still be short-curcuit, they - just won't be tail-recursive in their second operand any more. */ -#define TAILOPS 1 using namespace std; Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-05-27 09:18:50 UTC (rev 143) +++ pure/trunk/lib/prelude.pure 2008-05-27 09:28:46 UTC (rev 144) @@ -98,12 +98,12 @@ ()==() = 1; (x,xs)==() = 0; ()==(x,xs) = 0; -(x,xs)==(y,ys) = x==y && xs==ys; +(x,xs)==(y,ys) = if x==y then xs==ys else 0; ()!=() = 0; (x,xs)!=() = 1; ()!=(x,xs) = 1; -(x,xs)!=(y,ys) = x!=y || xs!=ys; +(x,xs)!=(y,ys) = if x!=y then 1 else xs!=ys; null () = 1; null (x,xs) = 0; @@ -136,12 +136,12 @@ []==[] = 1; (x:xs)==[] = 0; []==(x:xs) = 0; -(x:xs)==(y:ys) = x==y && xs==ys; +(x:xs)==(y:ys) = if x==y then xs==ys else 1; []!=[] = 0; (x:xs)!=[] = 1; []!=(x:xs) = 1; -(x:xs)!=(y:ys) = x!=y || xs!=ys; +(x:xs)!=(y:ys) = if x!=y then 1 else xs!=ys; null [] = 1; null (x:xs) = 0; @@ -214,10 +214,10 @@ to make them tail-recursive. */ all p [] = 1; -all p (x:xs) = p x && all p xs; +all p (x:xs) = if p x then all p xs else 0; any p [] = 0; -any p (x:xs) = p x || any p xs; +any p (x:xs) = if p x then 1 else any p xs; do f [] = (); do f (x:xs) = do f xs when _ = f x end; Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-05-27 09:18:50 UTC (rev 143) +++ pure/trunk/test/prelude.log 2008-05-27 09:28:46 UTC (rev 144) @@ -338,11 +338,11 @@ ()==() = 1; (x/*0:0101*/,xs/*0:011*/)==() = 0; ()==(x/*0:101*/,xs/*0:11*/) = 0; -(x/*0:0101*/,xs/*0:011*/)==(y/*0:101*/,ys/*0:11*/) = x/*0:0101*/==y/*0:101*/&&xs/*0:011*/==ys/*0:11*/; +(x/*0:0101*/,xs/*0:011*/)==(y/*0:101*/,ys/*0:11*/) = if x/*0:0101*/==y/*0:101*/ then xs/*0:011*/==ys/*0:11*/ else 0; ()!=() = 0; (x/*0:0101*/,xs/*0:011*/)!=() = 1; ()!=(x/*0:101*/,xs/*0:11*/) = 1; -(x/*0:0101*/,xs/*0:011*/)!=(y/*0:101*/,ys/*0:11*/) = x/*0:0101*/!=y/*0:101*/||xs/*0:011*/!=ys/*0:11*/; +(x/*0:0101*/,xs/*0:011*/)!=(y/*0:101*/,ys/*0:11*/) = if x/*0:0101*/!=y/*0:101*/ then 1 else xs/*0:011*/!=ys/*0:11*/; null () = 1; null (x/*0:101*/,xs/*0:11*/) = 0; #() = 0; @@ -412,11 +412,11 @@ []==[] = 1; x/*0:0101*/:xs/*0:011*/==[] = 0; []==x/*0:101*/:xs/*0:11*/ = 0; -x/*0:0101*/:xs/*0:011*/==y/*0:101*/:ys/*0:11*/ = x/*0:0101*/==y/*0:101*/&&xs/*0:011*/==ys/*0:11*/; +x/*0:0101*/:xs/*0:011*/==y/*0:101*/:ys/*0:11*/ = if x/*0:0101*/==y/*0:101*/ then xs/*0:011*/==ys/*0:11*/ else 1; []!=[] = 0; x/*0:0101*/:xs/*0:011*/!=[] = 1; []!=x/*0:101*/:xs/*0:11*/ = 1; -x/*0:0101*/:xs/*0:011*/!=y/*0:101*/:ys/*0:11*/ = x/*0:0101*/!=y/*0:101*/||xs/*0:011*/!=ys/*0:11*/; +x/*0:0101*/:xs/*0:011*/!=y/*0:101*/:ys/*0:11*/ = if x/*0:0101*/!=y/*0:101*/ then 1 else xs/*0:011*/!=ys/*0:11*/; null [] = 1; null (x/*0:101*/:xs/*0:11*/) = 0; #[] = 0; @@ -640,9 +640,9 @@ state 1: #0 }) n/*0:01*/; all p/*0:01*/ [] = 1; -all p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = p/*0:01*/ x/*0:101*/&&all p/*0:01*/ xs/*0:11*/; +all p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = if p/*0:01*/ x/*0:101*/ then all p/*0:01*/ xs/*0:11*/ else 0; any p/*0:01*/ [] = 0; -any p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = p/*0:01*/ x/*0:101*/||any p/*0:01*/ xs/*0:11*/; +any p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = if p/*0:01*/ x/*0:101*/ then 1 else any p/*0:01*/ xs/*0:11*/; do f/*0:01*/ [] = (); do f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = do f/*1:01*/ xs/*1:11*/ when _/*0:*/ = f/*0:01*/ x/*0:101*/ { rule #0: _ = f x This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-27 09:18:42
|
Revision: 143 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=143&view=rev Author: agraef Date: 2008-05-27 02:18:50 -0700 (Tue, 27 May 2008) Log Message: ----------- Overhaul of prelude. Modified Paths: -------------- pure/trunk/test/prelude.log Modified: pure/trunk/test/prelude.log =================================================================== --- pure/trunk/test/prelude.log 2008-05-27 09:17:56 UTC (rev 142) +++ pure/trunk/test/prelude.log 2008-05-27 09:18:50 UTC (rev 143) @@ -1,4 +1,5 @@ throw x/*0:1*/ = pure_throw x/*0:1*/; +assert p/*0:01*/ e/*0:1*/ = if p/*0:01*/ then 1 else throw e/*0:1*/; x/*0:01*/===y/*0:1*/ = same x/*0:01*/ y/*0:1*/; x/*0:01*/!==y/*0:1*/ = not same x/*0:01*/ y/*0:1*/; intp x/*0:1*/ = case x/*0:1*/ of _/*0:*/::int = 1; _/*0:*/ = 0 { @@ -49,6 +50,9 @@ listp [] = 1; listp (x/*0:101*/:xs/*0:11*/) = listp xs/*0:11*/; listp _/*0:1*/ = 0; +listnp [] = 1; +listnp (x/*0:101*/:xs/*0:11*/) = 1; +listnp _/*0:1*/ = 0; tuplep () = 1; tuplep (x/*0:101*/,xs/*0:11*/) = 1; tuplep _/*0:1*/ = 0; @@ -374,6 +378,7 @@ (x/*0:0101*/,xs/*0:011*/)!0 = x/*0:0101*/; (x/*0:0101*/,y/*0:01101*/,xs/*0:0111*/)!n/*0:1*/::int = (y/*0:01101*/,xs/*0:0111*/)!(n/*0:1*/-1) if n/*0:1*/>0; (x/*0:0101*/,y/*0:011*/)!1 = y/*0:011*/; +(x/*0:0101*/,xs/*0:011*/)!n/*0:1*/::int = throw out_of_bounds; reverse () = (); reverse (x/*0:101*/,xs/*0:11*/) = accum/*0*/ x/*0:101*/ xs/*0:11*/ with accum ys/*0:01*/ (x/*0:101*/,xs/*0:11*/) = accum/*1*/ (x/*0:101*/,ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ x/*0:1*/ = x/*0:1*/,ys/*0:01*/ { rule #0: accum ys (x,xs) = accum (x,ys) xs @@ -452,7 +457,9 @@ state 15: #1 #2 } end; (x/*0:0101*/:xs/*0:011*/)!0 = x/*0:0101*/; -(x/*0:0101*/:xs/*0:011*/)!n/*0:1*/::int = xs/*0:011*/!(n/*0:1*/-1) if n/*0:1*/>0; +(x/*0:0101*/:xs/*0:011*/)!n/*0:1*/::int = xs/*0:011*/!(n/*0:1*/-1) if n/*0:1*/>0&&assert (listnp xs/*0:011*/) (bad_list_value xs/*0:011*/); +(x/*0:0101*/:xs/*0:011*/)!n/*0:1*/::int = throw out_of_bounds; +[]!n/*0:1*/::int = throw out_of_bounds; []+ys/*0:1*/ = ys/*0:1*/; (x/*0:0101*/:xs/*0:011*/)+ys/*0:1*/ = x/*0:0101*/:accum/*0*/ ys/*0:1*/ (reverse xs/*0:011*/) with accum ys/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (x/*0:101*/:ys/*0:01*/) xs/*0:11*/; accum ys/*0:01*/ [] = ys/*0:01*/ { rule #0: accum ys (x:xs) = accum (x:ys) xs @@ -570,31 +577,35 @@ state 13: #1 #2 } end; xs/*0:01*/![] = []; -xs/*0:01*/!(n/*0:101*/:ns/*0:11*/) = accum/*0*/ [] xs/*0:01*/ (reverse (n/*0:101*/:ns/*0:11*/)) (#xs/*0:01*/) with accum ys/*0:0001*/ xs/*0:001*/ [] m/*0:1*/ = ys/*0:0001*/; accum ys/*0:0001*/ xs/*0:001*/ (n/*0:0101*/::int:ns/*0:011*/) m/*0:1*/ = accum/*1*/ (xs/*0:001*/!n/*0:0101*/:ys/*0:0001*/) xs/*0:001*/ ns/*0:011*/ m/*0:1*/ if n/*0:0101*/>=0&&n/*0:0101*/<m/*0:1*/; accum ys/*0:0001*/ xs/*0:001*/ (n/*0:0101*/::int:ns/*0:011*/) m/*0:1*/ = accum/*1*/ ys/*0:0001*/ xs/*0:001*/ ns/*0:011*/ m/*0:1*/ { - rule #0: accum ys xs [] m = ys - rule #1: accum ys xs (n::int:ns) m = accum (xs!n:ys) xs ns m if n>=0&&n<m - rule #2: accum ys xs (n::int:ns) m = accum ys xs ns m - state 0: #0 #1 #2 +xs/*0:01*/!(n/*0:101*/:ns/*0:11*/) = accum/*0*/ [] (reverse (n/*1:101*/:ns/*1:11*/)) with accum ys/*0:01*/ [] = ys/*0:01*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ (xs/*2:01*/!n/*0:101*/:ys/*0:01*/) ns/*0:11*/ if n/*0:101*/>=0&&n/*0:101*/<m/*1:*/; accum ys/*0:01*/ (n/*0:101*/::int:ns/*0:11*/) = accum/*1*/ ys/*0:01*/ ns/*0:11*/; accum _/*0:01*/ (n/*0:101*/:_/*0:11*/) = throw (bad_value n/*0:101*/) { + rule #0: accum ys [] = ys + rule #1: accum ys (n::int:ns) = accum (xs!n:ys) ns if n>=0&&n<m + rule #2: accum ys (n::int:ns) = accum ys ns + rule #3: accum _ (n:_) = throw (bad_value n) + state 0: #0 #1 #2 #3 <var> state 1 - state 1: #0 #1 #2 - <var> state 2 - state 2: #0 #1 #2 - [] state 3 - <app> state 5 - state 3: #0 - <var> state 4 - state 4: #0 - state 5: #1 #2 - <app> state 6 - state 6: #1 #2 - : state 7 - state 7: #1 #2 + state 1: #0 #1 #2 #3 + [] state 2 + <app> state 3 + state 2: #0 + state 3: #1 #2 #3 + <app> state 4 + state 4: #1 #2 #3 + : state 5 + state 5: #1 #2 #3 + <var> state 6 <var>::int state 8 - state 8: #1 #2 + state 6: #3 + <var> state 7 + state 7: #3 + state 8: #1 #2 #3 <var> state 9 - state 9: #1 #2 - <var> state 10 - state 10: #1 #2 + state 9: #1 #2 #3 +} end when m/*0:*/::int = #xs/*0:01*/ { + rule #0: m::int = #xs + state 0: #0 + <var>::int state 1 + state 1: #0 } end; n1/*0:0101*/,n2/*0:011*/..m/*0:1*/ = while (\i/*0:*/ -> s/*1:*/*i/*0:*/<=s/*1:*/*m/*3:1*/ { rule #0: i = s*i<=s*m @@ -652,9 +663,9 @@ foldl f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = foldl f/*0:001*/ (f/*0:001*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/; foldl1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = foldl f/*0:01*/ x/*0:101*/ xs/*0:11*/; foldr f/*0:001*/ a/*0:01*/ [] = a/*0:01*/; -foldr f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*0:001*/ x/*0:101*/ (foldr f/*0:001*/ a/*0:01*/ xs/*0:11*/); +foldr f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*0:001*/ x/*0:101*/ (foldl (flip f/*0:001*/) a/*0:01*/ (reverse xs/*0:11*/)); foldr1 f/*0:01*/ [x/*0:101*/] = x/*0:101*/; -foldr1 f/*0:01*/ (x/*0:101*/:y/*0:1101*/:xs/*0:111*/) = f/*0:01*/ x/*0:101*/ (foldr1 f/*0:01*/ (y/*0:1101*/:xs/*0:111*/)); +foldr1 f/*0:01*/ (x/*0:101*/:y/*0:1101*/:xs/*0:111*/) = f/*0:01*/ x/*0:101*/ (foldl1 (flip f/*0:01*/) (reverse (y/*0:1101*/:xs/*0:111*/))); head (x/*0:101*/:xs/*0:11*/) = x/*0:101*/; init [x/*0:101*/] = []; init (x/*0:101*/:xs/*0:11*/) = x/*0:101*/:init xs/*0:11*/; @@ -663,11 +674,46 @@ map f/*0:01*/ [] = []; map f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*0:01*/ x/*0:101*/:map f/*0:01*/ xs/*0:11*/; scanl f/*0:001*/ a/*0:01*/ [] = [a/*0:01*/]; -scanl f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = a/*0:01*/:scanl f/*0:001*/ (f/*0:001*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/; +scanl f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*0*/ [a/*0:01*/] f/*0:001*/ (f/*0:001*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/ with accum ys/*0:0001*/ f/*0:001*/ a/*0:01*/ [] = reverse (a/*0:01*/:ys/*0:0001*/); accum ys/*0:0001*/ f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = accum/*1*/ (a/*0:01*/:ys/*0:0001*/) f/*0:001*/ (f/*0:001*/ a/*0:01*/ x/*0:101*/) xs/*0:11*/; accum _/*0:0001*/ _/*0:001*/ _/*0:01*/ xs/*0:1*/ = throw (bad_list_value xs/*0:1*/) { + rule #0: accum ys f a [] = reverse (a:ys) + rule #1: accum ys f a (x:xs) = accum (a:ys) f (f a x) xs + rule #2: accum _ _ _ xs = throw (bad_list_value xs) + state 0: #0 #1 #2 + <var> state 1 + state 1: #0 #1 #2 + <var> state 2 + state 2: #0 #1 #2 + <var> state 3 + state 3: #0 #1 #2 + <var> state 4 + [] state 5 + <app> state 6 + state 4: #2 + state 5: #0 #2 + state 6: #1 #2 + <var> state 7 + <app> state 9 + state 7: #2 + <var> state 8 + state 8: #2 + state 9: #1 #2 + <var> state 10 + : state 13 + state 10: #2 + <var> state 11 + state 11: #2 + <var> state 12 + state 12: #2 + state 13: #1 #2 + <var> state 14 + state 14: #1 #2 + <var> state 15 + state 15: #1 #2 +} end; scanl1 f/*0:01*/ [] = []; scanl1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = scanl f/*0:01*/ x/*0:101*/ xs/*0:11*/; scanr f/*0:001*/ a/*0:01*/ [] = [a/*0:01*/]; -scanr f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*2:001*/ x/*2:101*/ y/*0:01*/:ys/*1:*/ when ys/*0:*/ = scanr f/*0:001*/ a/*0:01*/ xs/*0:11*/; y/*0:01*/:_/*0:1*/ = ys/*0:*/ { +scanr f/*0:001*/ a/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*2:001*/ x/*2:101*/ y/*0:01*/:ys/*1:*/ when ys/*0:*/ = reverse (scanl (flip f/*0:001*/) a/*0:01*/ (reverse xs/*0:11*/)); y/*0:01*/:_/*0:1*/ = ys/*0:*/ { rule #0: y:_ = ys state 0: #0 <app> state 1 @@ -681,14 +727,14 @@ <var> state 5 state 5: #0 } { - rule #0: ys = scanr f a xs + rule #0: ys = reverse (scanl (flip f) a (reverse xs)) state 0: #0 <var> state 1 state 1: #0 } end; scanr1 f/*0:01*/ [] = []; scanr1 f/*0:01*/ [x/*0:101*/] = [x/*0:101*/]; -scanr1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*2:01*/ x/*2:101*/ y/*0:01*/:ys/*1:*/ when ys/*0:*/ = scanr1 f/*0:01*/ xs/*0:11*/; y/*0:01*/:_/*0:1*/ = ys/*0:*/ { +scanr1 f/*0:01*/ (x/*0:101*/:xs/*0:11*/) = f/*2:01*/ x/*2:101*/ y/*0:01*/:ys/*1:*/ when ys/*0:*/ = reverse (scanl1 (flip f/*0:01*/) (reverse xs/*0:11*/)); y/*0:01*/:_/*0:1*/ = ys/*0:*/ { rule #0: y:_ = ys state 0: #0 <app> state 1 @@ -702,7 +748,7 @@ <var> state 5 state 5: #0 } { - rule #0: ys = scanr1 f xs + rule #0: ys = reverse (scanl1 (flip f) (reverse xs)) state 0: #0 <var> state 1 state 1: #0 @@ -715,6 +761,7 @@ takewhile p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = x/*0:101*/:takewhile p/*0:01*/ xs/*0:11*/ if p/*0:01*/ x/*0:101*/; takewhile p/*0:01*/ (x/*0:101*/:xs/*0:11*/) = []; cat [] = []; +cat [xs/*0:101*/] = xs/*0:101*/; cat (xs/*0:101*/:xss/*0:11*/) = accum/*0*/ (reverse xs/*0:101*/) xss/*0:11*/ with accum xs/*0:01*/ [] = reverse xs/*0:01*/; accum xs/*0:01*/ ([]:yss/*0:11*/) = accum/*1*/ xs/*0:01*/ yss/*0:11*/; accum xs/*0:01*/ ((y/*0:10101*/:ys/*0:1011*/):yss/*0:11*/) = accum/*1*/ (y/*0:10101*/:xs/*0:01*/) (ys/*0:1011*/:yss/*0:11*/); accum _/*0:01*/ (ys/*0:101*/:_/*0:11*/) = throw (bad_list_value ys/*0:101*/); accum _/*0:01*/ yss/*0:1*/ = throw (bad_list_value yss/*0:1*/) { rule #0: accum xs [] = reverse xs rule #1: accum xs ([]:yss) = accum xs yss This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-27 09:17:47
|
Revision: 142 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=142&view=rev Author: agraef Date: 2008-05-27 02:17:56 -0700 (Tue, 27 May 2008) Log Message: ----------- Overhaul of prelude. Modified Paths: -------------- pure/trunk/lib/prelude.pure pure/trunk/lib/primitives.pure Modified: pure/trunk/lib/prelude.pure =================================================================== --- pure/trunk/lib/prelude.pure 2008-05-27 08:38:37 UTC (rev 141) +++ pure/trunk/lib/prelude.pure 2008-05-27 09:17:56 UTC (rev 142) @@ -28,6 +28,17 @@ nullary failed_match; // failed pattern match (lambda, case, etc.) nullary stack_fault; // not enough stack space (PURE_STACK limit) +/* Other exceptions defined by the prelude. Note that some of the list + operations require that their list arguments are "proper" lists (ending in + []) and will raise a 'bad_list_value xs' exception otherwise; in this case + xs denotes the offending tail. Likewise, some operations will raise the + 'empty_list' exception if a nonempty list is required. */ + +nullary out_of_bounds; // tuple or list index is out of bounds (!) +nullary empty_list; // empty list (head, tail, etc.) +// bad_list_value xs; // not a proper list value (reverse, etc.) +// bad_value x; // invalid argument type + /* Other constants. */ nullary [] (); // empty list and tuple @@ -80,11 +91,6 @@ inequality and emptiness, to determine the size of a tuple, for zero-based indexing, and to reverse a tuple. */ -/* Note: Some of these definitions aren't exactly pretty. They are what they - are because they are the most efficient (at least asymptotically). In - particular, we strive for tail-recursive and constant or linear-time - implementations where this is feasible. */ - x,() = x; (),y = y; (x,y),z = x,(y,z); @@ -111,6 +117,7 @@ (x,xs)!0 = x; (x,y,xs)!n::int = (y,xs)!(n-1) if n>0; (x,y)!1 = y; +(x,xs)!n::int = throw out_of_bounds; reverse () = (); reverse (x,xs) = accum x xs with @@ -126,10 +133,6 @@ compute the size of a list, for indexing and concatenation, and for reversing a list. */ -/* Note: Some list operations throw a 'bad_list_value xs' exception if their - argument is not a "proper" list (i.e., ending in []). In this case xs - denotes the offending tail of the list. */ - []==[] = 1; (x:xs)==[] = 0; []==(x:xs) = 0; @@ -151,7 +154,9 @@ end; (x:xs)!0 = x; -(x:xs)!n::int = xs!(n-1) if n>0; +(x:xs)!n::int = xs!(n-1) if n>0 && assert (listnp xs) (bad_list_value xs); +(x:xs)!n::int = throw out_of_bounds; +[]!n::int = throw out_of_bounds; []+ys = ys; (x:xs)+ys = x : accum ys (reverse xs) with @@ -187,11 +192,12 @@ structures defined above. */ xs![] = []; -xs!(n:ns) = accum [] xs (reverse (n:ns)) (#xs) with - accum ys xs [] m = ys; - accum ys xs (n::int:ns) m = accum (xs!n:ys) xs ns m if n>=0 && n<m; - = accum ys xs ns m otherwise; -end; +xs!(n:ns) = accum [] (reverse (n:ns)) with + accum ys [] = ys; + accum ys (n::int:ns) = accum (xs!n:ys) ns if n>=0 && n<m; + = accum ys ns otherwise; + accum _ (n:_) = throw (bad_value n); +end when m::int = #xs end; /* Arithmetic sequences. */ @@ -203,8 +209,9 @@ /* Common list functions. This mostly comes straight from the Q prelude which in turn was based on the first edition of the Bird/Wadler book, and is very - similar to what you can find in the Haskell prelude (although some - functions have slightly different names). */ + similar to what you can find in the Haskell prelude. Some functions have + slightly different names, though, and some of the definitions were massaged + to make them tail-recursive. */ all p [] = 1; all p (x:xs) = p x && all p xs; @@ -236,11 +243,11 @@ foldr f a [] = a; foldr f a (x:xs) - = f x (foldr f a xs); + = f x (foldl (flip f) a (reverse xs)); foldr1 f [x] = x; foldr1 f (x:y:xs) - = f x (foldr1 f (y:xs)); + = f x (foldl1 (flip f) (reverse (y:xs))); head (x:xs) = x; @@ -255,18 +262,28 @@ scanl f a [] = [a]; scanl f a (x:xs) - = a:scanl f (f a x) xs; + = accum [a] f (f a x) xs with + accum ys f a [] = reverse (a:ys); + accum ys f a (x:xs) = accum (a:ys) f (f a x) xs; + accum _ _ _ xs = throw (bad_list_value xs); + end; scanl1 f [] = []; scanl1 f (x:xs) = scanl f x xs; scanr f a [] = [a]; scanr f a (x:xs) - = f x y:ys when ys = scanr f a xs; y:_ = ys end; + = f x y:ys when + ys = reverse (scanl (flip f) a (reverse xs)); + y:_ = ys; + end; scanr1 f [] = []; scanr1 f [x] = [x]; -scanr1 f (x:xs) = f x y:ys when ys = scanr1 f xs; y:_ = ys end; +scanr1 f (x:xs) = f x y:ys when + ys = reverse (scanl1 (flip f) (reverse xs)); + y:_ = ys; + end; tail (x:xs) = xs; @@ -282,6 +299,7 @@ /* Concatenate a list of lists. */ cat [] = []; +cat [xs] = xs; cat (xs:xss) = accum (reverse xs) xss with accum xs [] = reverse xs; accum xs ([]:yss) = accum xs yss; Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-05-27 08:38:37 UTC (rev 141) +++ pure/trunk/lib/primitives.pure 2008-05-27 09:17:56 UTC (rev 142) @@ -24,6 +24,11 @@ extern void pure_throw(expr*); // IMPURE! throw x = pure_throw x; +/* Convenience function to ensure a condition p. Returns 1 (true) if p holds, + and throws the given exception e otherwise. */ + +assert p e = if p then 1 else throw e; + /* Syntactic equality. */ extern bool same(expr* x, expr* y); @@ -39,7 +44,7 @@ pointerp x = case x of _::pointer = 1; _ = 0 end; /* Predicates to check for function objects, global (unbound) variables, - function applications and proper lists and tuples. */ + function applications, proper lists, list nodes and tuples. */ extern bool funp(expr*), bool lambdap(expr*), bool varp(expr*), bool applp(expr*); @@ -48,6 +53,10 @@ listp (x:xs) = listp xs; listp _ = 0 otherwise; +listnp [] = 1; +listnp (x:xs) = 1; +listnp _ = 0 otherwise; + tuplep () = 1; tuplep (x,xs) = 1; tuplep _ = 0 otherwise; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |