pure-lang-svn Mailing List for Pure (Page 33)
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-05-05 11:25:13
|
Revision: 60 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=60&view=rev Author: agraef Date: 2008-05-05 04:25:19 -0700 (Mon, 05 May 2008) Log Message: ----------- Back out revision 52, for OSX compatibility and according to the FHS, manpages should go to $(prefix)/share/man. Revision Links: -------------- http://pure-lang.svn.sourceforge.net/pure-lang/?rev=52&view=rev Modified Paths: -------------- pure/trunk/Makefile Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-05 09:40:50 UTC (rev 59) +++ pure/trunk/Makefile 2008-05-05 11:25:19 UTC (rev 60) @@ -15,7 +15,7 @@ prefix = /usr/local bindir = $(prefix)/bin libdir = $(prefix)/lib/pure -mandir = $(prefix)/man/man1 +mandir = $(prefix)/share/man/man1 # Staging directory for 'make install'. If you use this, make sure that this # ends in a slash. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-05 09:40:43
|
Revision: 59 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=59&view=rev Author: agraef Date: 2008-05-05 02:40:50 -0700 (Mon, 05 May 2008) Log Message: ----------- Cosmetic changes, add notes about MS Windows. Modified Paths: -------------- pure/trunk/INSTALL Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-05-05 09:20:02 UTC (rev 58) +++ pure/trunk/INSTALL 2008-05-05 09:40:50 UTC (rev 59) @@ -11,13 +11,13 @@ platforms. 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. Version 4.x of the GNU -C++ compiler is known to work (it should be available almost everywhere), -earlier versions probably need some work. Other ANSI/ISO compatible C/C++ -compilers will probably work as well after you fiddled with the compilation -options, but this has not been tested. Also note that the Makefile pretty much -requires GNU make right now, so you should make sure that you have that -installed before trying to compile Pure. +amount of tweaking) on all UNIX/POSIX-based platforms. We recommend using +version 4.x of the GNU C++ compiler; it should be available almost everywhere. +Other ANSI/ISO compatible C/C++ compilers will probably work as well (after +some fiddling with the compilation options and the sources maybe), but this +has not been tested. Also note that the Makefile pretty much requires GNU make +right now, so you should make sure that you have that installed before trying +to compile Pure. BASIC INSTALLATION @@ -72,7 +72,7 @@ $ make build=release $ sudo make install -Here, x.y denotes the current Pure version number (0.1 at the time of this +Here, x.y denotes the current Pure version number (0.2 at the time of this writing). If you want to install the debugging-enabled version, run just 'make' instead of 'make build=release'. @@ -226,7 +226,17 @@ but they are harmless and can be ignored. These warnings should also go away once Apple upgrades its SDK to a newer gcc version. +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 the Windows version of LLVM (available at +http://llvm.org) installed. So *you* can still be the hero who first got Pure +up and running on Windows; if you do, please let us know! :) + + May 2008 Albert Graef <Dr.Graef at t-online.de> Eddie Rucker <erucker at bmc.edu> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-05 09:19:56
|
Revision: 58 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=58&view=rev Author: agraef Date: 2008-05-05 02:20:02 -0700 (Mon, 05 May 2008) Log Message: ----------- Updated ChangeLog. Modified Paths: -------------- pure/trunk/ChangeLog Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-05 09:19:18 UTC (rev 57) +++ pure/trunk/ChangeLog 2008-05-05 09:20:02 UTC (rev 58) @@ -1,10 +1,14 @@ 2008-05-05 Albert Graef <Dr....@t-...> - * Makefile: Remove -s flag so that the pure executable is - installed without stripping the symbols which are needed to - properly resolve runtime externals on OSX. Reported by Ryan - Schmidt and others. + * INSTALL: Add system-specific notes. + * Makefile: Massaged some rules for OSX compatibility. In + particular, -rdynamic is now in the LDFLAGS, so that it can be + removed more easily, and I also removed the install -s flag so + that the pure executable is installed without stripping the + symbols which are needed to properly resolve runtime externals on + OSX. Reported by Ryan Schmidt and others. + * matcher.cc (merge_ctrans): Fixed broken mpz_cmp() test causing transitions on different (instead of equal) bigint constants to be merged. Reported by Libor Spacek. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-05 09:19:23
|
Revision: 57 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=57&view=rev Author: agraef Date: 2008-05-05 02:19:18 -0700 (Mon, 05 May 2008) Log Message: ----------- Add system-specific notes. Modified Paths: -------------- pure/trunk/INSTALL Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-05-05 09:17:57 UTC (rev 56) +++ pure/trunk/INSTALL 2008-05-05 09:19:18 UTC (rev 57) @@ -5,9 +5,21 @@ These instructions (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. +required LLVM source packages can be found at http://llvm.org. Please also +have a look at the SYSTEM-SPECIFIC NOTES section at the end of this file which +describes the tweaks necessary to make Pure compile and run on various +platforms. +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. Version 4.x of the GNU +C++ compiler is known to work (it should be available almost everywhere), +earlier versions probably need some work. Other ANSI/ISO compatible C/C++ +compilers will probably work as well after you fiddled with the compilation +options, but this has not been tested. Also note that the Makefile pretty much +requires GNU make right now, so you should make sure that you have that +installed before trying to compile Pure. + BASIC INSTALLATION ===== ============ @@ -15,8 +27,8 @@ required once. Steps 2-3 can be avoided if binary LLVM packages are available for your system. Additional instructions for compiling Pure from SVN sources can be found in the INSTALLING FROM SVN SOURCES section below. Moreover, you -can refer to the OTHER COMPILATION OPTIONS section at the end of the file for -details about various options available when building and installing Pure. +can refer to the OTHER COMPILATION OPTIONS section below for details about +various options available when building and installing Pure. STEP 1. Make sure you have all the necessary dependencies installed (-dev denotes corresponding development packages): @@ -169,6 +181,52 @@ installation process and other available targets and options. +SYSTEM-SPECIFIC NOTES +=============== ===== + +ALL PLATFORMS +--- --------- + +Compiling the release version (make build=release) with gcc with all warnings +turned on (which is the default) will give you the warning "dereferencing +type-punned pointer will break strict-aliasing rules" at some point in +util.cc. This is harmless and can be ignored. + +64 BIT SYSTEMS +-- --- ------- + +Please note that at the time of this writing only the release build of Pure +(make build=release) appears to work on (some) 64 bit systems. We're working +on these issues right now, so please stay tuned. + +LINUX +----- + +Linux is the primary development platform for this software, and the sources +should build out of the box on all recent Linux distributions. (Some +unresolved issues have been reported with Ubuntu on PowerPC, though, see the +mailing list for details and updates on this.) + +MAC OSX +--- --- + +Pure is known to work on this platform, and 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): + +$ make LDFLAGS="" 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 +non-void function" a couple of times in interpreter.cc. These are due to a bug +in older gcc versions (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16558), +but they are harmless and can be ignored. These warnings should also go away +once Apple upgrades its SDK to a newer gcc version. + + May 2008 Albert Graef <Dr.Graef at t-online.de> Eddie Rucker <erucker at bmc.edu> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-05 09:17:55
|
Revision: 56 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=56&view=rev Author: agraef Date: 2008-05-05 02:17:57 -0700 (Mon, 05 May 2008) Log Message: ----------- Move -rdynamic to LDFLAGS, comment changes. Modified Paths: -------------- pure/trunk/Makefile Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-05 07:28:25 UTC (rev 55) +++ pure/trunk/Makefile 2008-05-05 09:17:57 UTC (rev 56) @@ -17,8 +17,22 @@ libdir = $(prefix)/lib/pure mandir = $(prefix)/man/man1 +# 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). 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). + +LDFLAGS=-rdynamic +LIBS= + # Compilation flags. We provide three different build profiles: # 'default' compiles with extra runtime checks and debugging information. @@ -36,8 +50,6 @@ build=default -# No need to edit below this line. Unless you really have to. :) ############ - LLVM_FLAGS = `llvm-config --cppflags` LLVM_LIBS = `llvm-config --ldflags --libs core jit native` @@ -67,6 +79,8 @@ endif endif +# 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 \ runtime.cc runtime.h symtable.cc symtable.hh util.cc util.hh @@ -92,7 +106,7 @@ all: pure pure: $(OBJECT) - $(CXX) -o $@ $(LDFLAGS) -rdynamic $(OBJECT) $(ALL_LIBS) + $(CXX) -o $@ $(LDFLAGS) $(OBJECT) $(ALL_LIBS) pure.o: pure.cc $(CXX) $(CXXFLAGS) -DVERSION='"$(version)"' -DPURELIB='"$(libdir)"' -c -o $@ $< This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-05 07:28:39
|
Revision: 55 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=55&view=rev Author: agraef Date: 2008-05-05 00:28:25 -0700 (Mon, 05 May 2008) Log Message: ----------- Remove -s option from install command, which wreaks havoc on OSX (unresolved externals). Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/Makefile Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-05 06:57:21 UTC (rev 54) +++ pure/trunk/ChangeLog 2008-05-05 07:28:25 UTC (rev 55) @@ -1,5 +1,10 @@ 2008-05-05 Albert Graef <Dr....@t-...> + * Makefile: Remove -s flag so that the pure executable is + installed without stripping the symbols which are needed to + properly resolve runtime externals on OSX. Reported by Ryan + Schmidt and others. + * matcher.cc (merge_ctrans): Fixed broken mpz_cmp() test causing transitions on different (instead of equal) bigint constants to be merged. Reported by Libor Spacek. Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-05 06:57:21 UTC (rev 54) +++ pure/trunk/Makefile 2008-05-05 07:28:25 UTC (rev 55) @@ -84,8 +84,8 @@ $(SOURCE) $(EXTRA_SOURCE) w3centities.c pure.1 pure.xml pure.vim \ $(examples) $(lib) $(tests) $(distlogs) -.PHONY: all html dvi ps pdf clean realclean depend install uninstall dist \ -distcheck cleanlogs logs check +.PHONY: all html dvi ps pdf clean realclean depend install uninstall strip \ +dist distcheck cleanlogs logs check # compilation @@ -140,11 +140,19 @@ 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 -s pure $(DESTDIR)$(bindir)/pure + install pure $(DESTDIR)$(bindir)/pure install -m 644 $(lib) $(DESTDIR)$(libdir) 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-05-05 06:57:14
|
Revision: 54 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=54&view=rev Author: agraef Date: 2008-05-04 23:57:21 -0700 (Sun, 04 May 2008) Log Message: ----------- Fixed wrong mpz_cmp() tests in pattern matching code. Added regression test #8. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/matcher.cc Added Paths: ----------- pure/trunk/test/test8.log pure/trunk/test/test8.pure Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-04 22:17:09 UTC (rev 53) +++ pure/trunk/ChangeLog 2008-05-05 06:57:21 UTC (rev 54) @@ -1,3 +1,9 @@ +2008-05-05 Albert Graef <Dr....@t-...> + + * matcher.cc (merge_ctrans): Fixed broken mpz_cmp() test causing + transitions on different (instead of equal) bigint constants to be + merged. Reported by Libor Spacek. + 2008-05-04 Albert Graef <Dr....@t-...> * 0.2 release. Modified: pure/trunk/matcher.cc =================================================================== --- pure/trunk/matcher.cc 2008-05-04 22:17:09 UTC (rev 53) +++ pure/trunk/matcher.cc 2008-05-05 06:57:21 UTC (rev 54) @@ -95,7 +95,7 @@ case EXPR::INT: return (x.ival() == t->i)?t->st:0; case EXPR::BIGINT: - return (mpz_cmp(x.zval(), t->z))?t->st:0; + return (mpz_cmp(x.zval(), t->z) == 0)?t->st:0; case EXPR::DBL: return (x.dval() == t->d)?t->st:0; case EXPR::STR: @@ -377,7 +377,7 @@ transl::iterator t; // look for a matching transition for (t = tr.begin(); t != tr.end(); t++) { - if (t->tag == EXPR::BIGINT && mpz_cmp(t->z, x)) { + if (t->tag == EXPR::BIGINT && mpz_cmp(t->z, x) == 0) { merge_state(t->st, st); return; } else if (t->tag > 0 || t->tag < EXPR::BIGINT) Added: pure/trunk/test/test8.log =================================================================== --- pure/trunk/test/test8.log (rev 0) +++ pure/trunk/test/test8.log 2008-05-05 06:57:21 UTC (rev 54) @@ -0,0 +1,36 @@ +Binomial n/*0:01*/ k/*0:1*/ = Binomial n/*0:01*/ (n/*0:01*/-k/*0:1*/) if n/*0:01*/-k/*0:1*/<k/*0:1*/; +Binomial n/*0:01*/ 0G = 1G; +Binomial n/*0:01*/ 0 = 1; +Binomial n/*0:01*/ 1G = n/*0:01*/; +Binomial n/*0:01*/ 1 = n/*0:01*/; +Binomial n/*0:01*/ k/*0:1*/ = Binomial nm2/*0:*/ (k/*1:1*/-2)+2*Binomial nm2/*0:*/ (k/*1:1*/-1)+Binomial nm2/*0:*/ k/*1:1*/ when nm2/*0:*/ = n/*0:01*/-2 { + rule #0: nm2 = n-2 + state 0: #0 + <var> state 1 + state 1: #0 +} end; +{ + rule #0: Binomial n k = Binomial n (n-k) if n-k<k + rule #1: Binomial n 0G = 1G + rule #2: Binomial n 0 = 1 + rule #3: Binomial n 1G = n + rule #4: Binomial n 1 = n + rule #5: Binomial n k = Binomial nm2 (k-2)+2*Binomial nm2 (k-1)+Binomial nm2 k when nm2 = n-2 end + state 0: #0 #1 #2 #3 #4 #5 + <var> state 1 + state 1: #0 #1 #2 #3 #4 #5 + <var> state 2 + 0::int state 3 + 1::int state 4 + 0G::bigint state 5 + 1G::bigint state 6 + state 2: #0 #5 + state 3: #0 #2 #5 + state 4: #0 #4 #5 + state 5: #0 #1 #5 + state 6: #0 #3 #5 +} +Binomial 5 2; +10 +Binomial 5G 2G; +10G Added: pure/trunk/test/test8.pure =================================================================== --- pure/trunk/test/test8.pure (rev 0) +++ pure/trunk/test/test8.pure 2008-05-05 06:57:21 UTC (rev 54) @@ -0,0 +1,13 @@ +Binomial n k = Binomial n (n-k) if n-k < k; +Binomial n 0G = 1G; +Binomial n 0 = 1; +Binomial n 1G = n; +Binomial n 1 = n; +Binomial n k = + Binomial nm2 (k-2) + + 2 * Binomial nm2 (k-1) + + Binomial nm2 k + when nm2 = n-2 end; + +Binomial 5 2; +Binomial 5G 2G; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-04 22:17:03
|
Revision: 53 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=53&view=rev Author: agraef Date: 2008-05-04 15:17:09 -0700 (Sun, 04 May 2008) Log Message: ----------- Back out previous change (rev. 51), which causes more trouble than it's worth. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/Makefile Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-04 22:15:14 UTC (rev 52) +++ pure/trunk/ChangeLog 2008-05-04 22:17:09 UTC (rev 53) @@ -1,9 +1,5 @@ 2008-05-04 Albert Graef <Dr....@t-...> - * Makefile (pure.o): Add missing dependency of pure.o on Makefile, - so that the main module gets recompiled when bumping the version - number. - * 0.2 release. * lexer.ll, printer.cc: Add an explicit notation for big Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-04 22:15:14 UTC (rev 52) +++ pure/trunk/Makefile 2008-05-04 22:17:09 UTC (rev 53) @@ -94,7 +94,7 @@ pure: $(OBJECT) $(CXX) -o $@ $(LDFLAGS) -rdynamic $(OBJECT) $(ALL_LIBS) -pure.o: pure.cc Makefile +pure.o: pure.cc $(CXX) $(CXXFLAGS) -DVERSION='"$(version)"' -DPURELIB='"$(libdir)"' -c -o $@ $< lexer.cc: lexer.ll This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-04 22:15:06
|
Revision: 52 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=52&view=rev Author: agraef Date: 2008-05-04 15:15:14 -0700 (Sun, 04 May 2008) Log Message: ----------- Install manpage under $(prefix)/man by default. Modified Paths: -------------- pure/trunk/Makefile Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-04 10:44:58 UTC (rev 51) +++ pure/trunk/Makefile 2008-05-04 22:15:14 UTC (rev 52) @@ -15,7 +15,7 @@ prefix = /usr/local bindir = $(prefix)/bin libdir = $(prefix)/lib/pure -mandir = $(prefix)/share/man/man1 +mandir = $(prefix)/man/man1 DESTDIR= This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-04 10:44:54
|
Revision: 51 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=51&view=rev Author: agraef Date: 2008-05-04 03:44:58 -0700 (Sun, 04 May 2008) Log Message: ----------- Cosmetic change. Modified Paths: -------------- pure/trunk/examples/hello.pure Modified: pure/trunk/examples/hello.pure =================================================================== --- pure/trunk/examples/hello.pure 2008-05-04 10:10:37 UTC (rev 50) +++ pure/trunk/examples/hello.pure 2008-05-04 10:44:58 UTC (rev 51) @@ -55,8 +55,6 @@ fact1 n = n*fact1 (n-1) if n>0; = 1 otherwise; -let x = fact1 10; - // This is essentially the same, but uses a 'case' expression. fact2 n = case n of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-04 10:10:29
|
Revision: 50 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=50&view=rev Author: agraef Date: 2008-05-04 03:10:37 -0700 (Sun, 04 May 2008) Log Message: ----------- Add missing dependency of pure.o on Makefile. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/Makefile Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-04 09:30:54 UTC (rev 49) +++ pure/trunk/ChangeLog 2008-05-04 10:10:37 UTC (rev 50) @@ -1,5 +1,9 @@ 2008-05-04 Albert Graef <Dr....@t-...> + * Makefile (pure.o): Add missing dependency of pure.o on Makefile, + so that the main module gets recompiled when bumping the version + number. + * 0.2 release. * lexer.ll, printer.cc: Add an explicit notation for big Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-04 09:30:54 UTC (rev 49) +++ pure/trunk/Makefile 2008-05-04 10:10:37 UTC (rev 50) @@ -94,7 +94,7 @@ pure: $(OBJECT) $(CXX) -o $@ $(LDFLAGS) -rdynamic $(OBJECT) $(ALL_LIBS) -pure.o: pure.cc +pure.o: pure.cc Makefile $(CXX) $(CXXFLAGS) -DVERSION='"$(version)"' -DPURELIB='"$(libdir)"' -c -o $@ $< lexer.cc: lexer.ll This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-04 09:30:47
|
Revision: 49 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=49&view=rev Author: agraef Date: 2008-05-04 02:30:54 -0700 (Sun, 04 May 2008) Log Message: ----------- Snapshot of Pure 0.2. Added Paths: ----------- pure/releases/pure-0.2/ pure/releases/pure-0.2/ChangeLog pure/releases/pure-0.2/INSTALL pure/releases/pure-0.2/Makefile pure/releases/pure-0.2/NEWS pure/releases/pure-0.2/README pure/releases/pure-0.2/examples/hello.pure pure/releases/pure-0.2/interpreter.cc pure/releases/pure-0.2/interpreter.hh pure/releases/pure-0.2/lexer.ll pure/releases/pure-0.2/lib/prelude.pure pure/releases/pure-0.2/lib/primitives.pure pure/releases/pure-0.2/printer.cc pure/releases/pure-0.2/pure.1 pure/releases/pure-0.2/runtime.cc pure/releases/pure-0.2/runtime.h pure/releases/pure-0.2/test/prelude.log pure/releases/pure-0.2/test/test1.log pure/releases/pure-0.2/test/test1.pure pure/releases/pure-0.2/test/test2.log pure/releases/pure-0.2/test/test3.log pure/releases/pure-0.2/test/test4.log pure/releases/pure-0.2/test/test4.pure pure/releases/pure-0.2/test/test5.log pure/releases/pure-0.2/test/test6.log pure/releases/pure-0.2/test/test7.log pure/releases/pure-0.2/util.cc Removed Paths: ------------- pure/releases/pure-0.2/ChangeLog pure/releases/pure-0.2/Makefile pure/releases/pure-0.2/NEWS pure/releases/pure-0.2/README pure/releases/pure-0.2/examples/hello.pure pure/releases/pure-0.2/interpreter.cc pure/releases/pure-0.2/interpreter.hh pure/releases/pure-0.2/lexer.ll pure/releases/pure-0.2/lib/prelude.pure pure/releases/pure-0.2/lib/primitives.pure pure/releases/pure-0.2/printer.cc pure/releases/pure-0.2/pure.1 pure/releases/pure-0.2/runtime.cc pure/releases/pure-0.2/runtime.h pure/releases/pure-0.2/test/test1.pure pure/releases/pure-0.2/test/test4.pure pure/releases/pure-0.2/util.cc Copied: pure/releases/pure-0.2 (from rev 29, pure/trunk) Deleted: pure/releases/pure-0.2/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-02 07:09:21 UTC (rev 29) +++ pure/releases/pure-0.2/ChangeLog 2008-05-04 09:30:54 UTC (rev 49) @@ -1,74 +0,0 @@ -2008-05-02 Albert Graef <Dr....@t-...> - - * Makefile: Add $(LDFLAGS) and $(LIBS) to the link line, so that - the user can easily add his own linker options and local - libraries. - - * lib/strings.pure: Add missing range check in string indexing - operation. Reported by Eddie Rucker. - - * printer.cc (operator <<): Handle stack overflow while printing - an expression. - - * interpreter.cc (dodefn): Fix a tricky bug causing the executable - code of closures bound to variables to be freed when it was still - needed. Reported by Chris Double. - -2008-05-01 Albert Graef <Dr....@t-...> - - * interpreter.cc: Proper alignment of value fields in expression - struct on 64 bit systems. Reported by Tim Haynes. - - * Makefile: g++ shouldn't be hardcoded, use $(CXX) instead. - Reported by Ryan Schmidt. - - * runtime.cc (pure_sys_vars): More OSX compatibility fixes. - Reported by Ryan Schmidt. - -2008-04-30 Albert Graef <Dr....@t-...> - - * interpreter.cc: Fix a compilation error (STL bug: - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11729) as well as some - bogus warnings with Apple gcc 4.0.1. Reported by Ryan Schmidt. - - * Makefile (make depend): Get rid of bogus LLVM dependencies. - Reported by Ryan Schmidt. - - * lexer.ll, parser.yy: Fixes for compatibility with newer flex and - bison versions. Reported by Eddie Rucker. - -2008-04-28 Albert Graef <Dr....@t-...> - - * examples/symbolic.pure: Add symbolic evaluation example. This is - just a straightforward port of some Q examples. - - * runtime.cc: Add support for advisory stack checks. - - * matcher.cc: Bugfixes. - -2008-04-27 Albert Graef <Dr....@t-...> - - * lib/string.pure: Added split and join functions. - - * pure.1, examples/hello.pure: Overhaul n queens example, added - quicksort and binary search tree examples. - - * lib/prelude.pure: Added void and curry/uncurry combinators, do, - zipdo. - - * interpreter.cc, pure.cc, runtime.cc: Make SIGINT generate a - useful exception value. - - * pure.cc: Add completion for global function and variable - symbols. - -2008-04-22 Albert Graef <Dr....@t-...> - - * Got a working interpreter, at last. There's still lots of stuff - to do (see the TODO file), but the interpreter should now be - usable as it is. - -2008-03-27 Albert Graef <Dr....@t-...> - - * ChangeLog started - Copied: pure/releases/pure-0.2/ChangeLog (from rev 47, pure/trunk/ChangeLog) =================================================================== --- pure/releases/pure-0.2/ChangeLog (rev 0) +++ pure/releases/pure-0.2/ChangeLog 2008-05-04 09:30:54 UTC (rev 49) @@ -0,0 +1,127 @@ +2008-05-04 Albert Graef <Dr....@t-...> + + * 0.2 release. + + * lexer.ll, printer.cc: Add an explicit notation for big + integers. Any integer immediately followed by the uppercase letter + "G" (as in "biG" or "GMP") will now always be interpreted as a + bigint constant, even if it fits into a machine integer. This + notation is also used when printing bigint constants. This change + was necessary to make it possible to write rules matching against + "small bigint" constants. + + * lib/primitives.pure: Added operations to recognize function + applications and extract the function and argument parts, + implemented in runtime.cc. Note that these operations can't be + defined in Pure because of the "head is function" rule which means + that in a pattern of the form f x, f is always a literal function + symbol and not a variable. + +2008-05-03 Albert Graef <Dr....@t-...> + + * README: Moved installation instructions to a separate INSTALL + file, added Eddie Rucker's detailed instructions there. + + * util.cc (myiconv): Apple's iconv takes const char** as 2nd + parameter. #ifdef that case. Reported by Ryan Schmidt. + + * interpreter.cc (declare_extern): Fixed a bug in the generated + wrapper code for external calls, which caused function arguments + to be garbage-collected prematurely, when they were still needed + to create the default value, in the case of external calls + returning a null expression pointer to indicate failure. Reported + by Eddie Rucker. + + * test/test4.pure: Disabled tail call checks, as they may fail on + some platforms. Reported by Ryan Schmidt. + + * test/test1.pure: Corrected fact3 example, added test cases. + Reported by Libor Spacek. + +2008-05-02 Albert Graef <Dr....@t-...> + + * Makefile: Overhaul of regression tests so that results of + expressions are recorded. Also, 'make check' doesn't depend on the + log files any more, so that the logs can be stored in svn. You can + now use the explicit goal 'make logs' to regenerate the logs for + changed test files. + + * runtime.cc (same): Added a syntactic equality test. Requested by + Eddie Rucker. + + * Makefile: Add $(LDFLAGS) and $(LIBS) to the link line, so that + the user can easily add his own linker options and local + libraries. + + * lib/strings.pure: Add missing range check in string indexing + operation. Reported by Eddie Rucker. + + * printer.cc (operator <<): Handle stack overflow while printing + an expression. + + * interpreter.cc (dodefn): Fix a tricky bug causing the executable + code of closures bound to variables to be freed when it was still + needed. Reported by Chris Double. + +2008-05-01 Albert Graef <Dr....@t-...> + + * interpreter.cc: Proper alignment of value fields in expression + struct on 64 bit systems. Reported by Tim Haynes. + + * Makefile: g++ shouldn't be hardcoded, use $(CXX) instead. + Reported by Ryan Schmidt. + + * runtime.cc (pure_sys_vars): More OSX compatibility fixes. + Reported by Ryan Schmidt. + +2008-04-30 Albert Graef <Dr....@t-...> + + * interpreter.cc: Fix a compilation error (STL bug: + http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11729) as well as some + bogus warnings with Apple gcc 4.0.1. Reported by Ryan Schmidt. + + * Makefile (make depend): Get rid of bogus LLVM dependencies. + Reported by Ryan Schmidt. + + * lexer.ll, parser.yy: Fixes for compatibility with newer flex and + bison versions. Reported by Eddie Rucker. + +2008-04-29 Albert Graef <Dr....@t-...> + + * 0.1 release. + +2008-04-28 Albert Graef <Dr....@t-...> + + * examples/symbolic.pure: Add symbolic evaluation example. This is + just a straightforward port of some Q examples. + + * runtime.cc: Add support for advisory stack checks. + + * matcher.cc: Bugfixes. + +2008-04-27 Albert Graef <Dr....@t-...> + + * lib/string.pure: Added split and join functions. + + * pure.1, examples/hello.pure: Overhaul n queens example, added + quicksort and binary search tree examples. + + * lib/prelude.pure: Added void and curry/uncurry combinators, do, + zipdo. + + * interpreter.cc, pure.cc, runtime.cc: Make SIGINT generate a + useful exception value. + + * pure.cc: Add completion for global function and variable + symbols. + +2008-04-22 Albert Graef <Dr....@t-...> + + * Got a working interpreter, at last. There's still lots of stuff + to do (see the TODO file), but the interpreter should now be + usable as it is. + +2008-03-27 Albert Graef <Dr....@t-...> + + * ChangeLog started + Copied: pure/releases/pure-0.2/INSTALL (from rev 38, pure/trunk/INSTALL) =================================================================== --- pure/releases/pure-0.2/INSTALL (rev 0) +++ pure/releases/pure-0.2/INSTALL 2008-05-04 09:30:54 UTC (rev 49) @@ -0,0 +1,174 @@ + +INSTALLING PURE (AND LLVM) +========== ==== ==== ===== + +These instructions (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. + + +BASIC INSTALLATION +===== ============ + +The basic installation process is as follows. Note that steps 1-3 are only +required once. Steps 2-3 can be avoided if binary LLVM packages are available +for your system. Additional instructions for compiling Pure from SVN sources +can be found in the INSTALLING FROM SVN SOURCES section below. Moreover, you +can refer to the OTHER COMPILATION OPTIONS section at the end of the file for +details about various options available when building and installing Pure. + +STEP 1. Make sure you have all the necessary dependencies installed (-dev +denotes corresponding development packages): + +- GNU make, GNU C++ and the corresponding libraries; + +- flex and bison (these are only required when compiling the Pure SVN sources, + see the INSTALLING FROM SVN SOURCES section below); + +- libgmp, -dev; + +- libreadline, -dev; + +- libltdl, -dev; + +- subversion (only needed to fetch the SVN sources, see below). + +E.g., the required packages for Ubuntu are: make, g++, g++ 4.0 multilib, flex, +bison, libgmp3c2, libgmp3-dev, readline5-dev, libltdl3, libldtl3-dev, +subversion. + +STEP 2. Get and unpack the LLVM 2.2 sources at: +http://llvm.org/releases/download.html#2.2 + +STEP 3. Configure, build and install LLVM as follows: + +$ cd llvm-2.2 +$ ./configure +$ make +$ sudo make install + +STEP 4. Get and unpack the Pure sources at: http://pure-lang.sf.net/ + +The latest release tarballs can always be found on the SourceForge project +page. See "Downloads" on the Pure website for a quick link to the download +section. + +STEP 5. Build and install the release version of Pure as follows: + +$ cd pure-x.y +$ make build=release +$ sudo make install + +Here, x.y denotes the current Pure version number (0.1 at the time of this +writing). If you want to install the debugging-enabled version, run just +'make' instead of 'make build=release'. + +To check that Pure is working correctly on your computer, also run: + +$ make check + +STEP 6. The Pure interpreter should be ready to go now. (On some systems you +might first have to run ldconfig to update the dynamic linker cache.) + +Run Pure interactively as: + +$ pure +Pure 0.1 Copyright (c) 2008 by Albert Graef +This program is free software distributed under the GNU Public License +(GPL V3 or later). Please see the COPYING file for details. +Loaded prelude from /usr/local/lib/pure/prelude.pure. + +Check that it works: + +> 6*7; +42 + +Read the online documentation (this invokes the Pure manual page): + +> help + +Exit the interpreter (you can also just type the end-of-file character at the +beginning of a line, i.e., Ctrl-D on Unix): + +> quit + + +INSTALLING FROM SVN SOURCES +========== ==== === ======= + +The latest development version of Pure is available in its subversion (SVN) +source code repository. You can browse the repository at: + +http://pure-lang.svn.sourceforge.net/viewvc/pure-lang/ + +(See the pure/trunk subdirectory for the latest sources.) + +Note that if you're going with the development sources, you'll also need +fairly recent versions of the flex and bison utilities (flex 2.5.31 and bison +2.3 should be ok). + +To compile from the development sources, replace steps 4 and 5 above with: + +STEP 4': Fetch the SVN sources. + +$ svn co http://pure-lang.svn.sourceforge.net/svnroot/pure-lang pure-lang + +STEP 5': Build and install the debugging-enabled version (of course you can +also build the release version, as described in step 5 above): + +$ cd pure-lang/pure/trunk +$ make +$ sudo make install + + +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.: + +$ 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). + +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) like libiconv on OSX. + +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, + +$ PURELIB=./lib ./pure + +will run the Pure interpreter with that setting in Bourne-compatible shells. + +For the release version, you should build the interpreter as follows: + +$ make build=release + +This disables all runtime checks and debugging information in the interpreter. +(Don't worry, your Pure programs will still be executed "safely" and shouldn't +segfault unless you run out of memory or there's a bug in the interpreter.) +The 'release' build gives you *much* faster execution times (factor of 2 +compared to the default flags on my Linux system running gcc 4.1, YMMV). It +also takes a *long* time to compile runtime.cc, but it's really worth the +wait, so please be patient. ;-) + +Please also have a look at the Makefile for details on the build and +installation process and other available targets and options. + + +May 2008 +Albert Graef <Dr.Graef at t-online.de> +Eddie Rucker <erucker at bmc.edu> Deleted: pure/releases/pure-0.2/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-02 07:09:21 UTC (rev 29) +++ pure/releases/pure-0.2/Makefile 2008-05-04 09:30:54 UTC (rev 49) @@ -1,212 +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.1 -dist = pure-$(version) - -prefix = /usr/local -bindir = $(prefix)/bin -libdir = $(prefix)/lib/pure -mandir = $(prefix)/share/man/man1 - -DESTDIR= - -# Compilation flags. We provide three different build profiles: - -# 'default' compiles with extra runtime checks and debugging information. -# 'debug' adds more debugging output (useful to debug the interpreter). -# 'release' optimizes for execution speed (release version). - -# The latter disables all runtime checks and debugging information and gives -# you *much* faster execution times (factor of 2 compared to the default flags -# on my Linux system running gcc 4.1, YMMV). It also takes a *long* time to -# compile runtime.cc, so be patient. ;-) - -# 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'.) - -build=default - -# No need to edit below this line. Unless you really have to. :) ############ - -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 -Wall $(LLVM_FLAGS) -CFLAGS = -g -Wall -else -ifeq ($(build),debug) -CXXFLAGS = -g -Wall -DDEBUG=2 $(LLVM_FLAGS) -CFLAGS = -g -Wall -DDEBUG=2 -else -ifeq ($(build),release) -CXXFLAGS = -O3 -DNDEBUG -Wall $(LLVM_FLAGS) -CFLAGS = -O3 -DNDEBUG -Wall -else -CXXFLAGS = -g -Wall $(LLVM_FLAGS) -CFLAGS = -g -Wall -.PHONY: warn -warn: all - @echo "WARNING: Invalid build profile '$(build)'." - @echo "WARNING: Must be one of 'default', 'debug' and 'release'." - @echo "WARNING: Assuming 'default' profile." -endif -endif -endif - -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 \ -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) - -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 NEWS README TODO Makefile \ -$(SOURCE) $(EXTRA_SOURCE) w3centities.c pure.1 pure.xml pure.vim \ -$(examples) $(lib) $(tests) $(distlogs) - -.PHONY: all html dvi ps pdf clean realclean depend install uninstall dist \ -logs check - -# compilation - -all: pure - -pure: $(OBJECT) - $(CXX) -o $@ $(LDFLAGS) -rdynamic $(OBJECT) $(ALL_LIBS) - -pure.o: pure.cc - $(CXX) $(CXXFLAGS) -DVERSION='"$(version)"' -DPURELIB='"$(libdir)"' -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) 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) $(DESTDIR)$(mandir) - install -s pure $(DESTDIR)$(bindir)/pure - install -m 644 $(lib) $(DESTDIR)$(libdir) - install -m 644 pure.1 $(DESTDIR)$(mandir)/pure.1 - -uninstall: - rm -rf $(DESTDIR)$(bindir)/pure $(DESTDIR)$(libdir) $(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) - -# test logs, make check - -level=7 - -logs: $(logs) - -check: pure $(logs) - @ echo Running tests. - @ (export PURELIB=./lib; echo -n "prelude.pure: "; if ./pure -n -v$(level) lib/prelude.pure | 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 | diff -q - $$l > /dev/null; then echo passed; else echo FAILED; fi; done) - -test/prelude.log: lib/prelude.pure - PURELIB=./lib ./pure -n -v$(level) $< > $@ - -%.log: %.pure - PURELIB=./lib ./pure -v$(level) $< > $@ - -# 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 Copied: pure/releases/pure-0.2/Makefile (from rev 47, pure/trunk/Makefile) =================================================================== --- pure/releases/pure-0.2/Makefile (rev 0) +++ pure/releases/pure-0.2/Makefile 2008-05-04 09:30:54 UTC (rev 49) @@ -0,0 +1,217 @@ + +# 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.2 +dist = pure-$(version) + +prefix = /usr/local +bindir = $(prefix)/bin +libdir = $(prefix)/lib/pure +mandir = $(prefix)/share/man/man1 + +DESTDIR= + +# Compilation flags. We provide three different build profiles: + +# 'default' compiles with extra runtime checks and debugging information. +# 'debug' adds more debugging output (useful to debug the interpreter). +# 'release' optimizes for execution speed (release version). + +# The latter disables all runtime checks and debugging information and gives +# you *much* faster execution times (factor of 2 compared to the default flags +# on my Linux system running gcc 4.1, YMMV). It also takes a *long* time to +# compile runtime.cc, so be patient. ;-) + +# 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'.) + +build=default + +# No need to edit below this line. Unless you really have to. :) ############ + +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 -Wall $(LLVM_FLAGS) +CFLAGS = -g -Wall +else +ifeq ($(build),debug) +CXXFLAGS = -g -Wall -DDEBUG=2 $(LLVM_FLAGS) +CFLAGS = -g -Wall -DDEBUG=2 +else +ifeq ($(build),release) +CXXFLAGS = -O3 -DNDEBUG -Wall $(LLVM_FLAGS) +CFLAGS = -O3 -DNDEBUG -Wall +else +CXXFLAGS = -g -Wall $(LLVM_FLAGS) +CFLAGS = -g -Wall +.PHONY: warn +warn: all + @echo "WARNING: Invalid build profile '$(build)'." + @echo "WARNING: Must be one of 'default', 'debug' and 'release'." + @echo "WARNING: Assuming 'default' profile." +endif +endif +endif + +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 \ +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) + +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.1 pure.xml pure.vim \ +$(examples) $(lib) $(tests) $(distlogs) + +.PHONY: all html dvi ps pdf clean realclean depend install uninstall dist \ +distcheck cleanlogs logs check + +# compilation + +all: pure + +pure: $(OBJECT) + $(CXX) -o $@ $(LDFLAGS) -rdynamic $(OBJECT) $(ALL_LIBS) + +pure.o: pure.cc + $(CXX) $(CXXFLAGS) -DVERSION='"$(version)"' -DPURELIB='"$(libdir)"' -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) 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) $(DESTDIR)$(mandir) + install -s pure $(DESTDIR)$(bindir)/pure + install -m 644 $(lib) $(DESTDIR)$(libdir) + install -m 644 pure.1 $(DESTDIR)$(mandir)/pure.1 + +uninstall: + rm -rf $(DESTDIR)$(bindir)/pure $(DESTDIR)$(libdir) $(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 PURELIB=./lib; echo -n "prelude.pure: "; if ./pure -n -v$(level) lib/prelude.pure | 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 | diff -q - $$l > /dev/null; then echo passed; else echo FAILED; fi; done) + +test/prelude.log: lib/prelude.pure + PURELIB=./lib ./pure -n -v$(level) $< > $@ + +%.log: %.pure + PURELIB=./lib ./pure -v$(level) < $< > $@ + +# 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 Deleted: pure/releases/pure-0.2/NEWS =================================================================== --- pure/trunk/NEWS 2008-05-02 07:09:21 UTC (rev 29) +++ pure/releases/pure-0.2/NEWS 2008-05-04 09:30:54 UTC (rev 49) @@ -1,20 +0,0 @@ - -** Pure 0.1 2008-04-29 - -The much-awaited initial release. ;-) The interpreter is already fully -functional, but of course there's still a lot to be done (see the TODO file -for details). Please note that this is a preliminary, "beta" release, so -expect some bugs (and please report them to the author!). - -The Pure project is now hosted at SourceForge, see http://pure-lang.sf.net. A -mailing list should soon be available, too. - -See the INSTALLATION section in the README file to get up and running quickly. -After Pure is installed, read the Pure manual page (also available in various -formats from the Pure website) and have a look at the stuff in the examples -subdir, especially hello.pure, and review the standard library modules -(lib/*.pure). - -Enjoy! - -Albert Graef <Dr....@t-...> Copied: pure/releases/pure-0.2/NEWS (from rev 47, pure/trunk/NEWS) =================================================================== --- pure/releases/pure-0.2/NEWS (rev 0) +++ pure/releases/pure-0.2/NEWS 2008-05-04 09:30:54 UTC (rev 49) @@ -0,0 +1,37 @@ + +** Pure 0.2 2008-05-04 + +On the heels of Pure 0.1 comes the first bugfix release which addresses a +couple of bugs, misfeatures and Mac OSX compatibility issues, please refer to +the ChangeLog for details. I also added a more detailed INSTALL guide (thanks +are due to Eddie Rucker who wrote most of the new material in this guide) and +updated the manpage with a few minor corrections and some remarks about issues +raised on the Pure mailing list. + +Please note that there are still some issues with Pure on 64 bit systems (as +well as on Ubuntu running on PowerPC) which are still on my TODO list, these +will hopefully be fixed in the next release. + +Thanks to all who sent in bug reports and patches, in particular: Chris +Double, Tim Haynes, Eddie Rucker, Ryan Schmidt and Libor Spacek. (I hope I +didn't forget anyone.) + +** Pure 0.1 2008-04-29 + +The much-awaited initial release. ;-) The interpreter is already fully +functional, but of course there's still a lot to be done (see the TODO file +for details). Please note that this is a preliminary, "beta" release, so +expect some bugs (and please report them to the author!). + +The Pure project is now hosted at SourceForge, see http://pure-lang.sf.net. A +mailing list should soon be available, too. + +See the INSTALLATION section in the README file to get up and running quickly. +After Pure is installed, read the Pure manual page (also available in various +formats from the Pure website) and have a look at the stuff in the examples +subdir, especially hello.pure, and review the standard library modules +(lib/*.pure). + +Enjoy! + +Albert Graef <Dr....@t-...> Deleted: pure/releases/pure-0.2/README =================================================================== --- pure/trunk/README 2008-05-02 07:09:21 UTC (rev 29) +++ pure/releases/pure-0.2/README 2008-05-04 09:30:54 UTC (rev 49) @@ -1,111 +0,0 @@ - -PURE - The Pure programming language. - -Pure is a functional programming language based on term rewriting. It has a -modern syntax featuring curried function applications, lexical closures and -equational definitions with pattern matching, and thus is somewhat similar to -languages of the Haskell and ML variety. But Pure is also a very dynamic and -reflective language, and is more like Lisp in this respect. The interpreter -has an LLVM backend to do JIT compilation, hence programs run blazingly fast -and interfacing to C modules is easy. - -Please note that this is a preliminary, "beta" release, so please report bugs -to the author. Also have a look at the TODO file for stuff that still needs to -be done. - -WHERE TO GET IT - -You can find tarballs and the svn repository at http://pure-lang.sf.net. - -LICENSE - -GPL V3 or later. See the accompanying COPYING file for details. - -INSTALLATION - -The usual 'make && make install' should do the trick. (No 'configure' step -necessary.) This requires GNU make and g++. For other setups, you'll probably -have to fiddle with the Makefile and the sources. The sources should be pretty -portable, but the Makefile really needs GNU make right now. - -You'll also need LLVM (version 2.2 has been tested) for the compiler backend; -install it before compiling Pure. Instructions for installing LLVM can be -found at the LLVM website (http://llvm.org). - -By default, the 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.: - - 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). - -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 special libraries (LIBS) like libiconv on OSX. - -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, - - PURELIB=./lib ./pure - -will run the Pure interpreter with that setting in Bourne-compatible shells. - -For the release version, you should build the interpreter as follows: - - make build=release - -This disables all runtime checks and debugging information in the interpreter. -(Don't worry, your Pure programs will still be executed "safely" and shouldn't -segfault unless you run out of memory or there's a bug in the interpreter.) -The 'release' build gives you *much* faster execution times (factor of 2 -compared to the default flags on my Linux system running gcc 4.1, YMMV). It -also takes a *long* time to compile runtime.cc, but it's really worth the -wait, so please be patient. ;-) - -Please also have a look at the Makefile for details on the build and -installation process and other available targets and options. - -USING PURE - -Pure scripts are just ordinary text files, which can be created with any text -editor. The source directory contains Pure syntax highlighting files for Kate -and Vim (no Emacs mode yet, sorry). You might wish to install these into your -katepart/syntax and .vim/syntax directories, respectively. (For Vim you also -need to enable the syntax highlighting for .pure files; see the comments at -the beginning of pure.vim for details.) - -See the manpage ('man pure' after installation) for information on how to use -the interpreter and a brief description of the Pure language. Some example -programs can be found in the examples subdir in the sources; in particular, -have a look at the hello.pure program which will quickly give you an idea how -Pure programs look like. You should also browse the scripts in the lib -directory which contain the "built-in" definitions readily available when you -start up the Pure interpreter. - -This is currently all you get; more elaborate documentation of the Pure -language still needs to be written. But Pure is a really simple language; if -you have some experience using FPLs then you should be able to find your way -with the manpage and the provided examples. Of course, you can also post -questions to the Pure mailing list (see http://pure-lang.sf.net). - -Enjoy! :) - -AUTHOR - -Albert Graef -Dept. of Computer Music -Johannes Gutenberg University of Mainz -Germany - -<Dr....@t-...> -http://pure-lang.sf.net Copied: pure/releases/pure-0.2/README (from rev 38, pure/trunk/README) =================================================================== --- pure/releases/pure-0.2/README (rev 0) +++ pure/releases/pure-0.2/README 2008-05-04 09:30:54 UTC (rev 49) @@ -0,0 +1,68 @@ + +PURE - The Pure programming language. + +Pure is a functional programming language based on term rewriting. It has a +modern syntax featuring curried function applications, lexical closures and +equational definitions with pattern matching, and thus is somewhat similar to +languages of the Haskell and ML variety. But Pure is also a very dynamic and +reflective language, and is more like Lisp in this respect. The interpreter +has an LLVM backend to do JIT compilation, hence programs run blazingly fast +and interfacing to C modules is easy. + +Please note that this is a preliminary, "beta" release, so please report bugs +to the author. Also have a look at the TODO file for stuff that still needs to +be done. + +WHERE TO GET IT + +You can find tarballs and the svn repository at http://pure-lang.sf.net. + +LICENSE + +GPL V3 or later. See the accompanying COPYING file for details. + +INSTALLATION + +Please see the INSTALL file for detailed instructions. On most Unix-like +systems, the usual 'make && sudo make install' should do the trick. (No +'configure' step necessary.) This requires GNU make and g++. For other setups, +you'll probably have to fiddle with the Makefile and the sources. The sources +should be pretty portable, but the Makefile really needs GNU make right now. +You'll also need LLVM for the compiler backend (version 2.2 has been tested). +For your convenience, instructions for installing LLVM are also included in +the INSTALL file. + +USING PURE + +Pure scripts are just ordinary text files, which can be created with any text +editor. The source directory contains Pure syntax highlighting files for Kate +and Vim (no Emacs mode yet, sorry). You might wish to install these into your +katepart/syntax and .vim/syntax directories, respectively. (For Vim you also +need to enable the syntax highlighting for .pure files; see the comments at +the beginning of pure.vim for details.) + +See the manpage ('man pure' after installation) for information on how to use +the interpreter and a brief description of the Pure language. Some example +programs can be found in the examples subdir in the sources; in particular, +have a look at the hello.pure program which will quickly give you an idea how +Pure programs look like. You should also browse the scripts in the lib +directory which contain the "built-in" definitions readily available when you +start up the Pure interpreter. + +This is currently all you get; more elaborate documentation of the Pure +language still needs to be written. But Pure is a really simple language; if +you have some experience using FPLs then you should be able to find your way +with the manpage and the provided examples. Of course, you can also post +questions to the Pure mailing list (see http://pure-lang.sf.net). + +Enjoy! :) + +AUTHOR + +Albert Graef +Dept. of Computer Music +Johannes Gutenberg University of Mainz +Germany + +<Dr.Graef at t-online.de> +http://pure-lang.sf.net Deleted: pure/releases/pure-0.2/examples/hello.pure =================================================================== --- pure/trunk/examples/hello.pure 2008-05-02 07:09:21 UTC (rev 29) +++ pure/releases/pure-0.2/examples/hello.pure 2008-05-04 09:30:54 UTC (rev 49) @@ -1,266 +0,0 @@ - -/* This is a quick tour of Pure, starting from simple numeric calculations, - continuing with list processing, and finishing off with the recursive - manipulation of tree structures. Along the way you can see all major Pure - features at work: equational definitions, conditional expressions, - anonymous functions (lambdas), global and local variable bindings, local - function definitions, list comprehensions, access to external C functions, - and even doing some I/O with the system module. We also sketch out various - important programming techniques and tricks of the trade. So working - through these examples you should get a pretty good idea how Pure programs - look like. */ - -/* USAGE: You can run this script as 'pure hello.pure' to have it print a - friendly greeting. Or you can pipe it into the Pure interpreter with the - command 'pure < hello.pure' to print all computed results on stdout. But - usually you'll just want to run the script interactively in the Pure - interpreter, which can be done with 'pure -i hello.pure'. Or start up the - interpreter with the 'pure' command and at its command prompt enter: - - run hello.pure - - Note that the interactive input language of the interpreter is the full - Pure language, so you can also enter any of the definitions here directly - at the interpreter's prompt. In an interactive session, the interpreter - also understands some additional commands useful for interactive usage; - type 'help' in the interpreter to learn more about this. */ - -/* Let's start with the traditional hello world program. In Pure we need the - system module to do I/O, so we import that first. */ - -using system; -puts "Hello, world!"; - -/* Ok, with that out of the way, let's get on to more serious things. Most of - the time you'll be defining functions to do some calculations. As you'd - rightfully expect from a functional language, Pure makes that quite easy: */ - -// Just a simple function which squares its argument x. -square x = x*x; - -// You can evaluate things by just typing the expression, terminated with ';'. -square 5; square (a+b); - -// You can also bind a global ("free") variable symbol to a value. -let x = square 5; x; - -// Pattern matching definition with 'let'. -let x, y = square x, square (x+2); x; y; - -/* Variations on a theme: The factorial. This illustrates various different - ways to define a simple recursive function. */ - -// Guarded rules. - -fact1 n = n*fact1 (n-1) if n>0; - = 1 otherwise; - -let x = fact1 10; - -// This is essentially the same, but uses a 'case' expression. - -fact2 n = case n of - n = n*fact2 (n-1) if n>0; - = 1 otherwise; - end; - -// Using pattern matching (note the constant pattern on the lhs of eqn. #1). - -fact3 0 = 1; -fact3 n = n*fact3 (n-1) if n>0; - -// Using 'if-then-else'. - -fact4 n = if n>0 then n*fact4 (n-1) else 1; - -// Using lambda ("pointless style"). - -fact5 = \n -> if n>0 then n*fact5 (n-1) else 1; - -// Using fixed points. This technique allows you to define a recursive -// function without referring to the name of the function in its body. See -// http://en.wikipedia.org/wiki/Fixed_point_combinator for an explanation. - -fact6 = Z (\f n -> if n<=0 then 1 else n*f (n-1)); -Z = \f -> (\x -> f (\y -> x x y)) (\x -> f (\y -> x x y)); - -// These should all evaluate to the same list of the first 10 factorials. - -map fact1 (1..10); -map fact2 (1..10); -map fact3 (1..10); -map fact4 (1..10); -map fact5 (1..10); -map fact6 (1..10); - -/* Various different implementations of the Fibonacci function. Shows the use - of 'when' to perform local variable bindings and 'with' to define local - functions, and how to make a definition tail-recursive so that it runs in - constant stack space. */ - -// Naive O(fib n) implementation. Try fib1 35 to see how slow it is. - -fib1 0 = 0; -fib1 1 = 1; -fib1 n = fib1 (n-2) + fib1 (n-1) if n>1; - -// O(n) implementation, using a local function which generates the Fibonacci -// numbers in pairs. Much faster (try fib2 35 to see the change). - -fib2 n = a when a, b = fibs n end - with fibs n = 0, 1 if n<=0; - = b, a+b when a, b = fibs (n-1) end - otherwise; - end; - -// Tail-recursive version, with an "accumulating parameter". This one runs in -// constant stack space. It also uses bigints so that the arithmetically -// correct values are computed for large n. - -fib3 n = a when a, b = fibs (0, 1) n end - with fibs (a, b) n = a, b if n<=0; - = fibs (b, bigint a+b) (n-1) otherwise; - end; - -map fib1 (1..10); -map fib2 (1..10); -map fib3 (1..50); - -/* Ok, enough numbers already. Let's play around with lists! First, the - obligatory quicksort function. This isn't really the fastest version of the - algorithm, but it shows off the elegance of Pure and teaches us several - important lessons: How to perform pattern-matching on structured data; how - to deal with function arguments (the order predicate p in this case); how - to define local "convenience operators" to make definitions more readable - ('<' and '>=' in this example, which we redefine in terms of the order - predicate p); and how to generate lists using list comprehensions. All in - the same little 2.5-liner. ;-) */ - -qsort p [] = []; -qsort p (x:xs) = qsort p [l; l = xs; l<x] + (x : qsort p [r; r = xs; r>=x]) - with x<y = p x y; x>=y = not p x y end; - -qsort (<) (1..20); // ascending sort, no-op in this case -qsort (>) (1..20); // descending sort, reverses the list in this case - -/* Let's now test our quicksort with random inputs. This shows how quickly and - painlessly you can access functions from the C library in Pure (the random - number generator 'rand' in this example). */ - -extern int rand(); - -qsort (<) [rand; i = 1..20]; // sort 20 random numbers in ascending order -qsort (>) [rand; i = 1..20]; // sort 20 random numbers in descending order - -/* Erathosthenes' classical prime sieve. Another example showing the beauty - and usefulness of list comprehensions. */ - -primes n = sieve (2..n) with - sieve [] = []; - sieve (p:qs) = p : sieve [q; q = qs; q mod p]; -end; - -primes 100; - -/* The classical n queens problem: Compute all placements of n queens on an - n x n board so that no two queens hold each other in check. This algorithm - demonstrates how you can use list comprehensions to organize backtracking - searches. */ - -queens n = search n 1 [] -with - search n i p = [reverse p] if i>n; - = cat [search n (i+1) ((i,j):p); j = 1..n; safe (i,j) p]; - safe (i,j) p = not any (check (i,j)) p; - check (i1,j1) (i2,j2) - = i1==i2 || j1==j2 || i1+j1==i2+j2 || i1-j1==i2-j2; -end; - -/* The following version uses catch/throw for non-local value returns, in - order to compute only the first solution. If no solution is found, () is - returned. */ - -queens1 n = catch reverse (search n 1 []) -with - search n i p = throw p if i>n; - = void [search n (i+1) ((i,j):p); j = 1..n; safe (i,j) p]; - safe (i,j) p = not any (check (i,j)) p; - check (i1,j1) (i2,j2) - = i1==i2 || j1==j2 || i1+j1==i2+j2 || i1-j1==i2-j2; -end; - -/* Our final version makes best use of tail recursion to avoid the - construction of intermediate list values and thereby makes the algorithm - run a little faster and in less space. It's also slightly more tricky. In - particular, have a look at the guard in eqn. #2 of the search function - which first recurses on solutions which place the ith queen into column j - (after checking that it's safe there) and then backs out (makes the guard - fail) to pursue alternative solution paths in eqn. #3. */ - -queens2 n = catch reverse (search n 1 1 []) -with - search n i j p - = throw p if i>n; - = () if safe (i,j) p && - (0 when _ = search n (i+1) 1 ((i,j):p) end); - = search n i (j+1) p if j<n; - = () otherwise; - safe (i,j) p = not any (check (i,j)) p; - check (i1,j1) (i2,j2) - = i1==i2 || j1==j2 || i1+j1==i2+j2 || i1-j1==i2-j2; -end; - -// The first expression here evaluates to the number of solutions for the 8 -// queens problem. The other two expressions should both yield the same first -// solution. -#queens 8; -queens1 8; -queens2 8; - -/* Here's how you can print all solutions in a nice format, using some of the - I/O functions from the system module. */ - -print_queens ps = do (puts.join " ".map (sprintf "%d,%d")) ps; - -// Try this when running interactively: -//print_queens (queens 8); - -/* Lists are all good and fine, but what about other, more complicated kinds - of data? Luckily, as a term rewriting language Pure is well-suited to - process any kind of tree-structured data. We only discuss a simple example - here, but using similar, more elaborate techniques like AVL trees, it is - possible to implement almost any kind of container data structure in an - efficient way. - - So let's see how we can implement simple binary search trees in Pure. These - are represented using the constant symbol 'nil' (which denotes the empty - tree) and the constructor application 'bin x L R', where x denotes the - value at the top of the tree, and L and R are the left and right subtrees, - respectively. In Pure, constructor symbols like 'bin' don't have to be - declared, since they are just ordinary function symbols without any - defining equations, but we do need to declare the 'nil' symbol so that the - compiler knows that this symbol denotes a constant and doesn't mistake it - for a variable when it occurs on the left-hand side of an equation. */ - -nullary nil; - -/* The tree insertion operation. This assumes that the tree elements can be - compared using '<'. */ - -insert nil y = bin y nil nil; -insert (bin x L R) y = bin x (insert L y) R if y<x; - = bin x L (insert R y) otherwise; - -/* Create a tree from a list of elements. */ - -bintree xs = foldl insert nil xs; - -/* Do an inorder traversal of the tree to obtain the (now sorted) list of - elements. */ - -members nil = []; -members (bin x L R) = members L + (x:members R); - -// A random example: - -let xs = [rand; i = 1..20]; let T = bintree xs; xs; T; members T; Copied: pure/releases/pure-0.2/examples/hello.pure (from rev 46, pure/trunk/examples/hello.pure) =================================================================== --- pure/releases/pure-0.2/examples/hello.pure (rev 0) +++ pure/releases/pure-0.2/examples/hello.pure 2008-05-04 09:30:54 UTC (rev 49) @@ -0,0 +1,266 @@ + +/* This is a quick tour of Pure, starting from simple numeric calculations, + continuing with list processing, and finishing off with the recursive + manipulation of tree structures. Along the way you can see all major Pure + features at work: equational definitions, conditional expressions, + anonymous functions (lambdas), global and local variable bindings, local + function definitions, list comprehensions, access to external C functions, + and even doing some I/O with the system module. We also sketch out various + important programming techniques and tricks of the trade. So working + through these examples you should get a pretty good idea how Pure programs + look like. */ + +/* USAGE: You can run this script as 'pure hello.pure' to have it print a + friendly greeting. Or you can pipe it into the Pure interpreter with the + command 'pure < hello.pure' to print all computed results on stdout. But + usually you'll just want to run the script interactively in the Pure + interpreter, which can be done with 'pure -i hello.pure'. Or start up the + interpreter with the 'pure' command and at its command prompt enter: + + run hello.pure + + Note that the interactive input language of the interpreter is the full + Pure language, so you can also enter any of the definitions here directly + at the interpreter's prompt. In an interactive session, the interpreter + also understands some additional commands useful for interactive usage; + type 'help' in the interpreter to learn more about this. */ + +/* Let's start with the traditional hello world program. In Pure we need the + system module to do I/O, so we import that first. */ + +using system; +puts "Hello, world!"; + +/* Ok, with that out of the way, let's get on to more serious things. Most of + the time you'll be defining functions to do some calculations. As you'd + rightfully expect from a functional language, Pure makes that quite easy: */ + +// Just a simple function which squares its argument x. +square x = x*x; + +// You can evaluate things by just typing the expression, terminated with ';'. +square 5; square (a+b); + +// You can also bind a global ("free") variable symbol to a value. +let x = square 5; x; + +// Pattern matching definition with 'let'. +let x, y = square x, square (x+2); x; y; + +/* Variations on a theme: The factorial. This illustrates various different + ways to define a simple recursive function. */ + +// Guarded rules. + +fact1 n = n*fact1 (n-1) if n>0; + = 1 otherwise; + +let x = fact1 10; + +// This is essentially the same, but uses a 'case' expression. + +fact2 n = case n of + n = n*fact2 (n-1) if n>0; + = 1 otherwise; + end; + +// Using pattern matching (note the constant pattern on the lhs of eqn. #1). + +fact3 0 = 1; +fact3 n = n*fact3 (n-1) if n>0; + +// Using 'if-then-else'. + +fact4 n = if n>0 then n*fact4 (n-1) else 1; + +// Using lambda ("pointless style"). + +fact5 = \n -> if n>0 then n*fact5 (n-1) else 1; + +// Using fixed points. This technique allows you to define a recursive +// function without referring to the name of the function in its body. See +// http://en.wikipedia.org/wiki/Fixed_point_combinator for an explanation. + +fact6 = Z (\f n -> if n<=0 then 1 else n*f (n-1)); +Z = \f -> (\x -> f (\y -> x x y)) (\x -> f (\y -> x x y)); + +// These should all evaluate to the same list of the first 10 factorials. + +map fact1 (1..10); +map fact2 (1..10); +map fact3 (1..10); +map fact4 (1..10); +map fact5 (1..10); +map fact6 (1..10); + +/* Various different implementations of the Fibonacci function. Shows the use + of 'when' to perform local variable bindings and 'with' to define local + functions, and how to make a definition tail-recursive so that it runs in + constant stack space. */ + +// Naive O(fib n) implementation. Try fib1 35 to see how slow it is. + +fib1 0 = 0; +fib1 1 = 1; +fib1 n = fib1 (n-2) + fib1 (n-1) if n>1; + +// O(n) implementation, using a local function which generates the Fibonacci +// numbers in pairs. Much faster (try fib2 35 to see the change). + +fib2 n = a when a, b = fibs n end + with fibs n = 0, 1 if n<=0; + = b, a+b when a, b = fibs (n-1) end + otherwise; + end; + +// Tail-recursive version, with an "accumulating parameter". This one runs in +// constant stack space. It also uses bigints so that the arithmetically +// correct values are computed for large n. + +fib3 n = a when a, b = fibs (0G, 1G) n end + with fibs (a, b) n = a, b if n<=0; + = fibs (b, a+b) (n-1) otherwise; + end; + +map fib1 (1..10); +map fib2 (1..10); +map fib3 (1..50); + +/* Ok, enough numbers already. Let's play around with lists! First, the + obligatory quicksort function. This isn't really the fastest version of the + algorithm, but it shows off the elegance of Pure and teaches us several + important lessons: How to perform pattern-matching on structured data; how + to deal with function arguments (the order predicate p in this case); how + to define local "convenience operators" to make definitions more readable + ('<' and '>=' in this example, which we redefine in terms of the order + predicate p); and how to generate lists using list comprehensions. All in + the same little 2.5-liner. ;-) */ + +qsort p [] = []; +qsort p (x:xs) = qsort p [l; l = xs; l<x] + (x : qsort p [r; r = xs; r>=x]) + with x<y = p x y; x>=y = not p x y end; + +qsort (<) (1..20); // ascending sort, no-op in this case +qsort (>) (1..20); // descending sort, reverses the list in this case + +/* Let's now test our quicksort with random inputs. This shows how quickly and + painlessly you can access functions from the C library in Pure (the random + number generator 'rand' in this example). */ + +extern int rand(); + +qsort (<) [rand; i = 1..20]; // sort 20 random numbers in ascending order +qsort (>) [rand; i = 1..20]; // sort 20 random numbers in descending order + +/* Erathosthenes' classical prime sieve. Another example showing the beauty + and usefulness of list comprehensions. */ + +primes n = sieve (2..n) with + sieve [] = []; + sieve (p:qs) = p : sieve [q; q = qs; q mod p]; +end; + +primes 100; + +/* The classical n queens problem: Compute all placements of n queens on an + n x n board so that no two queens hold each other in check. This algorithm + demonstrates how you can use list comprehensions to organize backtracking + searches. */ + +queens n = search n 1 [] +with + search n i p = [reverse p] if i>n; + = cat [search n (i+1) ((i,j):p); j = 1..n; safe (i,j) p]; + safe (i,j) p = not any (check (i,j)) p; + check (i1,j1) (i2,j2) + = i1==i2 || j1==j2 || i1+j1==i2+j2 || i1-j1==i2-j2; +end; + +/* The following version uses catch/throw for non-local value returns, in + order to compute only the first solution. If no solution is found, () is + returned. */ + +queens1 n = catch reverse (search n 1 []) +with + search n i p = throw p if i>n; + = void [search n (i+1) ((i,j):p)... [truncated message content] |
From: <ag...@us...> - 2008-05-04 09:28:02
|
Revision: 48 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=48&view=rev Author: agraef Date: 2008-05-04 02:28:09 -0700 (Sun, 04 May 2008) Log Message: ----------- Added subdirectory for release snapshots. Added Paths: ----------- pure/releases/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-04 09:22:37
|
Revision: 47 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=47&view=rev Author: agraef Date: 2008-05-04 02:22:44 -0700 (Sun, 04 May 2008) Log Message: ----------- Release 0.2. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/Makefile pure/trunk/NEWS Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-04 08:55:48 UTC (rev 46) +++ pure/trunk/ChangeLog 2008-05-04 09:22:44 UTC (rev 47) @@ -1,5 +1,7 @@ 2008-05-04 Albert Graef <Dr....@t-...> + * 0.2 release. + * lexer.ll, printer.cc: Add an explicit notation for big integers. Any integer immediately followed by the uppercase letter "G" (as in "biG" or "GMP") will now always be interpreted as a @@ -84,6 +86,10 @@ * lexer.ll, parser.yy: Fixes for compatibility with newer flex and bison versions. Reported by Eddie Rucker. +2008-04-29 Albert Graef <Dr....@t-...> + + * 0.1 release. + 2008-04-28 Albert Graef <Dr....@t-...> * examples/symbolic.pure: Add symbolic evaluation example. This is Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-04 08:55:48 UTC (rev 46) +++ pure/trunk/Makefile 2008-05-04 09:22:44 UTC (rev 47) @@ -9,7 +9,7 @@ # 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.1 +version = 0.2 dist = pure-$(version) prefix = /usr/local @@ -85,7 +85,7 @@ $(examples) $(lib) $(tests) $(distlogs) .PHONY: all html dvi ps pdf clean realclean depend install uninstall dist \ -logs check +distcheck cleanlogs logs check # compilation @@ -162,6 +162,11 @@ 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 Modified: pure/trunk/NEWS =================================================================== --- pure/trunk/NEWS 2008-05-04 08:55:48 UTC (rev 46) +++ pure/trunk/NEWS 2008-05-04 09:22:44 UTC (rev 47) @@ -1,4 +1,21 @@ +** Pure 0.2 2008-05-04 + +On the heels of Pure 0.1 comes the first bugfix release which addresses a +couple of bugs, misfeatures and Mac OSX compatibility issues, please refer to +the ChangeLog for details. I also added a more detailed INSTALL guide (thanks +are due to Eddie Rucker who wrote most of the new material in this guide) and +updated the manpage with a few minor corrections and some remarks about issues +raised on the Pure mailing list. + +Please note that there are still some issues with Pure on 64 bit systems (as +well as on Ubuntu running on PowerPC) which are still on my TODO list, these +will hopefully be fixed in the next release. + +Thanks to all who sent in bug reports and patches, in particular: Chris +Double, Tim Haynes, Eddie Rucker, Ryan Schmidt and Libor Spacek. (I hope I +didn't forget anyone.) + ** Pure 0.1 2008-04-29 The much-awaited initial release. ;-) The interpreter is already fully This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-04 08:55:46
|
Revision: 46 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=46&view=rev Author: agraef Date: 2008-05-04 01:55:48 -0700 (Sun, 04 May 2008) Log Message: ----------- Make use of new bigint notation. Modified Paths: -------------- pure/trunk/examples/hello.pure Modified: pure/trunk/examples/hello.pure =================================================================== --- pure/trunk/examples/hello.pure 2008-05-04 07:10:41 UTC (rev 45) +++ pure/trunk/examples/hello.pure 2008-05-04 08:55:48 UTC (rev 46) @@ -117,9 +117,9 @@ // constant stack space. It also uses bigints so that the arithmetically // correct values are computed for large n. -fib3 n = a when a, b = fibs (0, 1) n end +fib3 n = a when a, b = fibs (0G, 1G) n end with fibs (a, b) n = a, b if n<=0; - = fibs (b, bigint a+b) (n-1) otherwise; + = fibs (b, a+b) (n-1) otherwise; end; map fib1 (1..10); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-04 07:10:34
|
Revision: 45 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=45&view=rev Author: agraef Date: 2008-05-04 00:10:41 -0700 (Sun, 04 May 2008) Log Message: ----------- Bugfix in parsing of bigint constants. Modified Paths: -------------- pure/trunk/lexer.ll Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-05-04 07:09:25 UTC (rev 44) +++ pure/trunk/lexer.ll 2008-05-04 07:10:41 UTC (rev 45) @@ -607,7 +607,9 @@ {int}G { mpz_t *z = (mpz_t*)malloc(sizeof(mpz_t)); mpz_init(*z); + yytext[yyleng-1] = 0; mpz_set_str(*z, yytext, 0); + yytext[yyleng-1] = 'G'; yylval->zval = z; return token::BIGINT; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-04 07:09:18
|
Revision: 44 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=44&view=rev Author: agraef Date: 2008-05-04 00:09:25 -0700 (Sun, 04 May 2008) Log Message: ----------- Updated manpage. Modified Paths: -------------- pure/trunk/pure.1 Modified: pure/trunk/pure.1 =================================================================== --- pure/trunk/pure.1 2008-05-03 23:33:41 UTC (rev 43) +++ pure/trunk/pure.1 2008-05-04 07:09:25 UTC (rev 44) @@ -187,17 +187,25 @@ .PP Expressions consist of the following elements: .TP -.B Constants: \fR4711, 1.2e-3, \(dqHello,\ world!\en\(dq +.B Constants: \fR4711, 4711G, 1.2e-3, \(dqHello,\ world!\en\(dq The usual C'ish notations for integers (decimal, hexadecimal, octal), floating -point values and double-quoted strings are all provided. Actually, in Pure -character escapes have a more flexible syntax borrowed from the author's Q -language, which provides notations to specify any Unicode character. In -particular, the notation +point values and double-quoted strings are all provided, although the Pure +syntax differs in some minor ways, as discussed in the following. First, there +is a special notation for denoting bigints. Note that an integer constant that +is too large to fit into a machine integer will be interpreted as a bigint +automatically. Moreover, an integer literal immediately followed by the +uppercase letter ``G'' (mnemonic: ``biG'' or ``GMP'' integer) will always be +interpreted as a bigint constant, even if it fits into a machine integer. This +``big G'' notation is also used when printing bigint constants. Second, +character escapes in Pure strings have a more flexible syntax borrowed from +the author's Q language, which provides notations to specify any Unicode +character. In particular, the notation .BR \e\fIn\fP , -where \fIn\fP is an integer written in decimal, hexadecimal or octal notation, -denotes the Unicode character (code point) #\fIn\fP. Since these escapes may -consist of a varying number of digits, parentheses may be used for -disambiguation purposes; thus, e.g. +where \fIn\fP is an integer literal written in decimal (no prefix), +hexadecimal (`0x' prefix) or octal (`0' prefix) notation, denotes the Unicode +character (code point) #\fIn\fP. Since these escapes may consist of a varying +number of digits, parentheses may be used for disambiguation purposes; thus, +e.g. .B \(dq\e(123)4\(dq denotes character #123 followed by the character `4'. The usual C-like escapes for special non-printable characters such as @@ -208,6 +216,8 @@ where \fIname\fP is any of the XML single character entity names specified in the ``XML Entity definitions for Characters'', see .IR http://www.w3.org/TR/xml-entity-names/ . +Thus, e.g., \(dq\e©\(dq denotes the copyright character (code point +0x000A9). .TP .B Function and variable symbols: \fRfoo, foo_bar, BAR, bar2 These consist of the usual sequence of ASCII letters (including the @@ -983,39 +993,48 @@ > \fBunderride\fP .fi .SH CAVEATS AND NOTES +.B Debugging. There's no symbolic debugger yet. So .BR printf (3) (available in the .B system standard library module) should be your friend. ;-) .PP +.B Tuples and parentheses. Please note that parentheses are really only used to group expressions and are \fInot\fP part of the tuple syntax; tuples are in fact not really part of the Pure language at all, but are implemented in the prelude. As you can see there, the pairing operator `,' used to construct tuples is (right-)associative. We call these the ``poor man's tuples'' since they are always flat and thus there are no nested tuples (if you need this then you -should use lists instead). This also implies than an expression like +should use lists instead). This also implies that an expression like [(1,2),(3,4)] is in fact exactly the same as [1,2,3,4]. If you want to denote 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 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 binding, or pattern-matching lambda expression, is always interpreted as a -literal function symbol (not a variable). This implies that you cannot bind -the ``function'' component of a function application to a variable, and thus -you cannot directly define a generic function which operates on arbitrary -function applications. As a remedy, the prelude provides three operations to -handle such objects: +literal function symbol (not a variable). This implies that you cannot match +the ``function'' component of an application against a variable, and thus you +cannot directly define a generic function which operates on arbitrary function +applications. As a remedy, the prelude provides three operations to handle +such objects: .BR applp , a predicate which checks whether a given expression is a function application, and .B fun and .BR arg , -which determine the function and argument parts of such an expression. +which determine the function and argument parts of such an expression, +respectively. (This may seem a little awkward, but as a matter of fact the +``head = function'' rule is quite convenient since it covers the common cases +without forcing the programmer to declare ``constructor'' symbols (except +nullary symbols). Also note that in standard term rewriting you do not have +rules parameterizing over the head symbol of a function application either.) .PP +.B Numeric types. If possible, you should always decorate numeric variables on the left-hand sides of function definitions with the appropriate type tags, like .B ::int @@ -1024,7 +1043,7 @@ This often helps the compiler to generate better code and makes your programs run faster. .PP -Talking about the built-in integer types, please note that +Talking about the built-in types, please note that .B int (the machine integers) and .B bigint @@ -1032,12 +1051,10 @@ you want to define a function operating on both kinds of integers, you'll also have to provide equations for both. This also applies to equations matching against constant values of these types; in particular, a small integer -constant like `0' only matches machine integers, not bigints. Unfortunately, -Pure currently doesn't provide any special notation for ``small bigints'', so -that there's no way to match a bigint against a small integer constant on the -left-hand side of an equation; instead you have to use explicit comparisons, -using guarded equations. +constant like `0' only matches machine integers, not bigints; for the latter +you'll have to use the ``big G'' notation `0G'. .PP +.B External C functions. The interpreter always takes your .B extern declarations of C routines at face value. It will not go and read any C header @@ -1054,6 +1071,7 @@ routines and data structures which do all the checks necessary to ensure that only the right kind of data is passed to C routines. .PP +.B Stack size and tail recursion. Pure programs may need a considerable amount of stack space to handle recursive function calls, and the interpreter itself also takes its toll. So you may have to configure your system accordingly (8 MB of stack space is This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-03 23:33:33
|
Revision: 43 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=43&view=rev Author: agraef Date: 2008-05-03 16:33:41 -0700 (Sat, 03 May 2008) Log Message: ----------- Add an explicit notation for big integers. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/lexer.ll pure/trunk/printer.cc pure/trunk/test/test1.log Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-03 23:01:13 UTC (rev 42) +++ pure/trunk/ChangeLog 2008-05-03 23:33:41 UTC (rev 43) @@ -1,5 +1,13 @@ 2008-05-04 Albert Graef <Dr....@t-...> + * lexer.ll, printer.cc: Add an explicit notation for big + integers. Any integer immediately followed by the uppercase letter + "G" (as in "biG" or "GMP") will now always be interpreted as a + bigint constant, even if it fits into a machine integer. This + notation is also used when printing bigint constants. This change + was necessary to make it possible to write rules matching against + "small bigint" constants. + * lib/primitives.pure: Added operations to recognize function applications and extract the function and argument parts, implemented in runtime.cc. Note that these operations can't be Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-05-03 23:01:13 UTC (rev 42) +++ pure/trunk/lexer.ll 2008-05-03 23:33:41 UTC (rev 43) @@ -604,6 +604,13 @@ return token::BIGINT; } } +{int}G { + mpz_t *z = (mpz_t*)malloc(sizeof(mpz_t)); + mpz_init(*z); + mpz_set_str(*z, yytext, 0); + yylval->zval = z; + return token::BIGINT; +} {float} yylval->dval = my_strtod(yytext, NULL); return(token::DBL); \"{str}\" { char *msg; Modified: pure/trunk/printer.cc =================================================================== --- pure/trunk/printer.cc 2008-05-03 23:01:13 UTC (rev 42) +++ pure/trunk/printer.cc 2008-05-03 23:33:41 UTC (rev 43) @@ -202,7 +202,7 @@ return os << x.ival(); case EXPR::BIGINT: { char *s = mpz_get_str(NULL, 10, x.zval()); - os << s; free(s); + os << s << "G"; free(s); return os; } case EXPR::DBL: { @@ -439,7 +439,7 @@ return os << " state " << tr.st->s << endl; case EXPR::BIGINT: { char *s = mpz_get_str(NULL, 10, tr.z); - os << "\t" << s; + os << "\t" << s << "G"; print_ttag(os, tr.ttag); os << " state " << tr.st->s << endl; free(s); @@ -621,7 +621,7 @@ return os << x->data.i; case EXPR::BIGINT: { char *s = mpz_get_str(NULL, 10, x->data.z); - os << s; free(s); + os << s << "G"; free(s); return os; } case EXPR::DBL: { Modified: pure/trunk/test/test1.log =================================================================== --- pure/trunk/test/test1.log 2008-05-03 23:01:13 UTC (rev 42) +++ pure/trunk/test/test1.log 2008-05-03 23:33:41 UTC (rev 43) @@ -92,7 +92,7 @@ state 2: #1 #2 } fact 50; -30414093201713378043612608166064768844377641568960512000000000000 +30414093201713378043612608166064768844377641568960512000000000000G fib1 0 = 0; fib1 1 = 1; fib1 n/*0:1*/ = fib1 (n/*0:1*/-2)+fib1 (n/*0:1*/-1) if n/*0:1*/>1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-03 23:01:05
|
Revision: 42 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=42&view=rev Author: agraef Date: 2008-05-03 16:01:13 -0700 (Sat, 03 May 2008) Log Message: ----------- Updated manpage. Modified Paths: -------------- pure/trunk/pure.1 Modified: pure/trunk/pure.1 =================================================================== --- pure/trunk/pure.1 2008-05-03 22:05:43 UTC (rev 41) +++ pure/trunk/pure.1 2008-05-03 23:01:13 UTC (rev 42) @@ -989,6 +989,33 @@ .B system standard library module) should be your friend. ;-) .PP +Please note that parentheses are really only used to group expressions and are +\fInot\fP part of the tuple syntax; tuples are in fact not really part of the +Pure language at all, but are implemented in the prelude. As you can see +there, the pairing operator `,' used to construct tuples is +(right-)associative. We call these the ``poor man's tuples'' since they are +always flat and thus there are no nested tuples (if you need this then you +should use lists instead). This also implies than an expression like +[(1,2),(3,4)] is in fact exactly the same as [1,2,3,4]. If you want to denote +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 +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 +binding, or pattern-matching lambda expression, is always interpreted as a +literal function symbol (not a variable). This implies that you cannot bind +the ``function'' component of a function application to a variable, and thus +you cannot directly define a generic function which operates on arbitrary +function applications. As a remedy, the prelude provides three operations to +handle such objects: +.BR applp , +a predicate which checks whether a given expression is a function application, +and +.B fun +and +.BR arg , +which determine the function and argument parts of such an expression. +.PP If possible, you should always decorate numeric variables on the left-hand sides of function definitions with the appropriate type tags, like .B ::int @@ -997,6 +1024,20 @@ This often helps the compiler to generate better code and makes your programs run faster. .PP +Talking about the built-in integer types, please note that +.B int +(the machine integers) and +.B bigint +(the GMP ``big'' integers) are really different kinds of objects, and thus if +you want to define a function operating on both kinds of integers, you'll also +have to provide equations for both. This also applies to equations matching +against constant values of these types; in particular, a small integer +constant like `0' only matches machine integers, not bigints. Unfortunately, +Pure currently doesn't provide any special notation for ``small bigints'', so +that there's no way to match a bigint against a small integer constant on the +left-hand side of an equation; instead you have to use explicit comparisons, +using guarded equations. +.PP The interpreter always takes your .B extern declarations of C routines at face value. It will not go and read any C header @@ -1004,15 +1045,14 @@ you have to be careful to give the proper declarations, otherwise your program will probably segfault calling the function. .PP -Talking about the C interface, you also have to be careful when passing -generic pointer values to external C routines, since currently there is no -type checking for these; any pointer type other than char* and expr* is -effectively treated as void*. This considerably simplifies lowlevel -programming and interfacing to C libraries, but also makes it very easy to -have your program segfault all over the place! Therefore it is highly -recommended that you wrap your lowlevel code in Pure routines and data -structures which do all the checks necessary to ensure that only the right -kind of data is passed to C routines. +You also have to be careful when passing generic pointer values to external C +routines, since currently there is no type checking for these; any pointer +type other than char* and expr* is effectively treated as void*. This +considerably simplifies lowlevel programming and interfacing to C libraries, +but also makes it very easy to have your program segfault all over the place! +Therefore it is highly recommended that you wrap your lowlevel code in Pure +routines and data structures which do all the checks necessary to ensure that +only the right kind of data is passed to C routines. .PP Pure programs may need a considerable amount of stack space to handle recursive function calls, and the interpreter itself also takes its toll. So @@ -1025,8 +1065,8 @@ limit. The value of .B PURE_STACK should be the maximum stack size in kilobytes. Please note that this is only -an advisory limit but does \fInot\fP change the program's physical stack size. -Your operating system should supply you with a command such as +an advisory limit which does \fInot\fP change the program's physical stack +size. Your operating system should supply you with a command such as .BR ulimit (1) to set the real process stack size. Also note that this feature isn't 100% foolproof yet, since for performance reasons the stack will be checked only on This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-03 22:05:38
|
Revision: 41 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=41&view=rev Author: agraef Date: 2008-05-03 15:05:43 -0700 (Sat, 03 May 2008) Log Message: ----------- Updated ChangeLog Modified Paths: -------------- pure/trunk/ChangeLog Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-03 22:02:26 UTC (rev 40) +++ pure/trunk/ChangeLog 2008-05-03 22:05:43 UTC (rev 41) @@ -1,3 +1,12 @@ +2008-05-04 Albert Graef <Dr....@t-...> + + * lib/primitives.pure: Added operations to recognize function + applications and extract the function and argument parts, + implemented in runtime.cc. Note that these operations can't be + defined in Pure because of the "head is function" rule which means + that in a pattern of the form f x, f is always a literal function + symbol and not a variable. + 2008-05-03 Albert Graef <Dr....@t-...> * README: Moved installation instructions to a separate INSTALL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-03 22:02:19
|
Revision: 40 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=40&view=rev Author: agraef Date: 2008-05-03 15:02:26 -0700 (Sat, 03 May 2008) Log Message: ----------- Add operations to check for and deconstruct function applications. Modified Paths: -------------- pure/trunk/lib/primitives.pure pure/trunk/runtime.cc pure/trunk/runtime.h Modified: pure/trunk/lib/primitives.pure =================================================================== --- pure/trunk/lib/primitives.pure 2008-05-03 21:06:12 UTC (rev 39) +++ pure/trunk/lib/primitives.pure 2008-05-03 22:02:26 UTC (rev 40) @@ -38,8 +38,11 @@ stringp x = case x of _::string = 1; _ = 0 end; pointerp x = case x of _::pointer = 1; _ = 0 end; -/* Predicates to check for proper lists and tuples. */ +/* Predicates to check for function applications and proper lists and + tuples. */ +extern bool applp(expr*); + listp [] = 1; listp (x:xs) = listp xs; listp _ = 0 otherwise; @@ -48,6 +51,10 @@ tuplep (x,xs) = 1; tuplep _ = 0 otherwise; +/* Operations to return the function and the argument in an application. */ + +extern expr* fun(expr*), expr* arg(expr*); + /* Conversions between the different numeric and pointer types. */ extern expr* pure_intval(expr*), expr* pure_dblval(expr*), Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-05-03 21:06:12 UTC (rev 39) +++ pure/trunk/runtime.cc 2008-05-03 22:02:26 UTC (rev 40) @@ -1095,6 +1095,30 @@ } extern "C" +bool applp(const pure_expr *x) +{ + return (x->tag == EXPR::APP); +} + +extern "C" +pure_expr *fun(const pure_expr *x) +{ + if (x->tag == EXPR::APP) + return x->data.x[0]; + else + return 0; +} + +extern "C" +pure_expr *arg(const pure_expr *x) +{ + if (x->tag == EXPR::APP) + return x->data.x[1]; + else + return 0; +} + +extern "C" int32_t pointer_get_byte(void *ptr) { uint8_t *p = (uint8_t*)ptr; Modified: pure/trunk/runtime.h =================================================================== --- pure/trunk/runtime.h 2008-05-03 21:06:12 UTC (rev 39) +++ pure/trunk/runtime.h 2008-05-03 22:02:26 UTC (rev 40) @@ -256,6 +256,16 @@ bool same(const pure_expr *x, const pure_expr *y); +/* Check whether an object is a function application, and return the function + and the argument of an application. Note that these operations can't be + defined in Pure because of the "head is function" rule which means that in + a pattern of the form f x, f is always a literal function symbol and not a + variable. */ + +bool applp(const pure_expr *x); +pure_expr *fun(const pure_expr *x); +pure_expr *arg(const pure_expr *x); + /* Direct memory accesses. */ int32_t pointer_get_byte(void *ptr); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-03 21:06:06
|
Revision: 39 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=39&view=rev Author: agraef Date: 2008-05-03 14:06:12 -0700 (Sat, 03 May 2008) Log Message: ----------- Add some remarks about the syntax of list of tuples. Modified Paths: -------------- pure/trunk/pure.1 Modified: pure/trunk/pure.1 =================================================================== --- pure/trunk/pure.1 2008-05-03 12:28:44 UTC (rev 38) +++ pure/trunk/pure.1 2008-05-03 21:06:12 UTC (rev 39) @@ -240,16 +240,19 @@ syntactic sugar for list values in brackets, such as [x,y,z], which is exactly the same as x:y:z:[]. Moreover, the prelude also provides an infix `..' operator to denote arithmetic sequences such as 1..10 or 1.0,1.2..3.0. Pure's -tuples are a bit unusual, however, in that they abide by the mathematical -rules: They are constructed by just ``paring'' things using the `,' operator, -for which the empty tuple acts as a neutral element (i.e., (),x is just x, as -is x,()). The pairing operator is associative, which implies that tuples are -completely flat (i.e., x,(y,z) is just x,y,z, as is (x,y),z). This means that -there are no nested tuples (tuples of tuples), if you need such constructs -then you should use lists instead. Also note that the parentheses are -\fInot\fP part of the tuple syntax in Pure, although you \fIcan\fP use -parentheses, just as with any other expression, for the usual purpose of -grouping expressions and overriding default precedences and associativity. +tuples are a bit unusual, however: They are constructed by just ``paring'' +things using the `,' operator, for which the empty tuple acts as a neutral +element (i.e., (),x is just x, as is x,()). The pairing operator is +associative, which implies that tuples are completely flat (i.e., x,(y,z) is +just x,y,z, as is (x,y),z). This means that there are no nested tuples (tuples +of tuples), if you need such constructs then you should use lists +instead. Also note that the parentheses are \fInot\fP part of the tuple syntax +in Pure, although you \fIcan\fP use parentheses, just as with any other +expression, for the usual purpose of grouping expressions and overriding +default precedences and associativity. This means that a list of tuples will +be printed (and must also be entered) using the ``canonical'' representation +(x1,y1):(x2,y2):...:[] rather than [(x1,y1),(x2,y2),...] (which denotes just +[x1,y1,x2,y2,...]). .TP .B List comprehensions: \fR[x,y; x = 1..n; y = 1..m; x<y] Pure also has list comprehensions which generate lists from an expression and This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-03 12:28:39
|
Revision: 38 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=38&view=rev Author: agraef Date: 2008-05-03 05:28:44 -0700 (Sat, 03 May 2008) Log Message: ----------- Updated README, added detailed installation instructions in INSTALL. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/Makefile pure/trunk/README Added Paths: ----------- pure/trunk/INSTALL Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-03 10:48:16 UTC (rev 37) +++ pure/trunk/ChangeLog 2008-05-03 12:28:44 UTC (rev 38) @@ -1,5 +1,8 @@ 2008-05-03 Albert Graef <Dr....@t-...> + * README: Moved installation instructions to a separate INSTALL + file, added Eddie Rucker's detailed instructions there. + * util.cc (myiconv): Apple's iconv takes const char** as 2nd parameter. #ifdef that case. Reported by Ryan Schmidt. Added: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL (rev 0) +++ pure/trunk/INSTALL 2008-05-03 12:28:44 UTC (rev 38) @@ -0,0 +1,174 @@ + +INSTALLING PURE (AND LLVM) +========== ==== ==== ===== + +These instructions (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. + + +BASIC INSTALLATION +===== ============ + +The basic installation process is as follows. Note that steps 1-3 are only +required once. Steps 2-3 can be avoided if binary LLVM packages are available +for your system. Additional instructions for compiling Pure from SVN sources +can be found in the INSTALLING FROM SVN SOURCES section below. Moreover, you +can refer to the OTHER COMPILATION OPTIONS section at the end of the file for +details about various options available when building and installing Pure. + +STEP 1. Make sure you have all the necessary dependencies installed (-dev +denotes corresponding development packages): + +- GNU make, GNU C++ and the corresponding libraries; + +- flex and bison (these are only required when compiling the Pure SVN sources, + see the INSTALLING FROM SVN SOURCES section below); + +- libgmp, -dev; + +- libreadline, -dev; + +- libltdl, -dev; + +- subversion (only needed to fetch the SVN sources, see below). + +E.g., the required packages for Ubuntu are: make, g++, g++ 4.0 multilib, flex, +bison, libgmp3c2, libgmp3-dev, readline5-dev, libltdl3, libldtl3-dev, +subversion. + +STEP 2. Get and unpack the LLVM 2.2 sources at: +http://llvm.org/releases/download.html#2.2 + +STEP 3. Configure, build and install LLVM as follows: + +$ cd llvm-2.2 +$ ./configure +$ make +$ sudo make install + +STEP 4. Get and unpack the Pure sources at: http://pure-lang.sf.net/ + +The latest release tarballs can always be found on the SourceForge project +page. See "Downloads" on the Pure website for a quick link to the download +section. + +STEP 5. Build and install the release version of Pure as follows: + +$ cd pure-x.y +$ make build=release +$ sudo make install + +Here, x.y denotes the current Pure version number (0.1 at the time of this +writing). If you want to install the debugging-enabled version, run just +'make' instead of 'make build=release'. + +To check that Pure is working correctly on your computer, also run: + +$ make check + +STEP 6. The Pure interpreter should be ready to go now. (On some systems you +might first have to run ldconfig to update the dynamic linker cache.) + +Run Pure interactively as: + +$ pure +Pure 0.1 Copyright (c) 2008 by Albert Graef +This program is free software distributed under the GNU Public License +(GPL V3 or later). Please see the COPYING file for details. +Loaded prelude from /usr/local/lib/pure/prelude.pure. + +Check that it works: + +> 6*7; +42 + +Read the online documentation (this invokes the Pure manual page): + +> help + +Exit the interpreter (you can also just type the end-of-file character at the +beginning of a line, i.e., Ctrl-D on Unix): + +> quit + + +INSTALLING FROM SVN SOURCES +========== ==== === ======= + +The latest development version of Pure is available in its subversion (SVN) +source code repository. You can browse the repository at: + +http://pure-lang.svn.sourceforge.net/viewvc/pure-lang/ + +(See the pure/trunk subdirectory for the latest sources.) + +Note that if you're going with the development sources, you'll also need +fairly recent versions of the flex and bison utilities (flex 2.5.31 and bison +2.3 should be ok). + +To compile from the development sources, replace steps 4 and 5 above with: + +STEP 4': Fetch the SVN sources. + +$ svn co http://pure-lang.svn.sourceforge.net/svnroot/pure-lang pure-lang + +STEP 5': Build and install the debugging-enabled version (of course you can +also build the release version, as described in step 5 above): + +$ cd pure-lang/pure/trunk +$ make +$ sudo make install + + +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.: + +$ 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). + +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) like libiconv on OSX. + +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, + +$ PURELIB=./lib ./pure + +will run the Pure interpreter with that setting in Bourne-compatible shells. + +For the release version, you should build the interpreter as follows: + +$ make build=release + +This disables all runtime checks and debugging information in the interpreter. +(Don't worry, your Pure programs will still be executed "safely" and shouldn't +segfault unless you run out of memory or there's a bug in the interpreter.) +The 'release' build gives you *much* faster execution times (factor of 2 +compared to the default flags on my Linux system running gcc 4.1, YMMV). It +also takes a *long* time to compile runtime.cc, but it's really worth the +wait, so please be patient. ;-) + +Please also have a look at the Makefile for details on the build and +installation process and other available targets and options. + + +May 2008 +Albert Graef <Dr.Graef at t-online.de> +Eddie Rucker <erucker at bmc.edu> Modified: pure/trunk/Makefile =================================================================== --- pure/trunk/Makefile 2008-05-03 10:48:16 UTC (rev 37) +++ pure/trunk/Makefile 2008-05-03 12:28:44 UTC (rev 38) @@ -80,7 +80,7 @@ logs = test/prelude.log $(tests:.pure=.log) distlogs = $(wildcard test/*.log) -DISTFILES = COPYING ChangeLog NEWS README TODO Makefile \ +DISTFILES = COPYING ChangeLog INSTALL NEWS README TODO Makefile \ $(SOURCE) $(EXTRA_SOURCE) w3centities.c pure.1 pure.xml pure.vim \ $(examples) $(lib) $(tests) $(distlogs) Modified: pure/trunk/README =================================================================== --- pure/trunk/README 2008-05-03 10:48:16 UTC (rev 37) +++ pure/trunk/README 2008-05-03 12:28:44 UTC (rev 38) @@ -23,58 +23,15 @@ INSTALLATION -The usual 'make && make install' should do the trick. (No 'configure' step -necessary.) This requires GNU make and g++. For other setups, you'll probably -have to fiddle with the Makefile and the sources. The sources should be pretty -portable, but the Makefile really needs GNU make right now. +Please see the INSTALL file for detailed instructions. On most Unix-like +systems, the usual 'make && sudo make install' should do the trick. (No +'configure' step necessary.) This requires GNU make and g++. For other setups, +you'll probably have to fiddle with the Makefile and the sources. The sources +should be pretty portable, but the Makefile really needs GNU make right now. +You'll also need LLVM for the compiler backend (version 2.2 has been tested). +For your convenience, instructions for installing LLVM are also included in +the INSTALL file. -You'll also need LLVM (version 2.2 has been tested) for the compiler backend; -install it before compiling Pure. Instructions for installing LLVM can be -found at the LLVM website (http://llvm.org). - -By default, the 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.: - - 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). - -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 special libraries (LIBS) like libiconv on OSX. - -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, - - PURELIB=./lib ./pure - -will run the Pure interpreter with that setting in Bourne-compatible shells. - -For the release version, you should build the interpreter as follows: - - make build=release - -This disables all runtime checks and debugging information in the interpreter. -(Don't worry, your Pure programs will still be executed "safely" and shouldn't -segfault unless you run out of memory or there's a bug in the interpreter.) -The 'release' build gives you *much* faster execution times (factor of 2 -compared to the default flags on my Linux system running gcc 4.1, YMMV). It -also takes a *long* time to compile runtime.cc, but it's really worth the -wait, so please be patient. ;-) - -Please also have a look at the Makefile for details on the build and -installation process and other available targets and options. - USING PURE Pure scripts are just ordinary text files, which can be created with any text @@ -107,5 +64,5 @@ Johannes Gutenberg University of Mainz Germany -<Dr....@t-...> +<Dr.Graef at t-online.de> http://pure-lang.sf.net This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-03 10:48:09
|
Revision: 37 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=37&view=rev Author: agraef Date: 2008-05-03 03:48:16 -0700 (Sat, 03 May 2008) Log Message: ----------- Fix up iconv() calls for compatibility with OSX. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/util.cc Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-03 10:29:01 UTC (rev 36) +++ pure/trunk/ChangeLog 2008-05-03 10:48:16 UTC (rev 37) @@ -1,5 +1,8 @@ 2008-05-03 Albert Graef <Dr....@t-...> + * util.cc (myiconv): Apple's iconv takes const char** as 2nd + parameter. #ifdef that case. Reported by Ryan Schmidt. + * interpreter.cc (declare_extern): Fixed a bug in the generated wrapper code for external calls, which caused function arguments to be garbage-collected prematurely, when they were still needed Modified: pure/trunk/util.cc =================================================================== --- pure/trunk/util.cc 2008-05-03 10:29:01 UTC (rev 36) +++ pure/trunk/util.cc 2008-05-03 10:48:16 UTC (rev 37) @@ -433,6 +433,14 @@ #endif /* HAVE_LANGINFO_CODESET */ } +#ifdef __APPLE__ +#define myiconv(ic, inbuf, inbytes, outbuf, outbytes) \ + iconv(ic, (const char**)inbuf, inbytes, outbuf, outbytes) +#else +#define myiconv(ic, inbuf, inbytes, outbuf, outbytes) \ + iconv(ic, inbuf, inbytes, outbuf, outbytes) +#endif + #define CHUNKSZ 128 char * @@ -455,7 +463,7 @@ char *inbuf = (char*)s, *outbuf = t; // const char* -> char*. Ugh. size_t inbytes = l, outbytes = l; - while (iconv(ic, &inbuf, &inbytes, &outbuf, &outbytes) == + while (myiconv(ic, &inbuf, &inbytes, &outbuf, &outbytes) == (size_t)-1) if (errno == E2BIG) { /* try to enlarge the output buffer */ @@ -508,7 +516,7 @@ char *inbuf = (char*)s, *outbuf = t; // const char* -> char*. Ugh. size_t inbytes = l, outbytes = l; - while (iconv(ic, &inbuf, &inbytes, &outbuf, &outbytes) == + while (myiconv(ic, &inbuf, &inbytes, &outbuf, &outbytes) == (size_t)-1) if (errno == E2BIG) { /* try to enlarge the output buffer */ @@ -532,7 +540,7 @@ /* here we might have to deal with a stateful encoding, so make sure that we emit the closing shift sequence */ - while (iconv(ic, NULL, NULL, &outbuf, &outbytes) == + while (myiconv(ic, NULL, NULL, &outbuf, &outbytes) == (size_t)-1) if (errno == E2BIG) { /* try to enlarge the output buffer */ @@ -580,7 +588,7 @@ char *inbuf = s; wchar_t *outbuf = t; size_t inbytes = l, outbytes = l*sizeof(wchar_t); - if (iconv(myic[1], &inbuf, &inbytes, (char**)&outbuf, &outbytes) == + if (myiconv(myic[1], &inbuf, &inbytes, (char**)&outbuf, &outbytes) == (size_t)-1) return NULL; /* terminate the output string */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-03 10:28:54
|
Revision: 36 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=36&view=rev Author: agraef Date: 2008-05-03 03:29:01 -0700 (Sat, 03 May 2008) Log Message: ----------- Fixed premature garbage collection of arguments in external wrapper code. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/interpreter.cc Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-05-03 10:05:43 UTC (rev 35) +++ pure/trunk/ChangeLog 2008-05-03 10:29:01 UTC (rev 36) @@ -1,6 +1,13 @@ 2008-05-03 Albert Graef <Dr....@t-...> - * test/test4.pure: Disable tail call checks, as they may fail on + * interpreter.cc (declare_extern): Fixed a bug in the generated + wrapper code for external calls, which caused function arguments + to be garbage-collected prematurely, when they were still needed + to create the default value, in the case of external calls + returning a null expression pointer to indicate failure. Reported + by Eddie Rucker. + + * test/test4.pure: Disabled tail call checks, as they may fail on some platforms. Reported by Ryan Schmidt. * test/test1.pure: Corrected fact3 example, added test cases. Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-03 10:05:43 UTC (rev 35) +++ pure/trunk/interpreter.cc 2008-05-03 10:29:01 UTC (rev 36) @@ -2405,19 +2405,8 @@ } // call the function Value* u = b.CreateCall(g, unboxed.begin(), unboxed.end()); - // free temporaries and arguments + // free temporaries if (temps) b.CreateCall(module->getFunction("pure_free_cstrings")); - if (n == 1) - b.CreateCall(module->getFunction("pure_free"), args[0]); - else if (n > 0) { - vector<Value*> freeargs(n+2); - freeargs[0] = NullExprPtr; - for (size_t i = 0; i < n; i++) - freeargs[i+1] = args[i]; - freeargs[n+1] = NullExprPtr; - b.CreateCall(module->getFunction("pure_free_args"), - freeargs.begin(), freeargs.end()); - } // box the result if (type == Type::VoidTy) u = b.CreateCall(module->getFunction("pure_const"), @@ -2456,6 +2445,18 @@ u = b.CreateCall(module->getFunction("pure_pointer"), u); else assert(0 && "invalid C type"); + // free arguments (we do that here so that the arguments don't get freed + // before we know that we don't need them anymore) + if (n > 0) { + vector<Value*> freeargs(n+2); + freeargs[0] = u; + for (size_t i = 0; i < n; i++) + freeargs[i+1] = args[i]; + freeargs[n+1] = NullExprPtr; + b.CreateCall(module->getFunction("pure_free_args"), + freeargs.begin(), freeargs.end()); + b.CreateCall(module->getFunction("pure_unref"), u); + } b.CreateRet(u); // The call failed. Provide a default value. f->getBasicBlockList().push_back(failedbb); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |