pure-lang-svn Mailing List for Pure (Page 27)
Status: Beta
Brought to you by:
agraef
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
(5) |
May
(141) |
Jun
(184) |
Jul
(97) |
Aug
(232) |
Sep
(196) |
Oct
|
Nov
|
Dec
|
---|
From: <ag...@us...> - 2008-06-14 06:59:30
|
Revision: 216 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=216&view=rev Author: agraef Date: 2008-06-13 23:59:34 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Add -q (quiet startup) option and PURE_MORE environment variable. Modified Paths: -------------- pure/trunk/lexer.ll pure/trunk/pure.cc Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-06-14 00:32:38 UTC (rev 215) +++ pure/trunk/lexer.ll 2008-06-14 06:59:34 UTC (rev 216) @@ -449,8 +449,9 @@ sout << nfuns << " functions, " << nrules << " rules\n"; } FILE *fp; + const char *more = getenv("PURE_MORE"); // FIXME: We should check that 'more' actually exists here. - if (isatty(fileno(stdin)) && (fp = popen("more", "w"))) { + if (more && isatty(fileno(stdin)) && (fp = popen(more, "w"))) { fputs(sout.str().c_str(), fp); pclose(fp); } else Modified: pure/trunk/pure.cc =================================================================== --- pure/trunk/pure.cc 2008-06-14 00:32:38 UTC (rev 215) +++ pure/trunk/pure.cc 2008-06-14 06:59:34 UTC (rev 216) @@ -34,10 +34,12 @@ -h: Print this message and exit.\n\ -i: Force interactive mode (read commands from stdin).\n\ -n: Suppress automatic inclusion of the prelude.\n\ +-q: Quiet startup (suppresses sign-on message).\n\ -v: Set verbosity level (useful for debugging purposes).\n\ --: Stop option processing, pass remaining args in argv variable.\n\ Environment:\n\ PURELIB: Directory to search for source scripts including the prelude.\n\ +PURE_MORE: Shell command for paging through output of the 'list' command.\n\ PURE_PS: Command prompt to be used in the interactive command loop.\n\ PURE_STACK: Maximum stack size in kilobytes (default: 0 = unlimited).\n" #define LICENSE "This program is free software distributed under the GNU Public License\n(GPL V3 or later). Please see the COPYING file for details.\n" @@ -152,7 +154,8 @@ char base; interpreter interp; int count = 0; - bool force_interactive = false, want_prelude = true, have_prelude = false; + bool quiet = false, force_interactive = false, + want_prelude = true, have_prelude = false; // This is used in advisory stack checks. interpreter::baseptr = &base; // make sure that SIGPIPE is ignored @@ -200,6 +203,8 @@ force_interactive = true; else if (*args == string("-n")) want_prelude = false; + else if (*args == string("-q")) + quiet = true; else if (string(*args).substr(0,2) == "-v") { string s = string(*args).substr(2); if (s.empty()) continue; @@ -256,10 +261,12 @@ interp.interactive = true; if (isatty(fileno(stdin))) { // connected to a terminal, print sign-on and initialize readline - cout << "Pure " << PACKAGE_VERSION << " (" << HOST << ") " - << COPYRIGHT << endl << LICENSE; - if (have_prelude) - cout << "Loaded prelude from " << prelude << ".\n\n"; + if (!quiet) { + cout << "Pure " << PACKAGE_VERSION << " (" << HOST << ") " + << COPYRIGHT << endl << LICENSE; + if (have_prelude) + cout << "Loaded prelude from " << prelude << ".\n\n"; + } rl_readline_name = "Pure"; rl_attempted_completion_function = pure_completion; using_history(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-14 00:32:31
|
Revision: 215 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=215&view=rev Author: agraef Date: 2008-06-13 17:32:38 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Update installation instructions. Modified Paths: -------------- pure/trunk/README Modified: pure/trunk/README =================================================================== --- pure/trunk/README 2008-06-14 00:27:15 UTC (rev 214) +++ pure/trunk/README 2008-06-14 00:32:38 UTC (rev 215) @@ -38,10 +38,11 @@ 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.) +and Vim, as well as an Emacs mode which allows you to run the interpreter in +an Emacs buffer. You might wish to install these into your katepart/syntax, +.vim/syntax and Emacs site-lisp directories, respectively. (The Emacs and Vim +modes must also be enabled in your corresponding startup files; see the +comments at the beginning of pure-mode.el and 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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-14 00:27:07
|
Revision: 214 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=214&view=rev Author: agraef Date: 2008-06-13 17:27:15 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Add a Pure Emacs mode. Modified Paths: -------------- pure/trunk/Makefile.in Added Paths: ----------- pure/trunk/pure-mode.el.in Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-13 23:45:33 UTC (rev 213) +++ pure/trunk/Makefile.in 2008-06-14 00:27:15 UTC (rev 214) @@ -107,7 +107,7 @@ DISTFILES = COPYING ChangeLog INSTALL NEWS README TODO \ Makefile.in aclocal.m4 configure.ac configure config.h.in \ config.guess config.sub install-sh $(SOURCE) $(EXTRA_SOURCE) w3centities.c \ -pure.cc pure.1 pure.1.in pure.xml pure.vim \ +pure.cc pure.1 pure.1.in pure-mode.el.in pure.xml pure.vim \ examples/*.pure lib/*.pure test/*.pure test/*.log .PHONY: all html dvi ps pdf clean realclean depend install uninstall strip \ @@ -115,7 +115,7 @@ # compilation -all: pure$(EXE) pure.1 +all: pure$(EXE) pure-mode.el pure.1 ifeq ($(sharedlib), yes) pure$(EXE): pure.o $(libpure) @@ -146,13 +146,18 @@ parser.hh location.hh position.hh stack.hh: parser.cc +# create pure-mode.el from pure-mode.el.in + +pure-mode.el: Makefile pure-mode.el.in + rm -f pure-mode.el pure-mode.el.tmp + sed -e 's,@bindir\@,$(bindir),g' -e 's,@libdir\@,$(libdir),g' pure-mode.el.in >pure-mode.el.tmp + mv pure-mode.el.tmp pure-mode.el + # create the manpage from pure.1.in -edit = sed -e 's,@version\@,$(version),g' - pure.1: configure.ac pure.1.in rm -f pure.1 pure.1.tmp - $(edit) pure.1.in >pure.1.tmp + sed -e 's,@version\@,$(version),g' pure.1.in >pure.1.tmp mv pure.1.tmp pure.1 # documentation in various formats (requires groff) @@ -186,7 +191,7 @@ rm -f *~ *.bak *.html *.dvi *.ps *.pdf pure$(EXE) $(OBJECT) pure.o $(libpurelnk) $(libpure) parser.output distclean: clean - rm -f Makefile config.h config.log config.status $(dist).tar.gz + rm -f Makefile config.h config.log config.status pure-mode.el $(dist).tar.gz realclean: distclean rm -f $(addprefix $(srcdir)/, test/*.log $(EXTRA_SOURCE) pure.1) @@ -198,7 +203,7 @@ # installation -install: pure$(EXE) pure.1 +install: pure$(EXE) pure-mode.el pure.1 for x in $(addprefix $(DESTDIR), $(bindir) $(libdir)/pure-$(version) $(man1dir)); do $(INSTALL) -d $$x; done $(INSTALL) pure$(EXE) $(DESTDIR)$(bindir)/pure-$(version)$(EXE) ln -sf $(bindir)/pure-$(version)$(EXE) $(DESTDIR)$(bindir)/pure$(EXE) Added: pure/trunk/pure-mode.el.in =================================================================== --- pure/trunk/pure-mode.el.in (rev 0) +++ pure/trunk/pure-mode.el.in 2008-06-14 00:27:15 UTC (rev 214) @@ -0,0 +1,1716 @@ +;;; pure-mode.el --- edit and run Pure scripts -*- Emacs-Lisp -*- + +;; Copyright (C) 1997-2002 Free Software Foundation, Inc. +;; Copyright (C) 1999-2002 Albert Graef +;; Copyright (C) 2008 Albert Graef + +;; Distributed under GPL V3 (or later; see the accompanying COPYING file). + +;; Author/Maintainer: Albert Graef +;; <ag...@mu..., Dr....@t-...> + +;; This is a quick and dirty hack of Q mode, which in turn was based on +;; various different language modes like Prolog mode and Emacs Lisp mode. It +;; desperately needs an overhaul; in particular, auto-indentation is pretty +;; much broken right now. (Watch out for XXXFIXME.) + +;; INSTALLATION: If necessary, edit the values of the `pure-prog' and +;; `pure-lib-dir' variables below. + +(defvar pure-prog "@bindir@/pure") +(defvar pure-lib-dir "@libdir@/pure") + +;; Then copy this file to your site-lisp directory. The easiest way to make +;; Pure mode available in emacs is to add the following to your emacs startup +;; file: + +;; (require 'pure-mode) + +;; To enable Pure mode for *.pure files, add the following to your emacs +;; startup file: + +;; (setq auto-mode-alist (cons '("\\.pure$" . pure-mode) auto-mode-alist)) + +;; Furthermore, you can enable font lock (syntax highlighting) as follows: + +;; (add-hook 'pure-mode-hook 'turn-on-font-lock) +;; (add-hook 'pure-eval-mode-hook 'turn-on-font-lock) + +;; Well, that's the way it works with XEmacs and newer GNU Emacs versions. For +;; older versions of GNU Emacs you might have to try something like: + +;; (global-font-lock-mode t) +;; (add-hook 'pure-mode-hook (lambda () (font-lock-mode 1))) +;; (add-hook 'pure-eval-mode-hook (lambda () (font-lock-mode 1))) + +;; Using the Pure-Eval hook you can also rebind the cursor up and down keys to +;; the history cycling commands: + +;; (add-hook 'pure-eval-mode-hook +;; (lambda () +;; (define-key pure-eval-mode-map [up] 'comint-previous-input) +;; (define-key pure-eval-mode-map [down] 'comint-next-input))) + +;; Finally, you might wish to add some global key bindings, e.g.: + +;; (global-set-key "\C-c\M-p" 'run-pure) + +;; NOTE: For reading the Pure online documentation, simply use Emacs' built-in +;; manpage reader (M-? RET in XEmacs). Pure's 'help' command won't work in an +;; Emacs buffer. + +(require 'comint) + +;; customizable variables + +(defgroup pure nil "Major mode for editing and running Pure scripts." + :group 'languages) + +(defcustom pure-default-rhs-indent 32 + "*Default indentation of the right-hand side of a rule." + :type 'integer + :group 'pure ) + +(defcustom pure-extra-decl-indent 2 + "*Extra indentation of continuation lines in declarations." + :type 'integer + :group 'pure ) + +(defcustom pure-extra-qual-indent 2 + "*Extra indentation of qualifiers in rules." + :type 'integer + :group 'pure ) + +(defcustom pure-hanging-comment-ender-p t + "*Controls what \\[fill-paragraph] does to Pure block comment enders. +When set to nil, Pure block comment enders are left on their own line. +When set to t, block comment enders will be placed at the end of the +previous line (i.e. they `hang' on that line)." + :type 'boolean + :group 'pure) + +(defcustom pure-hanging-comment-starter-p t + "*Controls what \\[fill-paragraph] does to Pure block comment starters. +When set to nil, Pure block comment starters are left on their own line. +When set to t, text that follows a block comment starter will be +placed on the same line as the block comment starter (i.e. the text +`hangs' on that line)." + :type 'boolean + :group 'pure) + +(defcustom pure-prog-name pure-prog + "*Name of the interpreter executable." + :type 'string + :group 'pure) + +(defcustom pure-histfile "~/.pure_history" + "*Name of the command history file." + :type 'string + :group 'pure) + +(defcustom pure-histsize 500 + "*Size of the command history." + :type 'integer + :group 'pure) + +(defcustom pure-query-before-kill nil + "*Indicates that the user should be prompted before zapping an existing +interpreter process when starting a new one." + :type 'boolean + :group 'pure) + +(defcustom pure-prompt-regexp "^> \\|^[A-Za-z_0-9-]*> \\|^: " + "*Regexp to match prompts in the Pure interpreter. If you customize the +interpreter's default prompt, you will have to change this value accordingly." + :type 'regexp + :group 'pure) + +(defcustom pure-msg-regexp + "^[ \t]*\\(\\([^:\n]+\\):\\([0-9]+\\)\\(\\.[0-9]+\\)?\\):" +"*Regexp to match error and warning messages with source line references in +the Pure eval buffer. Expression 1 denotes the whole source line info, +expression 2 the file name and expression 3 the corresponding line number." + :type 'regexp + :group 'pure) + +(defcustom pure-mode-hook nil + "*Hook for customising Pure mode. +For instance, add `turn-on-font-lock' to enable syntax highlighting." + :type 'hook + :group 'pure) + +(defcustom pure-eval-mode-hook nil + "*Hook for customising Pure eval mode. +For instance, add `turn-on-font-lock' to enable syntax highlighting." + :type 'hook + :group 'pure) + +;; the following are used internally + +(defvar pure-output-list nil) +(defvar pure-output-string nil) +(defvar pure-receive-in-progress nil) +(defvar pure-last-dir nil) +(defvar pure-last-script nil) +(defvar pure-last-path nil) + +;; font-lock support + +(defvar pure-eval-font-lock-keywords + (list +; (list pure-prompt-regexp 0 'font-lock-preprocessor-face t) + (list pure-msg-regexp 0 'font-lock-warning-face t) + (list "::\\([A-Za-z_][A-Za-z_0-9]*\\)" 1 'font-lock-type-face) + (list + (concat "\\<\\(" + "case\\|e\\(lse\\|nd\\|xtern\\)\\|i\\(f\\|nfix[lr]?\\)\\|let\\|" + "nullary\\|o\\(f\\|therwise\\)\\|p\\(refix\\|ostfix\\)\\|" + "then\\|using\\|w\\(hen\\|ith\\)" + "\\)\\>") + 0 'font-lock-keyword-face)) + "Rules for fontifying in Pure-Eval mode.") + +(defvar pure-font-lock-keywords + (list + (list "::\\([A-Za-z_][A-Za-z_0-9]*\\)" 1 'font-lock-type-face) + (list + (concat "\\<\\(" + "case\\|e\\(lse\\|nd\\|xtern\\)\\|i\\(f\\|nfix[lr]?\\)\\|let\\|" + "nullary\\|o\\(f\\|therwise\\)\\|p\\(refix\\|ostfix\\)\\|" + "then\\|using\\|w\\(hen\\|ith\\)" + "\\)\\>") + 0 'font-lock-keyword-face)) + "Rules for fontifying Pure scripts.") + +;; keymaps + +(defvar pure-mode-map nil) +(cond ((not pure-mode-map) + (setq pure-mode-map (make-sparse-keymap)) + (define-key pure-mode-map "\C-c\C-c" 'pure-run-script) + (define-key pure-mode-map "\C-c\C-u" 'pure-current-msg) + (define-key pure-mode-map "\C-c\C-n" 'pure-next-msg) + (define-key pure-mode-map "\C-c\C-p" 'pure-prev-msg) + (define-key pure-mode-map "\C-c\C-e" 'pure-last-msg) + (define-key pure-mode-map "\C-c\C-a" 'pure-first-msg) + (define-key pure-mode-map "\C-c\C-f" 'pure-find-script) + (define-key pure-mode-map "\C-c\C-v" 'pure-goto-input-line) + (define-key pure-mode-map "\t" 'pure-indent-line) + (define-key pure-mode-map "(" 'pure-electric-delim) + (define-key pure-mode-map ")" 'pure-electric-delim) + (define-key pure-mode-map "[" 'pure-electric-delim) + (define-key pure-mode-map "]" 'pure-electric-delim) + (define-key pure-mode-map "=" 'pure-electric-delim) + (define-key pure-mode-map "\e\C-i" 'pure-move-to-indent-column) + (define-key pure-mode-map "\e\C-q" 'pure-indent-current-rule))) + +(defvar pure-eval-mode-map nil) +(cond ((not pure-eval-mode-map) + (setq pure-eval-mode-map (copy-keymap comint-mode-map)) + (define-key pure-eval-mode-map "\t" 'comint-dynamic-complete) + (define-key pure-eval-mode-map "\C-a" 'comint-bol) + (define-key pure-eval-mode-map [home] 'comint-bol) +;; (define-key pure-eval-mode-map [up] 'comint-previous-input) +;; (define-key pure-eval-mode-map [down] 'comint-next-input) + (define-key pure-eval-mode-map [return] 'pure-current-msg-or-send) + (if (string-match "XEmacs\\|Lucid" emacs-version) + (define-key pure-eval-mode-map [button2] 'pure-mouse-msg) + (define-key pure-eval-mode-map [mouse-2] 'pure-mouse-msg)) + (define-key pure-eval-mode-map "\C-c\C-u" 'pure-current-msg) + (define-key pure-eval-mode-map "\C-c\C-n" 'pure-next-msg) + (define-key pure-eval-mode-map "\C-c\C-p" 'pure-prev-msg) + (define-key pure-eval-mode-map "\C-c\C-e" 'pure-last-msg) + (define-key pure-eval-mode-map "\C-c\C-a" 'pure-first-msg) + (define-key pure-eval-mode-map "\C-c\C-f" 'pure-find-script) + (define-key pure-eval-mode-map "\C-c\C-v" 'pure-goto-input-line))) + +;; menus + +(defsubst pure-region-is-active-p () + ;; Return t when the region is active. The determination of region + ;; activeness is different in both Emacs and XEmacs. + (cond + ;; XEmacs + ((and (fboundp 'region-active-p) + zmacs-regions) + (region-active-p)) + ;; Emacs + ((boundp 'mark-active) mark-active) + ;; fallback; shouldn't get here + (t (mark t)))) + +(defvar pure-mode-menu + (list "Pure" + ["Describe Pure Mode" describe-mode t] + ["Customize" (customize-group 'pure) t] + "-" + ["Move to `=' Column" pure-move-to-indent-column t] + ["Indent Current Rule" pure-indent-current-rule t] + ["Indent Line or Region" pure-indent-line-or-region t] + ["Comment Out Region" comment-region (pure-region-is-active-p)] + ["Uncomment Region" uncomment-region (pure-region-is-active-p)] + ["Fill Comment Paragraph" pure-fill-paragraph t] + "-" + ["Run Script" pure-run-script t] + ["Find Main Script" pure-find-script pure-last-script] + ["Goto Input Line" pure-goto-input-line + (get-process "pure-eval")] + "-" + ["Current Message" pure-current-msg + (get-buffer "*pure-eval*")] + ["First Message" pure-first-msg + (get-buffer "*pure-eval*")] + ["Next Message" pure-next-msg + (get-buffer "*pure-eval*")] + ["Previous Message" pure-prev-msg + (get-buffer "*pure-eval*")] + ["Last Message" pure-last-msg + (get-buffer "*pure-eval*")]) + "Menu for Pure mode.") + +(defvar pure-eval-mode-menu + (list "Pure-Eval" + ["Describe Pure-Eval Mode" describe-mode t] + ["Customize" (customize-group 'pure) t] + "-" + ["Find Main Script" pure-find-script pure-last-script] + ["Goto Input Line" pure-goto-input-line + (get-process "pure-eval")] + "-" + ["Current Message" pure-current-msg + (get-buffer "*pure-eval*")] + ["First Message" pure-first-msg + (get-buffer "*pure-eval*")] + ["Next Message" pure-next-msg + (get-buffer "*pure-eval*")] + ["Previous Message" pure-prev-msg + (get-buffer "*pure-eval*")] + ["Last Message" pure-last-msg + (get-buffer "*pure-eval*")] + "-" + ["Complete Symbol" comint-dynamic-complete + (pure-at-command-prompt-p)]) + "Menu for Pure-Eval mode.") + +;; some helper functions for pure/pure-eval-mode: check that we're on the +;; command resp. debugger prompt + +(defun pure-at-pmark-p () + (and (get-buffer "*pure-eval*") + (get-process "pure-eval") + (progn (set-buffer "*pure-eval*") (comint-after-pmark-p)))) + +(defun pure-at-command-prompt-p () + (and + (pure-at-pmark-p) + (save-excursion + (forward-line 0) + (looking-at pure-prompt-regexp)))) + +(defun pure-at-debug-prompt-p () + (and + (pure-at-pmark-p) + (save-excursion + (forward-line 0) + (looking-at ":")))) + +;; Pure mode + +;;;###autoload +(defun pure-mode () + "Major mode for editing Pure scripts. + +Provides the `pure-run-script' (\\[pure-run-script]) command to run the +interpreter on the script in the current buffer. It will be verified that the +buffer has a file associated with it, and you will be prompted to save edited +buffers when invoking this command. Special commands to quickly locate the +main script and the input line of the Pure eval buffer, and to visit the +source lines shown in error messages are provided as well (see +`pure-eval-mode'). + +These operations can be selected from the Pure mode menu (accessible from +the menu bar), which also provides commands for reading the online +help and customizing the Pure/Pure-Eval mode setup. + +Command list: + +\\{pure-mode-map} +Entry to this mode calls the value of pure-mode-hook if that value is +non-nil." + (interactive) + (kill-all-local-variables) + (set-syntax-table (make-syntax-table)) + (modify-syntax-entry ?_ "_") + (modify-syntax-entry ?\. "_") + (modify-syntax-entry ?\+ ".") + (modify-syntax-entry ?\- ".") + (modify-syntax-entry ?\= ".") + (modify-syntax-entry ?\< ".") + (modify-syntax-entry ?\> ".") + (modify-syntax-entry ?\$ ".") + (modify-syntax-entry ?\| ".") + ;; comment syntax a la C++ mode +; (cond +; ;; XEmacs 19 & 20 +; ((memq '8-bit c-emacs-features) +; (modify-syntax-entry ?/ ". 1456") +; (modify-syntax-entry ?* ". 23")) +; ;; Emacs 19 & 20 +; ((memq '1-bit c-emacs-features) +; (modify-syntax-entry ?/ ". 124b") +; (modify-syntax-entry ?* ". 23")) +; ;; incompatible +; (t (error "Pure Mode is incompatible with this version of Emacs"))) + (cond + ((string-match "XEmacs\\|Lucid" emacs-version) + (modify-syntax-entry ?/ ". 1456") + (modify-syntax-entry ?* ". 23")) + (t + (modify-syntax-entry ?/ ". 124b") + (modify-syntax-entry ?* ". 23"))) + (modify-syntax-entry ?\n "> b") + (modify-syntax-entry ?\^m "> b") + (setq major-mode 'pure-mode) + (setq mode-name "Pure") + (use-local-map pure-mode-map) + (make-local-variable 'paragraph-start) +;; (setq paragraph-start (concat "^$\\|" page-delimiter)) +;; (setq paragraph-start (concat "^//\\|^$\\|" page-delimiter)) + (setq paragraph-start (concat page-delimiter "\\|$")) + (make-local-variable 'paragraph-separate) + (setq paragraph-separate paragraph-start) + (make-local-variable 'paragraph-ignore-fill-prefix) + (setq paragraph-ignore-fill-prefix t) + (if (boundp 'fill-paragraph-function) + (progn + (make-local-variable 'fill-paragraph-function) + (setq fill-paragraph-function 'pure-fill-paragraph))) + (make-local-variable 'indent-line-function) + (setq indent-line-function 'pure-indent-line) + (make-local-variable 'indent-region-function) + (setq indent-region-function 'pure-indent-region) + (make-local-variable 'comment-start) + (make-local-variable 'comment-end) + (make-local-variable 'comment-column) + (make-local-variable 'comment-start-skip) + (make-local-variable 'comment-multi-line) + (setq comment-column 48 + comment-start "// " + comment-end "" + comment-start-skip "/\\*+ *\\|// *\\|^#! *" + comment-multi-line nil + ) + (make-local-variable 'comment-indent-function) + (setq comment-indent-function 'pure-comment-indent) + (make-local-variable 'font-lock-defaults) + (setq font-lock-defaults + '(pure-font-lock-keywords nil nil ((?_ . "w")))) + (require 'easymenu) + (easy-menu-define pure-mode-menu-map pure-mode-map + "Menu keymap for Pure mode." pure-mode-menu) + (easy-menu-add pure-mode-menu-map pure-mode-map) + (run-hooks 'pure-mode-hook)) + +;; Pure eval mode + +(defun pure-eval-mode () + + "Major mode for interacting with the Pure interpreter, based on comint-mode. + +Provides the `pure-current-msg-or-send' (\\[pure-current-msg-or-send]) +command, which, when point is at an error message describing a source +reference, visits the given line in the corresponding source file in another +window. Otherwise it runs the `comint-send-input' command, which usually +submits a command line to the interpreter, or copies it to the command prompt +when point is not at the current command line. + +Error messages are indicated with a special font, and in XEmacs they will also +be highlighted when the mouse passes over them. Moreover, pressing the middle +mouse button (button2) over such a message visits the corresponding source +line in another window (`pure-mouse-msg' command); anywhere else, the middle +mouse button invokes the usual `mouse-yank' command, so that you can also use +the mouse to perform xterm-like cut and paste in the Pure-Eval buffer. + +You can also use the `pure-first-msg' (\\[pure-first-msg]), `pure-next-msg' +(\\[pure-next-msg]), `pure-prev-msg' (\\[pure-prev-msg]) and `pure-last-msg' +(\\[pure-last-msg]) commands to scan through error messages found in the +buffer. The `pure-find-script' (\\[pure-find-script]) command lets you visit +the script that is currently running, and `pure-goto-input-line' +(\\[pure-goto-input-line]) quickly takes you to the prompt at the current +input line in the Pure eval buffer. (These commands are also provided in Pure +mode. If you like, you can bind them globally, so that you can invoke them +from other kinds of buffers as well.) + +Besides this, you can use the usual comint commands, see the description of +`comint-mode' for details. Some important commands are listed below: + +\\[comint-previous-input] and \\[comint-next-input] cycle through the command history. +\\[comint-previous-matching-input] and \\[comint-next-matching-input] search the command history. +\\[comint-interrupt-subjob] sends a Ctl-C to the interpreter. +\\[comint-send-eof] sends a Ctl-D to the interpreter. +\\[comint-dynamic-list-input-ring] lists the command history. +\\[comint-dynamic-complete] performs symbol and filename completion. + +Note that in difference to standard comint mode, the C-a/home keys are rebound +to `comint-bol', to mimic the behaviour of the default binding of these keys +in the interpreter. + +Most of these operations can also be selected from the Comint and Pure-Eval +mode menus accessible from the menu bar. The Pure-Eval menu also provides +operations for reading the online help and customizing Pure/Pure-Eval mode +setup. Moreover, a History menu is provided from which the most recent +commands can be selected. + +The interpreter's prompt and lines containing error messages are described by +the variables `pure-prompt-regexp' and `pure-msg-regexp'. The history file and +size is given by the `pure-histfile' and `pure-histsize' variables. Note that +when the `pure-gnuclient' customization option is enabled, then Pure-Eval mode +automatically tracks the current prompt string and hence you can safely use +the `prompt' command in the interpreter. + +A complete command list is given below: + +\\{pure-eval-mode-map} +Entry to this mode runs the hooks on `comint-mode-hook' and +`pure-eval-mode-hook' (in that order)." + + (interactive) + (kill-all-local-variables) + (comint-mode) + (set-syntax-table (make-syntax-table)) + (modify-syntax-entry ?_ "_") + (modify-syntax-entry ?\. "_") + (modify-syntax-entry ?\+ ".") + (modify-syntax-entry ?\- ".") + (modify-syntax-entry ?\= ".") + (modify-syntax-entry ?\< ".") + (modify-syntax-entry ?\> ".") + (modify-syntax-entry ?\| ".") + (modify-syntax-entry ?\$ ".") + (modify-syntax-entry ?\/ ". 12") + (modify-syntax-entry ?\* ".") + (modify-syntax-entry ?\n ">") + (modify-syntax-entry ?\^m ">") + (setq major-mode 'pure-eval-mode) + (setq mode-name "Pure-Eval") + (use-local-map pure-eval-mode-map) + (setq comint-prompt-regexp pure-prompt-regexp) + (make-local-variable 'paragraph-start) + (setq paragraph-start comint-prompt-regexp) + (make-local-variable 'comment-start) + (make-local-variable 'comment-end) + (make-local-variable 'comment-column) + (make-local-variable 'comment-start-skip) + (make-local-variable 'comment-multi-line) + (setq comment-column 48 + comment-start-skip "// *\\|^#! *" + comment-multi-line nil) + (make-local-variable 'font-lock-defaults) + (setq font-lock-defaults + '(pure-eval-font-lock-keywords nil nil ((?_ . "w")))) + (setq comint-input-ring-file-name pure-histfile + comint-input-ring-size pure-histsize + comint-dynamic-complete-functions + '(pure-complete comint-dynamic-complete-filename)) + ;; mouse-sensitive messages (requires XEmacs) + (cond + ((string-match "XEmacs\\|Lucid" emacs-version) + (require 'mode-motion) + (setq mode-motion-hook 'pure-motion-hook))) + (comint-read-input-ring t) + (require 'easymenu) + (easy-menu-define pure-eval-mode-menu-map pure-eval-mode-map + "Menu keymap for Pure mode." pure-eval-mode-menu) + (easy-menu-add pure-eval-mode-menu-map pure-eval-mode-map) + (run-hooks 'pure-eval-mode-hook)) + +(if (string-match "XEmacs" emacs-version) +(defun pure-motion-hook (event) + (mode-motion-highlight-internal + event + #'beginning-of-line + #'(lambda () + (if (looking-at pure-msg-regexp) + (end-of-line)))) +)) + +;; run a Q script in a Q eval buffer + +;; make sure win32 XEmacs quotes arguments containing whitespace + +(if (string-match "XEmacs.*-win32" (emacs-version)) + (defun pure-quote-arg (x) + (if (string-match "[ \t]" x) (concat "\"" x "\"") x)) + (defun pure-quote-arg (x) x)) + +;;;###autoload +(defun run-pure (&rest args) + + "Run the interpreter with given arguments, in buffer *pure-eval*. + +The interpreter is invoked in the directory of the current buffer (current +default directory if no file is associated with the current buffer). +If buffer exists but process is not running, make new process. +If buffer exists and process is running, kill it and start a new one. + +Program used comes from variable `pure-prog-name'. The buffer is put in Pure +eval mode, giving commands for visiting source files, sending input, +manipulating the command history, etc. See `pure-eval-mode'. + +\(Type \\[describe-mode] in the Pure eval buffer for a list of commands.)" + + (interactive) + (let* ((dir (if buffer-file-name + (file-name-directory (buffer-file-name)) + default-directory)) + (pure-eval-active (not (null (get-buffer "*pure-eval*")))) + (pure-eval-running (comint-check-proc "*pure-eval*")) + (pure-eval-buffer (get-buffer-create "*pure-eval*"))) + (if (and pure-eval-running + pure-query-before-kill + (not + (y-or-n-p + "An interpreter process is still running. Start a new one? "))) + (message "Aborted") + (set-buffer pure-eval-buffer) + ;; give process some time to terminate, then blast it away + (if pure-eval-running + (progn + (comint-send-eof) + (sleep-for .5))) + (if (comint-check-proc "*pure-eval*") + (progn + (comint-kill-subjob) + (sleep-for .1))) + (cd dir) + (if (not pure-eval-active) + (pure-eval-mode) + (if (and pure-eval-running + (or (not (string-equal + comint-input-ring-file-name pure-histfile)) + (not (= comint-input-ring-size pure-histsize)))) + ;; reset history in case any of the options have changed + (progn + (comint-write-input-ring) + (setq comint-input-ring-file-name pure-histfile + comint-input-ring-size pure-histsize) + (comint-read-input-ring t)))) + (goto-char (point-max)) + ;; invoke the interpreter + (comint-exec pure-eval-buffer "pure-eval" pure-prog-name nil + (append (list "-i") args)) + ;; set up process parameters + (setq pure-output-list nil + pure-output-string nil + pure-receive-in-progress nil + pure-last-script nil + pure-last-dir dir + pure-last-path nil) + (set-process-sentinel (get-process "pure-eval") 'pure-eval-sentinel) + (if (not pure-query-before-kill) + (process-kill-without-query (get-process "pure-eval"))) + ;; switch to and go to the end of the eval buffer + (pop-to-buffer "*pure-eval*") + (goto-char (point-max)))) + ) + +(defun pure-run-script () + "Run the interpreter with the script in the current buffer, in buffer +*pure-eval*. See `run-pure' for details." + (interactive) + (let ((script-file + (if (buffer-file-name) + (file-name-nondirectory (buffer-file-name)) + (error "Buffer is not associated with any file")))) + (save-some-buffers) + (run-pure script-file) + (setq pure-last-script script-file))) + +;; find a script in the current directory or on the Pure library path + +(defun pure-locate-script (file) + (let ((script (locate-library file t (list "." pure-lib-dir)))) + (if script + script + (error (concat "File " file " not found"))))) + +;; visit source lines of error and debugging messages + +(defun pure-current-msg () + "Show the source line referenced by an error message on the current line +in the Pure eval buffer." + (interactive) + (let ((actwindow (selected-window))) + (if (get-buffer "*pure-eval*") + (pop-to-buffer "*pure-eval*") + (error "No script is running")) + (cond + ((save-excursion (forward-line 0) (looking-at pure-msg-regexp)) + (forward-line 0) (recenter 0) + (let (visit-buffer + visit-line + (file (match-string 2)) (line (match-string 3))) + (setq visit-buffer (find-file-noselect (pure-locate-script file))) + (setq visit-line (string-to-number line)) + (message "%s, line %s" file line) + (switch-to-buffer-other-window visit-buffer) + (goto-line visit-line))) + (t + (select-window actwindow) + (error "No message found"))))) + +(defun pure-current-msg-or-send () + "Depending on whether point is at an error message, either execute a +`pure-current-msg' or a `comint-send-input' command. This must be invoked +from the Pure eval buffer." + (interactive) + (if (save-excursion (forward-line 0) (looking-at pure-msg-regexp)) + (pure-current-msg) + (comint-send-input))) + +(defun pure-next-msg (&optional count) + "Advance to the next Pure error message below the current line in the Pure +eval buffer, and show the referenced source line in another window. When used +with a numeric argument n, advance to the nth message below the current line +(move backwards if numeric argument is negative). + +Note that this command can easily be fooled if the running script produces +some output, or you insert some text, which looks like an error message, so +you should take care what you're doing." + (interactive "P") + (if (and (numberp count) (< count 0)) + (pure-prev-msg (- count)) + (if (null count) (setq count 1)) + (let ((actwindow (selected-window))) + (if (get-buffer "*pure-eval*") + (pop-to-buffer "*pure-eval*") + (error "No script is running")) + (forward-line 0) + (if (looking-at pure-msg-regexp) + (if (save-excursion (end-of-line) (not (eobp))) + (forward-line 1) + (error "No more messages"))) + (let ((pos (re-search-forward pure-msg-regexp nil t count))) + (if pos + (let ((file (match-string 2)) (line (match-string 3))) + (goto-char pos) + (recenter 0) + (find-file-other-window (pure-locate-script file)) + (goto-line (string-to-number line)) + (message "%s, line %s" file line)) + (select-window actwindow) + (error "No more messages")))))) + +(defun pure-prev-msg (&optional count) + "Advance to previous Pure error messages above the current line in the Pure +eval buffer, and show the referenced source line in another window. Like +`pure-next-msg', but moves backward." + (interactive "P") + (if (and (numberp count) (< count 0)) + (pure-next-msg (- count)) + (if (null count) (setq count 1)) + (let ((actwindow (selected-window))) + (if (get-buffer "*pure-eval*") + (pop-to-buffer "*pure-eval*") + (error "No script is running")) + (forward-line 0) + (let ((pos (re-search-backward pure-msg-regexp nil t count))) + (if pos + (let ((file (match-string 2)) (line (match-string 3))) + (goto-char pos) + (recenter 0) + (find-file-other-window (pure-locate-script file)) + (goto-line (string-to-number line)) + (message "%s, line %s" file line)) + (select-window actwindow) + (error "No more messages")))))) + +(defun pure-last-msg () + "Advance to the last message in a contiguous sequence of error messages at +or below the current line, and show the referenced source line in another +window." + (interactive) + (let ((actwindow (selected-window))) + (if (get-buffer "*pure-eval*") + (pop-to-buffer "*pure-eval*") + (error "No script is running")) + (forward-line 0) + (let ((pos + (if (looking-at pure-msg-regexp) + (point) + (re-search-forward pure-msg-regexp nil t)))) + (if pos + (progn + (goto-char pos) + (while (and (save-excursion (end-of-line) (not (eobp))) + (save-excursion (forward-line 1) + (looking-at pure-msg-regexp))) + (forward-line 1)) + (let ((file (match-string 2)) (line (match-string 3))) + (recenter 0) + (find-file-other-window (pure-locate-script file)) + (goto-line (string-to-number line)) + (message "%s, line %s" file line))) + (select-window actwindow) + (error "No more messages"))))) + +(defun pure-first-msg () + "Advance to the first message in a contiguous sequence of error messages at +or above the current line, and show the referenced source line in another +window." + (interactive) + (let ((actwindow (selected-window))) + (if (get-buffer "*pure-eval*") + (pop-to-buffer "*pure-eval*") + (error "No script is running")) + (forward-line 0) + (let ((pos + (if (looking-at pure-msg-regexp) + (point) + (re-search-backward pure-msg-regexp nil t)))) + (if pos + (progn + (goto-char pos) + (while (and (not (bobp)) + (save-excursion (forward-line -1) + (looking-at pure-msg-regexp))) + (forward-line -1)) + (let ((file (match-string 2)) (line (match-string 3))) + (recenter 0) + (find-file-other-window (pure-locate-script file)) + (goto-line (string-to-number line)) + (message "%s, line %s" file line))) + (select-window actwindow) + (error "No more messages"))))) + +(defun pure-mouse-msg (event) + "Show the source line referenced by an error message under the mouse." + (interactive "e") + (mouse-set-point event) + (if (save-excursion (forward-line 0) (looking-at pure-msg-regexp)) + (progn (forward-line 0) (pure-current-msg)) + (mouse-yank event))) + +;; visit main script and the eval buffer + +(defun pure-find-script () + "Visit the script currently running in the Pure eval buffer." + (interactive) + (if (and pure-last-dir pure-last-script) + (if (not (string-equal (concat pure-last-dir pure-last-script) + (buffer-file-name))) + (find-file-other-window (concat pure-last-dir pure-last-script))) + (error "No script is running"))) + +(defun pure-goto-input-line () + "Move to the prompt in the Pure eval buffer." + (interactive) + (if (get-buffer "*pure-eval*") + (progn (pop-to-buffer "*pure-eval*") (goto-char (point-max))) + (error "No script is running"))) + +;; completion + +;; XXXFIXME: Currently this just calls the comint-dynamic-complete function, +;; as the Pure interpreter doesn't understand the completion_matches command +;; right now. + +(defun pure-complete () + "Perform completion on the token preceding point." + (interactive) + (comint-dynamic-complete)) + +; (defun pure-complete () +; "Perform completion on the token preceding point." +; (interactive) +; (if (pure-at-command-prompt-p) +; (let* ((end (point)) +; (command +; (save-excursion +; ;; skip over anything but whitespace, quotes and parentheses +; (skip-syntax-backward "w_.\\$'<>") +; (and (looking-at pure-prompt-regexp) +; (goto-char (match-end 0))) +; (buffer-substring-no-properties (point) end)))) +; (pure-send-list-and-digest +; (list (concat "completion_matches \"" command "\"\n"))) +; ;; Sort the list +; (setq pure-output-list +; (sort pure-output-list 'string-lessp)) +; ;; Remove duplicates +; (let* ((x pure-output-list) +; (y (cdr x))) +; (while y +; (if (string-equal (car x) (car y)) +; (setcdr x (setq y (cdr y))) +; (setq x y +; y (cdr y))))) +; ;; And let comint handle the rest +; (comint-dynamic-simple-complete command pure-output-list)))) + +;; send commands to the Q interpreter and digest their results + +(defun pure-output-digest (proc string) + (setq string (concat pure-output-string string)) + (while (string-match "\n" string) + (setq pure-output-list + (append pure-output-list + (list (substring string 0 (match-beginning 0)))) + string (substring string (match-end 0)))) + (if (string-match pure-prompt-regexp string) + (setq pure-receive-in-progress nil)) + (setq pure-output-string string)) + +(defun pure-send-list-and-digest (list) + (let* ((pure-eval-buffer (get-buffer "*pure-eval*")) + (proc (get-buffer-process pure-eval-buffer)) + (filter (process-filter proc)) + string) + (set-process-filter proc 'pure-output-digest) + (setq pure-output-list nil) + (unwind-protect + (while (setq string (car list)) + (setq pure-output-string nil + pure-receive-in-progress t) + (comint-send-string proc string) + (while pure-receive-in-progress + (accept-process-output proc)) + (setq list (cdr list))) + (set-process-filter proc filter)))) + +;; perform cleanup when the interpreter process is killed + +(defun pure-eval-sentinel (proc msg) + (if (null (buffer-name (process-buffer proc))) + ;; buffer has been killed + (set-process-buffer proc nil) + (set-buffer (process-buffer proc)) + (comint-write-input-ring) + (setq pure-last-dir nil + pure-last-script nil) + (goto-char (point-max)) + (insert "\n*** Process Pure-Eval finished ***\n"))) + +;; make sure that the history is written when exiting emacs +(add-hook 'kill-emacs-hook + (lambda () + (let ((pure-eval-buffer (get-buffer "*pure-eval*"))) + (cond + (pure-eval-buffer + (set-buffer pure-eval-buffer) + (comint-write-input-ring)))))) + +;; autoindent and fill support (preliminary) + +;; XXXFIXME: This needs to be completely rewritten. We still use the Q +;; indentation rules here (with some minor tweaks), which don't work all that +;; well even in Q mode. + +(defun pure-electric-delim (arg) + "Insert character and correct line's indentation." + (interactive "P") + (if (and (not arg) + (save-excursion + (skip-chars-backward " \t") + (bolp))) + (progn + (insert last-command-char) + (pure-indent-line) + (delete-char -1))) + (self-insert-command (prefix-numeric-value arg))) + +;; find the position of the previous rule's rhs (`=' delimiter) +(defun pure-prev-rhs () + (if (not (pure-backward-to-delim "=")) + nil + ;; back up to beginning of rule, then find 1st `=' at toplevel + (beginning-of-rule) + (if (not (pure-forward-to-delim "=")) + nil ; this shouldn't happen + (backward-char) + (point)))) + +(defvar pure-qual-keywords "\\<\\(if\\|otherwise\\|when\\|with\\)\\>") + +(defun pure-at-qual () + (and (looking-at pure-qual-keywords) + (or (not (looking-at "else")) + (save-excursion + (backward-word 1) + (not (looking-at "or")))))) + +;; find the position of the previous qualifier or conditional keyword (if, +;; else, otherwise, etc.) +(defun pure-prev-qual () + (if (not (pure-backward-to-regexp pure-qual-keywords)) nil + (let ((success t) (done nil)) + (while (and success (not done)) + (setq done (pure-at-qual)) + (setq success (or done (pure-backward-to-regexp pure-qual-keywords)))) + (if (not done) nil + (let* ((p0 (point)) + (p (progn (beginning-of-line) + (if (pure-forward-to-regexp pure-qual-keywords) + (backward-word 1)) + (if (pure-at-qual) (point) p0)))) + (goto-char p)))))) + +(defun pure-move-to-indent-column () + "At end of line, move forward to the current `=' indentation column, as +given by the most recent rule or the \\[pure-default-rhs-indent] variable." + (interactive) + (if (save-excursion + (skip-chars-forward " \t") + (eolp)) + (let ((col (current-column)) + (icol (save-excursion + (if (pure-prev-rhs) + (current-column) + pure-default-rhs-indent)))) + (if (> icol col) + (move-to-column icol t))))) + +(defun pure-comment-indent () + "Compute Pure comment indentation." + (cond ((looking-at "^#!") 0) + ((looking-at "/[/*]") + (let ((indent (pure-calculate-indent))) + (if (consp indent) (car indent) indent))) + (t + (save-excursion + (skip-chars-backward " \t") + (max (current-column) +;; (max (1+ (current-column)) ;Insert one space at least + comment-column))) + )) + +;; FIXME: This stuff (beginning-of-rule, end-of-rule) is broken. It gets +;; caught in block comments easily -- unfortunately, Pure definitions may look a +;; lot like plain comment text ;-). There really seems to be no good way of +;; doing this, because these routines need to be fast, so we can't just parse +;; the whole file any time they are invoked. + +;; As implemented, beginning-of-rule looks for a line starting with a +;; word/symbol constituent, open parentheses, string, or optional whitespace +;; followed by a `=' character, whereas end-of-rule searches for a semicolon +;; at line end (with maybe some single-line comments and whitespace in +;; between). So reasonable formatting styles should all be parsed correctly. + +(defun beginning-of-rule () + "Move backward to beginning of current or previous rule." + (interactive) + (if (or + (if (and (> (current-column) 0) + (save-excursion + (beginning-of-line) + (looking-at "[ \t]*="))) + (progn (beginning-of-line) t) + nil) + (re-search-backward "^\\w\\|^\\s_\\|^\\s(\\|^\\s\"\\|^[ \t]*=" + (point-min) 'mv)) + (let ((p (point))) + (pure-backward-to-noncomment (point-min)) + (if (and (not (bobp)) + (/= (preceding-char) ?\;) + (/= (preceding-char) ?\:)) + (beginning-of-rule) + (goto-char p))))) + +(defun end-of-rule () + "Move forward to end of current or next rule." + (interactive) + (let ((p (point))) + (while (and (re-search-forward +;;; match ";" + whitespace/comment sequence + "\n" +";\\([ \t]+\\|/\\*+\\([^\n\\*]\\|\\*[^\n/]\\)*\\*+/\\)*\\(//.*\\)?\n" + nil 'move) + (/= (1+ (match-beginning 0)) + (save-excursion + (pure-backward-to-noncomment p) + (point))))))) + +(defun pure-indent-line () + "Indent current line as Pure code. +Return the amount the indentation changed by." + (interactive) + (let ((indent (pure-calculate-indent nil)) + start-of-block + beg shift-amt + (case-fold-search nil) + (pos (- (point-max) (point)))) + (if (listp indent) + (progn + (setq start-of-block (cdr indent)) + (setq indent (car indent))) + (setq start-of-block 0)) + (beginning-of-line) + (setq beg (point)) + (setq indent + (cond ((eq indent nil) (current-indentation)) + ((eq indent t) (pure-calculate-indent-within-comment)) + (t + (skip-chars-forward " \t") + (cond ((looking-at "^#!") 0) + ((= (following-char) ?\)) start-of-block) + (t indent))))) + (skip-chars-forward " \t") + (setq shift-amt (- indent (current-column))) + (if (zerop shift-amt) + (if (> (- (point-max) pos) (point)) + (goto-char (- (point-max) pos))) + (delete-region beg (point)) + (indent-to indent) + ;; If initial point was within line's indentation, + ;; position after the indentation. Else stay at same point in text. + (if (> (- (point-max) pos) (point)) + (goto-char (- (point-max) pos)))) + shift-amt)) + +(defvar pure-decl-keywords + (concat "\\<\\(" + "infix[lr]?\\|let\\|nullary\\|p\\(refix\\|ostfix\\)\\|using" + "\\)\\>")) + +(defun pure-indent-col (col pos) + (if pos + (let ((col2 (save-excursion (goto-char pos) (current-column)))) + (cons col col2)) + col) +) + +;; TODO: proper indentation of parenthesized if-then-else constructs +(defun pure-calculate-indent (&optional parse-start) + "Return appropriate indentation for current line as Pure code. +In usual case returns an integer: the column to indent to. +Returns nil if line starts inside a string, t if in a comment, +\(indent . start-of-block\) if line is within a paren block." + (save-excursion + (beginning-of-line) + (let ((indent-point (point)) + (case-fold-search nil) + state + containing-sexp + (at-decl nil) + (lhs-extra-indent 0) + (rhs-extra-indent + (save-excursion + (skip-chars-forward " \t") + (if (pure-at-qual) pure-extra-qual-indent 0))) + (following-character + (save-excursion (skip-chars-forward " \t") (following-char)))) + (if parse-start + (goto-char parse-start) + (let ((p (point))) + (pure-backward-to-noncomment (point-min)) + (if (and (not (bobp)) + (/= (preceding-char) ?\;)) + (beginning-of-rule) + (goto-char p)))) + ;; extra indent for continuation lines in declarations + (if (and (< (point) indent-point) + (looking-at pure-decl-keywords)) + (setq at-decl t + lhs-extra-indent pure-extra-decl-indent)) + (while (< (point) indent-point) + (setq parse-start (point)) + (setq state (parse-partial-sexp (point) indent-point 0)) + (setq containing-sexp (car (cdr state)))) + ;; the above sometimes craps out even if we're inside a balanced pair + ;; of parens, but the following should work in any case + (if (null containing-sexp) + (setq containing-sexp + (condition-case nil + (scan-lists indent-point -1 1) + (error nil)))) + (if (or (nth 3 state) (nth 4 state)) + ;; return nil or t if should not change this line + (nth 4 state) + ;; Check to see whether we are inside a sexp, on the lhs, rhs, + ;; qualifier, or at the = of a rule. + (goto-char indent-point) + (pure-backward-to-noncomment (or parse-start (point-min))) + (let (p0 p1 p2 p3 col1 col2 col3) + (setq p0 containing-sexp + p1 (save-excursion + (pure-backward-to-delim ";") + (point)) + p2 (save-excursion + (if (pure-prev-rhs) (point) 0)) + p3 (save-excursion + (if (pure-prev-qual) (point) 0))) + (if (> p2 0) + (setq col1 (save-excursion + (goto-char p2) + (current-column)) + col2 (save-excursion + (goto-char p2) + (forward-char) + (skip-chars-forward " \t") + (current-column)) + col3 (save-excursion + (goto-char p3) + (current-column))) + (setq col1 pure-default-rhs-indent + col2 pure-default-rhs-indent + col3 pure-default-rhs-indent)) + (cond + ((and (not (null p0)) (>= p0 (max p1 p2 p3))) + ;; inside a sexp (pair of balanced parens): indent at the column + ;; to the right of the paren + (let ((col (save-excursion (goto-char p0) (current-column)))) + (cons (1+ col) col))) + ((or (= following-character ?=) + (= following-character ?\;) + (and at-decl (= following-character ?|))) + ;; followup eqns (initial =), initial semi, and initial | + ;; in declarations are indented at preceding = + (pure-indent-col col1 p0)) + ((or at-decl (> p1 p2)) + ;; lhs: indent at lhs-extra-indent + (pure-indent-col lhs-extra-indent p0)) + ((> p3 p2) + ;; qualifier/conditional: indent at column of previous qualifier + ;; keyword plus pure-extra-qual-indent if no keyword at bol + (pure-indent-col + (+ col3 (if (= 0 rhs-extra-indent) pure-extra-qual-indent 0)) p0)) + (t + ;; rhs: indent at first token behind preceding = + ;; add rhs-extra-indent for initial qualifier keyword + (pure-indent-col (+ col2 rhs-extra-indent) p0)))))))) + +(defun pure-calculate-indent-within-comment () + "Return the indentation amount for line, assuming that +the current line is to be regarded as part of a block comment." + (let (end star-start) + (save-excursion + (beginning-of-line) + (skip-chars-forward " \t") + (setq star-start (= (following-char) ?\*)) + (skip-chars-backward " \t\n") + (setq end (point)) + (beginning-of-line) + (skip-chars-forward " \t") + (and (re-search-forward "/\\*[ \t]*" end t) + star-start + (goto-char (1+ (match-beginning 0)))) + (current-column)))) + +(defun pure-backward-to-noncomment (lim) + (let (opoint stop) + (while (not stop) + (skip-chars-backward " \t\n\f" lim) + (setq opoint (point)) + (if (and (>= (point) (+ 2 lim)) + (= (preceding-char) ?/) (= (char-after (- (point) 2)) ?*)) + (search-backward "/*" lim 'mv) + (let ((p (max lim (save-excursion (beginning-of-line) (point))))) + (if (nth 4 (parse-partial-sexp p (point))) + (re-search-backward "^#!\\|//" p 'mv) + (goto-char opoint) + (setq stop t))))))) + +(defun pure-forward-to-noncomment (lim) + (forward-char 1) + (while (progn + (skip-chars-forward " \t\n" lim) + (looking-at "^#!\\|//\\|/\\*")) + ;; Skip over comments and labels following openparen. + (if (looking-at "^#!\\|//") + (forward-line 1) + (forward-char 2) + (search-forward "*/" lim 'mv)))) + +;; some added stuff for finding = and ; delimiters in rules + +(defun pure-at-toplevel-p () + (let (p state) + (save-excursion + (setq p (save-excursion + (beginning-of-rule) + (point))) + (setq state (parse-partial-sexp p (point))) + (not (or (nth 1 state) + (nth 3 state) + (nth 4 state)))))) + +(defun pure-backward-to-delim (delim-str) + (let ((success nil)) + (while (and (search-backward delim-str nil 'mv) + (progn + (setq success (pure-at-toplevel-p)) + (not success)) + (not (bobp)))) + (if success (point) nil))) + +(defun pure-forward-to-delim (delim-str) + (let ((success nil)) + (while (and (search-forward delim-str nil 'mv) + (progn + (setq success (pure-at-toplevel-p)) + (not success)) + (not (eobp)))) + (if success (point) nil))) + +(defun pure-backward-to-regexp (delim-str) + (let ((success nil)) + (while (and (re-search-backward delim-str nil 'mv) + (progn + (setq success (pure-at-toplevel-p)) + (not success)) + (not (bobp)))) + (if success (point) nil))) + +(defun pure-forward-to-regexp (delim-str) + (let ((success nil)) + (while (and (re-search-forward delim-str nil 'mv) + (progn + (setq success (pure-at-toplevel-p)) + (not success)) + (not (eobp)))) + (if success (point) nil))) + +(defun pure-indent-current-rule () + "Indent all lines in the current rule." + (interactive) + (let (p) + (save-excursion + (end-of-rule) + (setq p (point-marker)) + (beginning-of-rule) + (while (< (point) p) + (pure-indent-line) + (forward-line 1))))) + +;; this stuff is from (XEmacs) cc-mode + +(defun pure-indent-region (start end) + ;; Indent every line whose first char is between START and END inclusive. + (let (p) + (save-excursion + (goto-char start) + (setq p (copy-marker end)) + (while (and (bolp) + (not (eobp)) + (< (point) p)) + (pure-indent-line) + (forward-line 1))))) + +(defun pure-indent-line-or-region () + "When the region is active, indent it. Otherwise indent the current line." + (interactive) + (if (pure-region-is-active-p) + (pure-indent-region (region-beginning) (region-end)) + (pure-indent-line))) + +;; paragraph fill from (XEmacs) cc-mode, boiled down for Pure mode + +(defmacro pure-safe (&rest body) + ;; safely execute BODY, return nil if an error occurred + (` (condition-case nil + (progn (,@ body)) + (error nil)))) + +(defmacro pure-forward-sexp (&optional arg) + ;; like forward-sexp except + ;; 1. this is much stripped down from the XEmacs version + ;; 2. this cannot be used as a command, so we're insulated from + ;; XEmacs' losing efforts to make forward-sexp more user + ;; friendly + ;; 3. Preserves the semantics most of CC Mode is based on + (or arg (setq arg 1)) + `(goto-char (or (scan-sexps (point) ,arg) + ,(if (numberp arg) + (if (> arg 0) `(point-max) `(point-min)) + `(if (> ,arg 0) (point-max) (point-min)))))) + +(defmacro pure-backward-sexp (&optional arg) + ;; See pure-forward-sexp and reverse directions + (or arg (setq arg 1)) + `(pure-forward-sexp ,(if (numberp arg) (- arg) `(- ,arg)))) + +(defsubst pure-point (position) + ;; Returns the value of point at certain commonly referenced POSITIONs. + ;; POSITION can be one of the following symbols: + ;; + ;; bol -- beginning of line + ;; eol -- end of line + ;; + ;; This function does not modify point or mark. + (let ((here (point))) + (cond + ((eq position 'bol) (beginning-of-line)) + ((eq position 'eol) (end-of-line)) + (t (error "unknown buffer position requested: %s" position)) + ) + (prog1 + (point) + (goto-char here)))) + +(defun pure-literal-limits (&optional lim near) + ;; Returns a cons of the beginning and end positions of the comment + ;; or string surrounding point (including both delimiters), or nil + ;; if point isn't in one. If LIM is non-nil, it's used as the + ;; "safe" position to start parsing from. If NEAR is non-nil, then + ;; the limits of any literal next to point is returned. "Next to" + ;; means there's only [ \t] between point and the literal. The + ;; search for such a literal is done first in forward direction. + ;; + ;; This is the Emacs 19 version. + (save-excursion + (let* ((pos (point)) +;;; FIXME: need a reasonable replacement for `beginning-of-defun' (bod) here. +;;; (lim (or lim (pure-point 'bod))) + (lim (or lim (point-min))) + (state (parse-partial-sexp lim (point)))) + (cond ((nth 3 state) + ;; String. Search backward for the start. + (while (nth 3 state) + (search-backward (make-string 1 (nth 3 state))) + (setq state (parse-partial-sexp lim (point)))) + (cons (point) (or (pure-safe (pure-forward-sexp 1) (point)) + (point-max)))) + ((nth 7 state) + ;; Line comment. Search from bol for the comment starter. + (beginning-of-line) + (setq state (parse-partial-sexp lim (point)) + lim (point)) + (while (not (nth 7 state)) + (search-forward "//") ; Should never fail. + (setq state (parse-partial-sexp + lim (point) nil nil state) + lim (point))) + (backward-char 2) + (cons (point) (progn (forward-comment 1) (point)))) + ((nth 4 state) + ;; Block comment. Search backward for the comment starter. + (while (nth 4 state) + (search-backward "/*") ; Should never fail. + (setq state (parse-partial-sexp lim (point)))) + (cons (point) (progn (forward-comment 1) (point)))) + ((pure-safe (nth 4 (parse-partial-sexp ; Can't use prev state due + lim (1+ (point))))) ; to bug in Emacs 19.34. + ;; We're standing in a comment starter. + (backward-char 2) + (cons (point) (progn (forward-comment 1) (point)))) + (near + (goto-char pos) + ;; Search forward for a literal. + (skip-chars-forward " \t") + (cond + ((eq (char-syntax (or (char-after) ?\ )) ?\") ; String. + (cons (point) (or (pure-safe (pure-forward-sexp 1) (point)) + (point-max)))) + ((looking-at pure-comment-start-regexp) ; Line or block comment. + (cons (point) (progn (forward-comment 1) (point)))) + (t + ;; Search backward. + (skip-chars-backward " \t") + (let ((end (point)) beg) + (cond + ((eq (char-syntax (or (char-before) ?\ )) ?\") ; String. + (setq beg (pure-safe (pure-backward-sexp 1) (point)))) + ((and (pure-safe (forward-char -2) t) + (looking-at "*/")) + ;; Block comment. Due to the nature of line + ;; comments, they will always be covered by the + ;; normal case above. + (goto-char end) + (forward-comment -1) + ;; If LIM is bogus, beg will be bogus. + (setq beg (point)))) + (if beg (cons beg end)))))) + )))) + +(defconst pure-comment-start-regexp "\\(/[/*]\\|^#!\\)") + +;; FIXME: I'm wondering why this code messes up the fontification of comment +;; paragraphs since the same code apparently works in C/C++ mode, and the +;; comment syntax is also the same. :( This only happens with XEmacs +;; (21.1p10), no problems with GNU Emacs. Maybe the XEmacs font-lock stuff is +;; broken, or has some special built-in support for the C modes? Anyway, if +;; anyone knows how to fix this please let me know. -AG + +(defun pure-fill-paragraph (&optional arg) + "Like \\[fill-paragraph] but handles Pure (i.e., C/C++) style +comments. If any of the current line is a comment or within a comment, +fill the comment or the paragraph of it that point is in, +preserving the comment indentation or line-starting decorations. + +If point is inside multiline string literal, fill it. This currently +does not respect escaped newlines, except for the special case when it +is the very first thing in the string. The intended use for this rule +is in situations like the following: + +description = \"\\ +A very long description of something that you want to fill to make +nicely formatted output.\"\; + +If point is in any other situation, i.e. in normal code, do nothing. + +Optional prefix ARG means justify paragraph as well." + (interactive "*P") + (let* ((point-save (point-marker)) + limits + comment-start-place + (first-line + ;; Check for obvious entry to comment. + (save-excursion + (beginning-of-line) + (skip-chars-forward " \t") + (and (looking-at comment-start-skip) + (setq comment-start-place (point))))) + (re1 "\\|\\([ \t]*/\\*[ \t]*\\|[ \t]*\\*/[ \t]*\\|[ \t/*]*\\)")) + (if (save-excursion + (beginning-of-line) + (looking-at "#!\\|.*//")) + (let ((fill-prefix fill-prefix) + ;; Lines containing just a comment start or just an end + ;; should not be filled into paragraphs they are next + ;; to. + (paragraph-start (concat paragraph-start re1 "$")) + (paragraph-separate (concat paragraph-separate re1 "$"))) + (save-excursion + (beginning-of-line) + ;; Move up to first line of this comment. + (while (and (not (bobp)) + (looking-at "[ \t]*//[ \t]*[^ \t\n]")) + (forward-line -1)) + (if (not (looking-at ".*//[ \t]*[^ \t\n]")) + (forward-line 1)) + ;; Find the comment start in this line. + (re-search-forward "[ \t]*//[ \t]*") + ;; Set the fill-prefix to be what all lines except the first + ;; should start with. But do not alter a user set fill-prefix. + (if (null fill-prefix) + (setq fill-prefix (buffer-substring (match-beginning 0) + (match-end 0)))) + (save-restriction + ;; Narrow down to just the lines of this comment. + (narrow-to-region (pure-point 'bol) + (save-excursion + (forward-line 1) + (while + (looking-at (regexp-quote fill-prefix)) + (forward-line 1)) + (point))) + (or (pure-safe + ;; fill-paragraph sometimes fails to detect when we + ;; are between paragraphs. + (beginning-of-line) + (search-forward fill-prefix (pure-point 'eol)) + (looking-at paragraph-separate)) + ;; Avoids recursion + (let (fill-paragraph-function) + (fill-paragraph arg)))))) + ;; else C style comments + (if (or first-line + ;; t if we enter a comment between start of function and + ;; this line. + (save-excursion + (setq limits (pure-literal-limits)) + (and (consp limits) + (save-excursion + (goto-char (car limits)) + (looking-at pure-comment-start-regexp)))) + ;; t if this line contains a comment starter. + (setq first-line + (save-excursion + (beginning-of-line) + (prog1 + (re-search-forward comment-start-skip + (save-excursion (end-of-line) + (point)) + t) + (setq comment-start-place (point))))) + ;; t if we're in the whitespace after a comment ender + ;; which ends its line. + (and (not limits) + (when (and (looking-at "[ \t]*$") + (save-excursion + (beginning-of-line) + (looking-at ".*\\*/[ \t]*$"))) + (save-excursion + (forward-comment -1) + (setq comment-start-place (point))) + t))) + ;; Inside a comment: fill one comment paragraph. + (let ((fill-prefix + (or + ;; Keep user set fill prefix if any. + fill-prefix + ;; The prefix for each line of this paragraph + ;; is the appropriate part of the start of this line, + ;; up to the column at which text should be indented. + (save-excursion + (beginning-of-line) + (if (looking-at ".*/\\*.*\\*/") + (progn (re-search-forward comment-start-skip) + (make-string (current-column) ?\ )) + (if first-line + (forward-line 1) + (if (and (looking-at "[ \t]*\\*/") + (not (save-excursion + (forward-line -1) + (looking-at ".*/\\*")))) + (forward-line -1))) + + (let ((line-width (progn (end-of-line) + (current-column)))) + (beginning-of-line) + (prog1 + (buffer-substring + (point) + + ;; How shall we decide where the end of the + ;; fill-prefix is? + (progn + (skip-chars-forward " \t*" (pure-point 'eol)) + ;; kludge alert, watch out for */, in + ;; which case fill-prefix should *not* + ;; be "*"! + (if (and (eq (char-after) ?/) + (eq (char-before) ?*)) + (forward-char -1)) + (point))) + + ;; If the comment is only one line followed + ;; by a blank line, calling move-to-column + ;; above may have added some spaces and tabs + ;; to the end of the line; the fill-paragraph + ;; function will then delete it and the + ;; newline following it, so we'll lose a + ;; blank line when we shouldn't. So delete + ;; anything move-to-column added to the end + ;; of the line. We record the line width + ;; instead of the position of the old line + ;; end because move-to-column might break a + ;; tab into spaces, and the new characters + ;; introduced there shouldn't be deleted. + + ;; If you can see a better way to do this, + ;; please make the change. This seems very + ;; messy to me. + (delete-region (progn (move-to-column line-width) + (point)) + (progn (end-... [truncated message content] |
From: <ag...@us...> - 2008-06-13 23:45:25
|
Revision: 213 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=213&view=rev Author: agraef Date: 2008-06-13 16:45:33 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Only pipe 'list' output through more if stdin is a tty. Modified Paths: -------------- pure/trunk/lexer.ll Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-06-13 19:02:09 UTC (rev 212) +++ pure/trunk/lexer.ll 2008-06-13 23:45:33 UTC (rev 213) @@ -448,9 +448,9 @@ else sout << nfuns << " functions, " << nrules << " rules\n"; } + FILE *fp; // FIXME: We should check that 'more' actually exists here. - FILE *fp = popen("more", "w"); - if (fp) { + if (isatty(fileno(stdin)) && (fp = popen("more", "w"))) { fputs(sout.str().c_str(), fp); pclose(fp); } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 19:02:13
|
Revision: 212 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=212&view=rev Author: agraef Date: 2008-06-13 12:02:09 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Update examples. Modified Paths: -------------- pure/trunk/examples/myutils.pure Modified: pure/trunk/examples/myutils.pure =================================================================== --- pure/trunk/examples/myutils.pure 2008-06-13 12:24:23 UTC (rev 211) +++ pure/trunk/examples/myutils.pure 2008-06-13 19:02:09 UTC (rev 212) @@ -31,63 +31,91 @@ nrotate n::int l = protate nm l when ll = #l; nm = ll + (n mod ll) end if n<0; = protate nm l when nm = n mod #l end; -// interpret any nonzero result as true: prevents errors in conditions -nonzero 0 = 0; -nonzero x = 1; +// increment and decrement +succ x::int = 1+x; +pred x::int = x-1; -// The Queens problem: -// the solution is only the rows permutation, without the ordered columns (1..n) -// full 2D board coordinates can be produced with: zip (1..n) (queens n); +// Now follow several different solutions to the Queens problem +// allqueens gives all solutions but is slow +// queens and tailqueens give one (different) solution each +// thequeens does no search and is very fast even for large boards +// Example: (allqueens 8) lists all 92 solutions, +// >queens 8; gives solution number 52 in the allqueens' list, +// >tailqueens 8; gives number 89, which is a simple reflection of 52 +// >map succ (thequeens 8); gives solution number 56 safe _ _ [] = 1; safe id::int j::int (j2::int:l) = - if (j==j2) || (id==j2-j) || (id==j-j2) then 0 else safe (id+1) j l; + if (j==j2) || (id==j2-j) || (id==j-j2) then 0 else safe (1+id) j l; -queens n::int = list (search n n n []) +allqueens n::int = searchall n n [] // returns all possible solutions - slow! with + searchall n::int 0 p = p; + searchall n::int i::int p = + tuple [searchall n (i-1) (j:p); j = 1..n; safe 1 j p] + end; + +// the solution is only the rows permutation, without the ordered columns (1..n) +// full 2D board coordinates can be reconstructed with zip (1..n) (queens n); + +nullary failed; +queens n::int = search n n n [] + with search _ 0 _ p = (); // last i, solved - search _ _ 0 _ = 0; // fail, run out of alternative js + search _ _ 0 _ = failed; // failed, run out of alternative js search n::int i::int j::int p = - if nonzero solution then j,solution // new i led to a solution - else search n i (j-1) p // or it failed, try another j + if (failed === solution) then search n i (j-1) p else j,solution when solution = search n (i-1) n (j:p); end if safe 1 j p; - = search n i (j-1) p // also try another j when unsafe + = search n i (j-1) p // also try another j when unsafe end; -// this concise backtracking tailqueens throw a single solution +// this concise backtracking tailrecursive version throws a single solution tailqueens n::int = catch id (srch n n n []) - with srch _ 0 _ p = throw p; srch _ _ 0 _ = 0; + with srch _ 0 _ p = throw p; srch _ _ 0 _ = failed; srch n::int i::int j::int p = if safe 1 j p then - ( if nonzero (srch n (i-1) n (j:p)) then 1 else srch n i (j-1) p ) + ( if failed === (srch n (i-1) n (j:p)) then srch n i (j-1) p else () ) else srch n i (j-1) p end; // thequeens encodes my no search solution which is my original discovery, -// to my knowledge the simplest known algorithm for this kind of a problem. +// to my knowledge the simplest known algorithm for this problem // there always exists one fundamental centre-symmetrical solution of this form, // representing an orbit of just four solutions, instead of the usual eight. // these few lines of code are self-contained (not calling any square checking). -// has been tested exhaustively from 0 to 5000 and individually for 50000. -thequeens 1 = [0]; thequeens n::int = no solution if n<4; -thequeens n::int = map (newsquare n) (0..(n-1)) - with newsquare n::int x::int = (start+2*x) mod n if x < halfn; - = (start2+2*(x-halfn)) mod n end //reflections - when halfn = n div 2; +// tested exhaustively from 0 to 5000 and individually for n = 50000. + +nullary nosolution; // returned for n=2 and n=3 when there are no solutions + +thequeens n::int = case n of + 1 = [0]; // trivial solution to one square board + 2 = nosolution; + 3 = nosolution; + n = map (newsquare n) (0..(n-1)) // rule for even sized boards n>3 + with newsquare n::int x::int + = (start+2*x) mod n if x < halfn; // right start square is crucial + = (start2+2*(x-halfn)) mod n // centre reflections fill the 2nd half + end + when + halfn = n div 2; // local variable halfn start = if (n mod 3) then (halfn-1) else 1; // (n mod 3) == 0 is special - start2 = n-((start + 2*(halfn-1)) mod n)-1 end if (n mod 2)==0; // even - = 0:(map (\x->1+x)(thequeens (n-1))); // corner start solves odd size boards! + start2 = n-((start + 2*(halfn-1)) mod n)-1 // start for the reflections + end if (n mod 2) == 0; // even sized boards finished + = 0:(map succ (thequeens (n-1))) // corner start 0: solves odd size boards! +end; // end of case and thequeens + +// Row numbering in thequeens was changed to "C style" 0..n-1 +// 2D board coordinates (1..n)x(1..n) can be reconstructed with: +fullboard simple = zip (1..(#simple)) (map succ simple); -// row numbering in thequeens was changed to the "C style" e.g. 0..7. -// full board coordinates, e.g. (1..8) x (1..8) can be reconstructed with: -fullboard simple = zip (1..(#simple)) (map (\x->1+x) simple); +// The rest are test utilities for the queens problem: // checks one queens solution either in 0..7 encoding or in 1..8 encoding. -// returns 1 for a correct result, including "no solution" for sizes 2 and 3. -// returns 0 if a queen attack exists anywhere in the presented solution +// returns 1 for a correct result, including "nosolution" for sizes 2 and 3. +// returns 0 if a queen attack exists anywhere in the presented 'solution': checkqs [] = 1; checkqs (s::int:l) = if safe 1 s l then checkqs l else 0; -checkqs (no solution) = 1; +checkqs (nosolution) = 1; -// conducts an exhaustive test of boards of all listed sizes. +// conducts an exhaustive test of solutions for boards of all listed sizes. // examples of use: >queenstest (1..1000); >queenstest (5000,4999..4990); queenstest [] = 1; queenstest (h:l) = if checkqs (thequeens h) then queenstest l else 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 12:24:15
|
Revision: 211 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=211&view=rev Author: agraef Date: 2008-06-13 05:24:23 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Updated ChangeLog. Modified Paths: -------------- pure/trunk/ChangeLog Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-13 11:33:13 UTC (rev 210) +++ pure/trunk/ChangeLog 2008-06-13 12:24:23 UTC (rev 211) @@ -1,3 +1,14 @@ +2008-06-13 Albert Graef <Dr....@t-...> + + * configure.ac, Makefile.in, etc.: Overhauled configury and bumped + the version number. + + Building a separate runtime lib on x86-64 works now (but requires + a patched LLVM, see the INSTALL file for details). Linking the + runtime lib on OSX should also work now. Moreover, it is now + possible to install different Pure versions in parallel, again see + the INSTALL file for details. + 2008-06-06 Albert Graef <Dr....@t-...> * 0.3 release. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 11:33:05
|
Revision: 210 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=210&view=rev Author: agraef Date: 2008-06-13 04:33:13 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Include proper version number in manpage. Modified Paths: -------------- pure/trunk/Makefile.in pure/trunk/pure.1.in Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-13 11:21:35 UTC (rev 209) +++ pure/trunk/Makefile.in 2008-06-13 11:33:13 UTC (rev 210) @@ -106,8 +106,8 @@ DISTFILES = COPYING ChangeLog INSTALL NEWS README TODO \ Makefile.in aclocal.m4 configure.ac configure config.h.in \ -config.guess config.sub install-sh \ -$(SOURCE) $(EXTRA_SOURCE) w3centities.c pure.cc pure.1 pure.xml pure.vim \ +config.guess config.sub install-sh $(SOURCE) $(EXTRA_SOURCE) w3centities.c \ +pure.cc pure.1 pure.1.in pure.xml pure.vim \ examples/*.pure lib/*.pure test/*.pure test/*.log .PHONY: all html dvi ps pdf clean realclean depend install uninstall strip \ @@ -115,7 +115,7 @@ # compilation -all: pure$(EXE) +all: pure$(EXE) pure.1 ifeq ($(sharedlib), yes) pure$(EXE): pure.o $(libpure) @@ -150,7 +150,7 @@ edit = sed -e 's,@version\@,$(version),g' -pure.1: configure pure.1.in +pure.1: configure.ac pure.1.in rm -f pure.1 pure.1.tmp $(edit) pure.1.in >pure.1.tmp mv pure.1.tmp pure.1 @@ -189,7 +189,7 @@ rm -f Makefile config.h config.log config.status $(dist).tar.gz realclean: distclean - rm -f $(addprefix $(srcdir)/, test/*.log $(EXTRA_SOURCE)) + rm -f $(addprefix $(srcdir)/, test/*.log $(EXTRA_SOURCE) pure.1) # dependencies (rerun configure after this) @@ -198,7 +198,7 @@ # installation -install: pure$(EXE) +install: pure$(EXE) pure.1 for x in $(addprefix $(DESTDIR), $(bindir) $(libdir)/pure-$(version) $(man1dir)); do $(INSTALL) -d $$x; done $(INSTALL) pure$(EXE) $(DESTDIR)$(bindir)/pure-$(version)$(EXE) ln -sf $(bindir)/pure-$(version)$(EXE) $(DESTDIR)$(bindir)/pure$(EXE) Modified: pure/trunk/pure.1.in =================================================================== --- pure/trunk/pure.1.in 2008-06-13 11:21:35 UTC (rev 209) +++ pure/trunk/pure.1.in 2008-06-13 11:33:13 UTC (rev 210) @@ -1,4 +1,4 @@ -.TH Pure 1 "March 2008" "Pure Version @version@" +.TH Pure 1 "June 2008" "Pure Version @version@" .SH NAME pure \- the Pure interpreter .SH SYNOPSIS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 11:21:32
|
Revision: 209 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=209&view=rev Author: agraef Date: 2008-06-13 04:21:35 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Include proper version number in manpage. Added Paths: ----------- pure/trunk/pure.1.in Removed Paths: ------------- pure/trunk/pure.1 Deleted: pure/trunk/pure.1 =================================================================== --- pure/trunk/pure.1 2008-06-13 11:21:12 UTC (rev 208) +++ pure/trunk/pure.1 2008-06-13 11:21:35 UTC (rev 209) @@ -1,1218 +0,0 @@ -.TH Pure 1 "March 2008" "Pure Version @version@" -.SH NAME -pure \- the Pure interpreter -.SH SYNOPSIS -\fBpure\fP [-h] [-i] [-n] [-v[\fIlevel\fP]] [\fIscript\fP ...] [-- \fIargs\fP ...] -.SH OPTIONS -.TP -.B -h -Print help message and exit. -.TP -.B -i -Force interactive mode (read commands from stdin). -.TP -.B -n -Suppress automatic inclusion of the prelude. -.TP -.B -v -Set verbosity level. See below for details. -.TP -.B -- -Stop option processing and pass the remaining command line arguments in the -.B argv -variable. -.SH DESCRIPTION -Pure is a modern-style functional programming language based on term -rewriting. Pure programs are basically collections of equational rules used to -evaluate expressions in a symbolic fashion by reducing them to normal form. A -brief overview of the language can be found in the \fBPURE OVERVIEW\fP section -below. (In case you're wondering, the name ``Pure'' actually refers to the -adjective. But you can also write it as ``PURE'' and take this as a recursive -acronym for the ``Pure Universal Rewriting Engine''.) -.PP -.B pure -is the Pure interpreter. The interpreter has an LLVM backend which -JIT-compiles Pure programs to machine code, hence programs run blazingly fast -and interfacing to C modules is easy, while the interpreter still provides a -convenient, fully interactive environment for running Pure scripts and -evaluating expressions. -.PP -If any source scripts are specified on the command line, they are loaded and -executed, after which the interpreter exits. Otherwise the interpreter enters -the interactive read-eval-print loop. You can also use the -.B -i -option to enter the interactive loop (continue reading from stdin) even after -processing some source scripts. To exit the interpreter, just type the -.B quit -command or the end-of-file character (^D on Unix) at the beginning of the -command line. -.PP -When the interpreter is in interactive mode and reads from a tty, commands are -read using -.BR readline (3) -(providing completion for all commands listed in section -.B INTERACTIVE USAGE -below, as well as for global function and variable symbols) and, when exiting -the interpreter, the command history is stored in -.BR ~/.pure_history , -from where it is restored the next time you run the interpreter. -.PP -Options and source files are processed in the order in which they are given on -the command line. Processing of options and source files ends when the -.B -- -option is encountered. Any following parameters are passed to the executing -script by means of the global -.B argc -and -.B argv -variables. Moreover, the -.B version -variable is set to the Pure interpreter version, and the -.B sysinfo -variable provides information about the host system. -.PP -If available, the prelude script -.B prelude.pure -is loaded by the interpreter prior to any other other definitions, unless the -.B -n -option is specified. The prelude as well as other source scripts specified -with a relative pathname are first searched for in the current directory and -then in the directory specified with the -.B PURELIB -environment variable. If the -.B PURELIB -variable is not set, a system-specific default is used. -.PP -The -.B -v -option is most useful for debugging the interpreter, or if you are interested -in the code your program gets compiled to. The -.I level -argument is optional; it defaults to 1. Six different levels are implemented -at this time (two more bits are reserved for future extensions). For most -purposes, only the first two levels will be useful for the average Pure -programmer; the remaining levels are most likely to be used by the Pure -interpreter developers. -.TP -.B 1 (0x1) -denotes echoing of parsed definitions and expressions; -.TP -.B 2 (0x2) -adds special annotations concerning local bindings (de Bruijn indices, subterm -paths; this can be helpful to debug tricky variable binding issues); -.TP -.B 4 (0x4) -adds abstract code snippets (matching automata etc.; you probably want to see -this only when working on the guts of the interpreter). -.TP -.B 8 (0x8) -dumps the ``real'' output code (LLVM assembler, which is as close to the -native machine code for your program as it gets; you \fIdefinitely\fP don't -want to see this unless you have to inspect the generated code for bugs or -performance issues). -.TP -.B 16 (0x10) -adds debugging messages from the -.BR bison (1) -parser; useful for debugging the parser. -.TP -.B 32 (0x20) -adds debugging messages from the -.BR flex (1) -lexer; useful for debugging the lexer. -.PP -These values can be or'ed together, and, for convenience, can be specified in -either decimal or hexadecimal. Thus 0xff always gives you full debugging -output (which isn't most likely be used by anyone but the Pure developers). -.PP -Note that the -.B -v -option is only applied \fIafter\fP the prelude has been loaded. If you want to -debug the prelude, use the -.B -n -option and specify the -.B prelude.pure -file explicitly on the command line. Alternatively, you can also use the -interactive -.B list -command (see the \fBINTERACTIVE USAGE\fP section below) to list definitions -along with additional debugging information. -.SH PURE OVERVIEW -.PP -Pure is a fairly simple language. Programs are simply collections of -equational rules defining functions, \fBlet\fP commands binding global -variables, and expressions to be evaluated. Here's a simple example, entered -interactively in the interpreter: -.sp -.nf -> // my first Pure example -> fact 1 = 1; -> fact n::int = n*fact (n-1) \fBif\fP n>1; -> \fBlet\fP x = fact 10; x; -3628800 -.fi -.PP -The language is free-format (blanks are insignificant). As indicated, -definitions and expressions at the toplevel have to be terminated with a -semicolon. Comments have the same syntax as in C++ (using // for line-oriented -and /* ... */ for multiline comments; the latter may not be nested). -.PP -On the surface, Pure is quite similar to other modern functional languages -like Haskell and ML. But under the hood it is a much more dynamic and -reflective language, more akin to Lisp. In particular, Pure is dynamically -typed, so functions can be fully polymorphic and you can add to the definition -of an existing function at any time: -.sp -.nf -> fact 1.0 = 1.0; -> fact n::double = n*fact (n-1) \fBif\fP n>1; -> fact 10.0; -3628800.0 -> fact 10; -3628800 -.fi -.sp -Also, due to its term rewriting semantics, Pure can do symbolic evaluations: -.sp -.nf -> square x = x*x; -> square (a+b); -(a+b)*(a+b) -.fi -.PP -The Pure language provides built-in support for machine integers (32 bit), -bigints (implemented using GMP), floating point values (double precision -IEEE), character strings (UTF-8 encoded) and generic C pointers (these don't -have a syntactic representation in Pure, though, so they need to be created -with external C functions). Truth values are encoded as machine integers (as -you might expect, zero denotes ``false'' and any non-zero value ``true''). -.PP -Expressions are generally evaluated from left to right, innermost expressions -first, i.e., using -.I call by value -semantics. Pure also has a few built-in special forms (most notably, -conditional expressions and the short-circuit logical connectives && and ||) -which take some of their arguments using -.I call by name -semantics. -.PP -Expressions consist of the following elements: -.TP -.B Constants: \fR4711, 4711L, 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, 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, as in Python an integer literal immediately followed -by the uppercase letter ``L'' will always be interpreted as a bigint constant, -even if it fits into a machine integer. This 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 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 -.B \en -are also supported. Moreover, you can use symbolic character escapes of the -form -.BR \e&\fIname\fP; , -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 -underscore) and digits, starting with a letter. Case is significant, but it -doesn't carry any meaning (that's in contrast to languages like Prolog and Q, -where variables must be capitalized). Pure simply distinguishes function and -variable symbols on the left-hand side of an equation by the ``head = -function'' rule: Any symbol which occurs as the head symbol of a function -application is a function symbol, all other symbols are variables -- except -symbols explicitly declared as ``constant'' a.k.a. -.B nullary -symbols, see below. Another important thing to know is that in Pure, keeping -with the tradition of term rewriting, there's no distinction between -``defined'' and ``constructor'' function symbols; any function symbol can also -act as a constructor if it happens to occur in a normal form term. -.TP -.B Operator and constant symbols: \fRx+y, x==y, \fBnot\fP\ x -As indicated, these take the form of an identifier or a sequence of ASCII -punctuation symbols, as defined in the source using corresponding -\fBprefix\fP, \fBpostfix\fP and \fBinfix\fP declarations, which are discussed -in section DECLARATIONS. Enclosing an operator in parentheses, such as (+) or -(\fBnot\fP), turns it into an ordinary function symbol. Symbols can also be -defined as \fBnullary\fP to denote special constant symbols. See the prelude -for examples. -.TP -.B Lists and tuples: \fR[x,y,z], x..y, x:xs, x,y,z -The necessary constructors to build lists and tuples are actually defined in -the prelude: `[]' and `()' are the empty list and tuple, `:' produces list -``conses'', and `,' produces ``pairs''. As indicated, Pure provides the usual -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: 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 -one or more ``generator'' and ``filter'' clauses (the former bind a pattern to -values drawn from a list, the latter are just predicates determining which -generated elements should actually be added to the output list). List -comprehensions are in fact syntactic sugar for a combination of nested -lambdas, conditional expressions and ``catmaps'' (a list operation which -combines list concatenation and mapping a function over a list, defined in the -prelude), but they are often much easier to write. -.TP -.B Function applications: \fRfoo\ x\ y\ z -As in other modern FPLs, these are written simply as juxtaposition (i.e., in -``curried'' form) and associate to the left. Operator applications are written -using prefix, postfix or infix notation, as the declaration of the operator -demands, but are just ordinary function applications in disguise. E.g., x+y is -exactly the same as (+) x y. -.TP -.B Conditional expressions: if\fR\ x\ \fBthen\fR\ y\ \fBelse\fR\ z -Evaluates to y or z depending on whether x is ``true'' (i.e., a nonzero -integer). An exception is generated if the condition is not an -integer. Conditional expressions are special forms with call-by-name arguments -y and z; only one of the branches is actually evaluated. (The logical -operators && and || are treated in a similar fashion, in order to implement -short-circuit semantics.) -.TP -.B Lambdas: \fR\ex\ ->\ y -These work pretty much like in Haskell. More than one variable may be bound -(e.g, \ex\ y\ ->\ x*y), which is equivalent to a nested lambda -(\ex\ ->\ \ey\ ->\ x*y). Pure also fully supports pattern-matching lambda -abstractions which match a pattern against the lambda argument and bind -multiple lambda variables in one go, such as \e(x,y)\ ->\ x*y. -.TP -.B Case expressions: case\fR\ x\ \fBof\fR\ \fIrule\fR;\ ...\ \fBend -Matches an expression, discriminating over a number of different patterns; -similar to the Haskell \fBcase\fP construct. -.TP -.B When expressions: \fRx\ \fBwhen\fR\ \fIrule\fR;\ ...\ \fBend -An alternative way to bind local variables by matching a collection of subject -terms against corresponding patterns. Similar to Aardappel's \fBwhen\fP -construct, but Pure allows more than one definition. Note that multiple -definitions in a \fBwhen\fP clause are processed from left to right, so that -later definitions may refer to the variables in earlier ones. In fact, a -\fBwhen\fP expression with multiple definitions is treated like several -nested \fBwhen\fP expressions, with the first binding being the ``outermost'' -one. -.TP -.B With expressions: \fRx\ \fBwith\fR\ \fIrule\fR;\ ...\ \fBend\fR -Defines local functions. Like Haskell's \fBwhere\fP construct, but can be used -anywhere inside an expression (just like Aardappel's \fBwhere\fP, but Pure -uses the keyword \fBwith\fP which better lines up with \fBcase\fP and -\fBwhen\fP). Also note that while Haskell lets you do \fIboth\fP function -definitions and ``pattern bindings'' in its \fBwhere\fP clauses, in Pure you -have to use \fBwith\fP for the former and \fBwhen\fP for the latter. This is -necessary because Pure, in contrast to Haskell, does not distinguish between -defined functions and constructors and thus there is no magic to figure out -whether an equation is meant as a function definition or a pattern binding. -.PP -At the toplevel, a Pure program basically consists of rules a.k.a. equations -defining functions, variable definitions a.k.a. global ``pattern bindings'', -and expressions to be evaluated. -.TP -.B Rules: \fIlhs\fR = \fIrhs\fR; -The basic form can also be augmented with a condition \fBif\ \fIguard\fR -tacked on to the end of the rule (which restricts the applicability of the -rule to the case that the guard evaluates to a nonzero integer), or the -keyword -.B otherwise -denoting an empty guard which is always true (this is nothing but syntactic -sugar useful to point out the ``default'' case of a definition; the -interpreter just treats -.B otherwise -as a comment, so it can always be omitted). Moreover, the left-hand side can -be omitted if it is the same as for the previous rule. This provides a -convenient means to write out a collection of equations for the same left-hand -side which discriminates over different conditions: -.sp -.nf -\fIlhs\fR = \fIrhs\fB if \fIguard\fR; - = \fIrhs\fB if \fIguard\fR; - ... - = \fIrhs\fB otherwise\fR; -.fi -.sp -Rules are used to define functions at the toplevel and in \fBwith\fP -expressions, as well as inside \fBcase\fP and \fBwhen\fP expressions for the -purpose of performing pattern bindings (however, for obvious reasons the forms -without a left-hand side or including a guard are not permitted in \fBwhen\fP -expressions). When matching against a function call or the subject term in a -\fBcase\fP expression, the rules are always considered in the order in which -they are written, and the first matching rule (whose guard evaluates to a -nonzero value, if applicable) is picked. (Again, the \fBwhen\fP construct is -treated differently, because each rule is actually a separate pattern -binding.) -.sp -In any case, the left-hand side pattern must not contain repeated variables -(i.e., rules must be ``left-linear''), except for the ``anonymous'' variable -`_' which matches an arbitrary value without binding a variable -symbol. Moreover, a left-hand side variable may be followed by one of the -special type tags \fB::int\fP, \fB::bigint\fP, \fB::double\fP, \fB::string\fP, -to indicate that it can only match a constant value of the corresponding -built-in type. (This is useful if you want to write rules matching \fIany\fP -object of one of these types; note that there is no way to write out all -``constructors'' for the built-in types, as there are infinitely many.) -.TP -.B Global variable bindings: let\fR \fIlhs\fR = \fIrhs\fR; -This binds every variable in the left-hand side pattern to the corresponding -subterm of the evaluated right-hand side. -.TP -.B Toplevel expressions: \fIexpr\fR; -A singleton expression at the toplevel, terminated with a semicolon, simply -causes the given value to be evaluated (and the result to be printed, when -running in interactive mode). -.PP -Expressions are parsed according to the following precedence rules: Lambda -binds most weakly, followed by -.BR when , -.B with -and -.BR case , -followed by conditional expressions (\fBif\fP-\fBthen\fP-\fBelse\fP), followed -by the ``simple'' expressions (i.e., all other kinds of expressions involving -operators, function applications, constants, symbols and other primary -expressions). Precedence and associativity of operator symbols are given by -their declarations (in the prelude or the user's program), and function -application binds stronger than all operators. Parentheses can be used to -override default precedences and associativities as usual. -.PP -For instance, here are two more function definitions showing most of these -elements in action: -.sp -.nf -fact n = n*fact (n-1) \fBif\fP n>0; - = 1 \fBotherwise\fP; - -fib n = a \fBwhen\fP a, b = fibs n \fBend\fP - \fBwith\fP fibs n = 0, 1 \fBif\fP n<=0; - = \fBcase\fP fibs (n-1) \fBof\fP - a, b = b, a+b; - \fBend\fP; - \fBend\fP; - -\fBlet\fP facts = map fact (1..10); \fBlet\fP fibs = map fib (1..100); -facts; fibs; -.fi -.PP -And here's a little list comprehension example: Erathosthenes' classical prime -sieve. -.sp -.nf -primes n = sieve (2..n) \fBwith\fP - sieve [] = []; - sieve (p:qs) = p : sieve [q; q = qs; q mod p]; -\fBend\fP; -.fi -.sp -For instance: -.sp -.nf -> primes 100; -[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97] -.fi -.PP -If you dare, you can actually have a look at the catmap-lambda-if-then-else -expression the comprehension expanded to: -.sp -.nf -> list primes -primes n = sieve (2..n) with sieve [] = []; sieve (p:qs) = p:sieve -(catmap (\eq -> if q mod p then [q] else []) qs) end; -.fi -.PP -List comprehensions are also a useful device to organize backtracking -searches. For instance, here's an algorithm for the n queens problem, which -returns the list of all placements of n queens on an n x n board (encoded as -lists of n pairs (i,j) with i = 1..n), so that no two queens hold each other -in check. -.sp -.nf -queens n = search n 1 [] \fBwith\fP - search n i p = [reverse p] \fBif\fP 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; -\fBend\fP; -.fi -.SH EXCEPTION HANDLING -Pure also offers a useful exception handling facility. To raise an exception, -you just invoke the built-in function -.B throw -with the value to be thrown as the argument. To catch an exception, you use -the built-in special form -.B catch -with the exception handler (a function to be applied to the exception value) -as the first and the expression to be evaluated as the second (call-by-name) -argument. For instance: -.sp -.nf -> catch error (throw hello_world); -error hello_world -.fi -.PP -Exceptions are also generated by the runtime system if the program runs out of -stack space, when a guard does not evaluate to a truth value, and when the -subject term fails to match the pattern in a pattern-matching lambda -abstraction, or a \fBlet\fP, \fBcase\fP or \fBwhen\fP construct. These types -of exceptions are reported using the symbols -.BR stack_fault , -.B failed_cond -and -.BR failed_match , -respectively, which are declared as constant symbols in the standard -prelude. You can use -.B catch -to handle these kinds of exceptions just like any other. For instance: -.sp -.nf -> fact n = \fBif\fP n>0 \fBthen\fP n*fact(n-1) \fBelse\fP 1; -> catch error (fact foo); -error failed_cond -> catch error (fact 100000); -error stack_fault -.fi -.PP -(You'll only get the latter kind of exception if the interpreter does stack -checks, see the discussion of the -.B PURE_STACK -environment variable in the CAVEATS AND NOTES section.) -.PP -Note that unhandled exceptions are reported by the interpreter with a -corresponding error message: -.sp -.nf -> fact foo; -<stdin>:2.0-7: unhandled exception 'failed_cond' while evaluating 'fact foo' -.fi -.PP -Exceptions can also be used to implement non-local value returns. For -instance, here's a variation of our n queens algorithm which only returns the -first solution. Note the use of -.B throw -in the recursive search routine to bail out with a solution as soon as we -found one. The value thrown there is caught in the main routine. If no value -gets thrown, the function regularly returns with () to indicate that there is -no solution. -.sp -.nf -queens1 n = catch reverse (search n 1 []) \fBwith\fP - search n i p = throw p \fBif\fP 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; -\fBend\fP; -.fi -.PP -E.g., let's compute a solution for a standard 8x8 board: -.sp -.nf -> queens 8; -(1,1):(2,5):(3,8):(4,6):(5,3):(6,7):(7,2):(8,4):[] -.fi -.SH DECLARATIONS -As you probably noticed, Pure is very terse. That's because, in contrast to -hopelessly verbose languages like Java, you don't declare much stuff in Pure, -you just define it and be done with it. Usually, all necessary information -about the defined symbols is inferred automatically. However, there are a few -toplevel constructs which let you declare special symbol attributes and manage -programs consisting of several source modules. These are: operator and -constant symbol declarations, -.B extern -declarations for external C functions (described in the next section), and -.B using -clauses which provide a simple include file mechanism. -.TP -.B Operator and constant declarations: infix \fIlevel\fP \fIop\fR ...; -Ten different precedence levels are available for user-defined operators, -numbered 0 (lowest) thru 9 (highest). On each precedence level, you can -declare (in order of increasing precedence) -.BR infix " (binary non-associative)," -.BR infixl " (binary left-associative)," -.BR infixr " (binary right-associative)," -.BR prefix " (unary prefix) and" -.BR postfix " (unary postfix)" -operators. For instance: -.sp -.nf -\fBinfixl\fP 6 + - ; -\fBinfixl\fP 7 * / div mod ; -.fi -.sp -Moreover, constant symbols are introduced using a declaration of -the form: -.sp -.nf -\fBnullary \fIsymbol\fR ...; -.fi -.sp -Examples for all of these can be found in the prelude which declares a bunch -of standard (arithmetic, relational, logical) operator symbols as well as the -list and pair constructors `:' and `,' and the constant symbols `[]' and `()' -denoting the empty list and tuple, respectively. -.TP -.B Using clause: using \fIname\fR ...; -Causes each given script to be included, at the position of the -.B using -clause, but only if the script was not included already. The script name can -be specified either as a string denoting the proper filename (possibly -including path and/or filename extension), or as an identifier. In the latter -case, the -.B .pure -filename extension is added automatically. In both cases, the script is -searched for in the current directory and the directory named by the -.B PURELIB -environment variable. (The -.B using -clause also has an alternative form which allows dynamic libraries to be -loaded, this will be discussed in the following section.) -.SH C INTERFACE -Accessing C functions from Pure programs is dead simple. You just need an -.B extern -declaration of the function, which is a simplified kind of C prototype. The -function can then be called in Pure just like any other. For instance, the -following commands, entered interactively in the interpreter, let you use the -.B sin -function from the C library (of course you could just as well put the -.B extern -declaration into a script): -.sp -.nf -> \fBextern\fP double sin(double); -> sin 0.3; -0.29552020666134 -.fi -.sp -For clarity, the parameter types can also be annotated with parameter names, -e.g.: -.sp -.nf -\fBextern\fP double sin(double x); -.fi -.sp -Parameter names in prototypes only serve informational purposes and are for -the human reader; they are effectively treated as comments by the compiler. -.PP -The interpreter makes sure that the parameters in a call match; if not, the -call is treated as a normal form expression. The range of supported C types is -a bit limited right now (void, bool, char, short, int, long, double, as well -as arbitrary pointer types, i.e.: void*, char*, etc.), but in practice these -should cover most kinds of calls that need to be done when interfacing to C -libraries. -.PP -Since Pure only has 32 bit machine integers and GMP bigints, a variety of C -integer types are provided which are converted from/to the Pure types in a -straightfoward way. The short type indicates 16 bit integers which are -converted from/to Pure machine ints using truncation and sign extension, -respectively. The long type -.I always -denotes 64 bit integers, even if the corresponding C type is actually 32 bit -(as it usually is on most contemporary systems). This type is to be used if a -C function takes or returns 64 bit integer values. For a long parameter you -can either pass a Pure machine int (which is sign-extended to 64 bit) or a -Pure bigint (which is truncated to 64 bit if necessary). 64 bit return values -are always converted to (signed) Pure bigints. -.PP -Concerning the pointer types, char* is for string arguments and return values -which need translation between Pure's internal utf-8 representation and the -system encoding, while void* is for any generic kind of pointer (including -strings, which are \fInot\fP translated when passed/returned as void*). Any -other kind of pointer (except expr*, see below) is effectively treated as -void* right now, although in a future version the interpreter may keep track -of the type names for the purpose of checking parameter types. -.PP -The expr* pointer type is special; it indicates a Pure expression parameter or -return value which is just passed through unchanged. All other types of values -have to be ``unboxed'' when they are passed as arguments (i.e., from Pure to -C) and ``boxed'' again when they are returned as function results (from C to -Pure). All of this is handled by the runtime system in a transparent way, of -course. -.PP -It is even possible to augment an external C function with ordinary Pure -equations, but in this case you have to make sure that the -.B extern -declaration of the function comes first. For instance, we might want to extend -our imported -.B sin -function with a rule to handle integers: -.sp -.nf -> sin 0; -sin 0 -> sin x::int = sin (double x); -> sin 0; -0.0 -.fi -.PP -Sometimes it is preferable to replace a C function with a wrapper function -written in Pure. In such a case you can specify an \fIalias\fP under which the -original C function is known to the Pure program, so that you can still call -the C function from the wrapper. An alias is introduced by terminating the -.B extern -declaration with a clause of the form ``= \fIalias\fP''. For instance: -.sp -.nf -> \fBextern\fP double sin(double) = c_sin; -> sin x::double = c_sin x; -> sin x::int = c_sin (double x); -> sin 0.3; sin 0; -0.29552020666134 -0.0 -.fi -.PP -External C functions are resolved by the LLVM runtime, which first looks for -the symbol in the C library and Pure's runtime library (or the interpreter -executable, if the interpreter was linked statically). Thus all C library and -Pure runtime functions are readily available in Pure programs. Other functions -can be provided by including them in the runtime, or by linking the -interpreter against the corresponding modules. Or, better yet, you can just -``dlopen'' shared libraries at runtime with a special form of the -.B using -clause: -.sp -.nf -\fBusing\fP "lib:\fIlibname\fR[.\fIext\fP]"; -.fi -.sp -For instance, if you want to call the GMP functions directly from Pure: -.sp -.nf -\fBusing\fP "lib:libgmp"; -.fi -.sp -After this declaration the GMP functions will be ready to be imported into -your Pure program by means of corresponding -.B extern -declarations. -.PP -Shared libraries opened with \fBusing\fP clauses are searched for on the usual -system linker path (\fBLD_LIBRARY_PATH\fP on Linux). The necessary filename -suffix (e.g., \fB.so\fP on Linux or \fB.dll\fP on Windows) will also be -supplied automatically. You can also specify a full pathname for the library -if you prefer that. If a library file cannot be found, or if an -.B extern -declaration names a function symbol which cannot be resolved, an appropriate -error message is printed. -.SH STANDARD LIBRARY -Pure comes with a collection of Pure library modules, which includes the -standard prelude. Right now the library is pretty rudimentary, but it offers -the necessary functions to work with the built-in types (including arithmetic -and logical operations) and to do most kind of list processing you can find in -ML- and Haskell-like languages. Please refer to the -.B prelude.pure -file for details on the provided operations. Also, the beginnings of a system -interface can be found in the -.B system.pure -module. In particular, this also includes operations to do basic I/O. More -stuff will be provided in future releases. -.SH INTERACTIVE USAGE -In interactive mode, the interpreter reads definitions and expressions and -processes them as usual. The input language is just the same as for source -scripts, and hence individual definitions and expressions \fImust\fP be -terminated with a semicolon before they are processed. For instance, here is a -simple interaction which defines the factorial and then uses that definition -in some evaluations. Input lines begin with ``>'', which is the interpreter's -default command prompt: -.sp -.nf -> fact 1 = 1; -> fact n = n*fact (n-1) \fBif\fP n>1; -> \fBlet\fP x = fact 10; x; -3628800 -> map fact (1..10); -[1,2,6,24,120,720,5040,40320,362880,3628800] -.fi -.PP -When running interactively, the interpreter also accepts a number of special -commands useful for interactive purposes. Here is a quick rundown of the -currently supported operations: -.TP -.B "! \fIcommand\fP" -Shell escape. -.TP -.B "cd \fIdir\fP" -Change the current working dir. -.TP -.B "clear \fR[\fIsymbol\fP ...]\fP" -Purge the definitions of the given symbols (functions or global variables). If -no symbols are given, purge \fIall\fP definitions (after confirmation) made -after the most recent -.B save -command (or the beginning of the interactive session). -See the \fBDEFINITION LEVELS AND OVERRIDE MODE\fP section below for details. -.TP -.B "help \fR[\fIargs\fP]\fP" -Display the -.BR pure (1) -manpage, or invoke -.BR man (1) -with the given arguments. -.TP -.B "list \fR[\fIoption\fP ...]\fP \fR[\fIsymbol\fP ...]\fP" -List defined symbols in various formats. -See the \fBLIST COMMAND\fP section below for details. -.TP -.B "ls \fR[\fIargs\fP]\fP" -List files (shell \fBls\fP(1) command). -.TP -.B override -Enter ``override'' mode. This allows you to add equations ``above'' existing -definitions in the source script, possibly overriding existing equations. -See the \fBDEFINITION LEVELS AND OVERRIDE MODE\fP section below for details. -.TP -.B pwd -Print the current working dir (shell \fBpwd\fP(1) command). -.TP -.B quit -Exits the interpreter. -.TP -.B "run \fIscript\fP" -Loads the given script file and adds its definitions to the current -environment. This works more or less like a -.B using -clause, but loads the script ``anonymously'', as if the contents of the script -had been typed at the command prompt. That is, -.B run -doesn't check whether the script is being used already and it puts the -definitions on the current temporary level (so that -.B clear -can be used to remove them again). -.TP -.B save -Begin a new level of temporary definitions. A subsequent -.B clear -command (see above) will purge all definitions made after the most recent -.B save -(or the beginning of the interactive session). -See the \fBDEFINITION LEVELS AND OVERRIDE MODE\fP section below for details. -.TP -.B "stats \fR[on|off]\fP" -Enables (default) or disables ``stats'' mode, in which various statistics are -printed after an expression has been evaluated. Currently, this just prints -the cpu time in seconds for each evaluation, but in the future additional -profiling information may be provided. -.TP -.B underride -Exits ``override'' mode. This returns you to the normal mode of operation, -where new equations are added `below'' previous rules of an existing function. -See the \fBDEFINITION LEVELS AND OVERRIDE MODE\fP section below for details. -.PP -Note that these special commands are only recognized at the beginning of the -interactive command line. (Thus you can escape a symbol looking like a command -by prefixing it with a space.) -.PP -Some commands which are especially important for effective operation of the -interpreter are discussed in more detail in the following sections. -.SH LIST COMMAND -In interactive mode, the -.B list -command can be used to obtain information about defined symbols in various -formats. This command recognizes the following options. Options may be -combined, thus, e.g., \fBlist\fP -tvl is the same as \fBlist\fP -t -v -l. -.TP -.B -c -Annotate printed definitions with compiled code (matching automata). Works -like the -.B -v4 -option of the interpreter. -.TP -.B -d -Disassembles LLVM IR, showing the generated LLVM assembler code of a -function. Works like the -.B -v8 -option of the interpreter. -.TP -.B -e -Annotate printed definitions with lexical environment information (de Bruijn -indices, subterm paths). Works like the -.B -v2 -option of the interpreter. -.TP -.B -f -Print information about function symbols only. -.TP -.B -g -Indicates that the following symbols are actually shell glob patterns and that -all matching symbols should be listed. -.TP -.B -h -Print a short help message. -.TP -.B -l -Long format, prints definitions along with the summary symbol information. -This implies \fB-s\fP. -.TP -.B -s -Summary format, print just summary information about listed symbols. -.TP -.B -t[\fIlevel\fP] -List only ``temporary'' symbols and definitions at the given \fIlevel\fP (the -current level by default) or above. The \fIlevel\fP parameter, if given, must -immediately follow the option character. A \fIlevel\fP of 1 denotes all -temporary definitions, whereas 0 indicates \fIall\fP definitions (which is the -default if \fB-t\fP is not specified). See the \fBDEFINITION LEVELS AND -OVERRIDE MODE\fP section below for information about the notion of temporary -definition levels. -.TP -.B -v -Print information about variable symbols only. -.PP -Output is piped through the -.BR more (1) -program to make it easier to read, as some of the options (in particular, -.B -c -and -.BR -d ) -may produce excessive amounts of information. -.PP -For instance, to list all definitions in all loaded scripts (including the -prelude), simply say: -.sp -.nf -> \fBlist\fP -.fi -.PP -This may produce quite a lot of output, depending on which scripts are -loaded. The following command will only show summary information about the -variable symbols along with their current values (using the ``long format''): -.sp -.nf -> \fBlist\fP -lv -argc var argc = 0; -argv var argv = []; -sysinfo var sysinfo = "i686-pc-linux-gnu"; -version var version = "0.1"; -4 variables -.fi -.PP -If you're like me then you'll frequently have to look up how some operations -are defined. No sweat, with the Pure interpreter there's no need to dive into -the sources, the -.B list -command can easily do it for you. For instance, here's how you can list the -definitions of all list ``zipping'' operations from the prelude in one go: -.sp -.nf -> \fBlist\fP -g zip* -zip (x:xs) (y:ys) = (x,y):zip xs ys; -zip _ _ = []; -zip3 (x:xs) (y:ys) (z:zs) = (x,y,z):zip3 xs ys zs; -zip3 _ _ _ = []; -zipwith f (x:xs) (y:ys) = f x y:zipwith f xs ys; -zipwith f _ _ = []; -zipwith3 f (x:xs) (y:ys) (z:zs) = f x y z:zipwith3 f xs ys zs; -zipwith3 f _ _ _ = []; -.fi -.SH DEFINITION LEVELS AND OVERRIDE MODE -To help with incremental development, the interpreter also offers some -facilities to manipulate the current set of definitions interactively. To -these ends, defined symbols and their definitions are organized into different -subsets called \fIlevels\fP. The prelude, as well as other source programs -specified when invoking the interpreter, are always at level 0, while the -interactive environment starts at level 1. -.PP -Each \fBsave\fP command introduces a new temporary level, and each subsequent -\fBclear\fP command ``pops'' the symbols and definitions on the current level -(including any definitions read using the -.B run -command) and returns you to the previous one. This gives you a ``stack'' of up -to 255 temporary environments which enables you to ``plug and play'' in a safe -fashion, without affecting the rest of your program. Example: -.sp -.nf -> \fBsave\fP -save: now at temporary definitions level #2 -> foo (x:xs) = x+foo xs; -> foo [] = 0; -> \fBlist\fP foo -foo (x:xs) = x+foo xs; -foo [] = 0; -> foo (1..10); -55 -> \fBclear\fP -This will clear all temporary definitions at level #2. Continue (y/n)? y -clear: now at temporary definitions level #1 -> \fBlist\fP foo -> foo (1..10); -foo [1,2,3,4,5,6,7,8,9,10] -.fi -.PP -We've seen already that normally, if you enter a sequence of equations, they -will be recorded in the order in which they were written. However, it is also -possible to override definitions in lower levels with the -.B override -command: -.sp -.nf -> foo (x:xs) = x+foo xs; -> foo [] = 0; -> \fBlist\fP foo -foo (x:xs) = x+foo xs; -foo [] = 0; -> foo (1..10); -55 -> \fBsave\fP -save: now at temporary definitions level #2 -> \fBoverride\fP -> foo (x:xs) = x*foo xs; -> \fBlist\fP foo -foo (x:xs) = x*foo xs; -foo (x:xs) = x+foo xs; -foo [] = 0; -> foo (1..10); -0 -.fi -.PP -Note that the equation `foo (x:xs) = x*foo xs;' was inserted before the -previous `foo (x:xs) = x+foo xs;' rule, which is at level #1. -.PP -Even in override mode, new definitions will be added \fIafter\fP other -definitions at the \fIcurrent\fP level. This allows us to just continue adding -more high-priority definitions overriding lower-priority ones: -.sp -.nf -> foo [] = 1; -> \fBlist\fP foo -foo (x:xs) = x*foo xs; -foo [] = 1; -foo (x:xs) = x+foo xs; -foo [] = 0; -> foo (1..10); -3628800 -.fi -.PP -Again, the new equation was inserted \fIabove\fP the existing lower-priority -rules, but \fIbelow\fP our previous `foo (x:xs) = x*foo xs;' equation entered -at the same level. As you can see, we have now effectively replaced our -original definition of `foo' with a version that calculates list products -instead of sums, but of course we can easily go back one level to restore the -previous definition: -.sp -.nf -> \fBclear\fP -This will clear all temporary definitions at level #2. Continue (y/n)? y -clear: now at temporary definitions level #1 -clear: override mode is on -> \fBlist\fP foo -foo (x:xs) = x+foo xs; -foo [] = 0; -> foo (1..10); -55 -.fi -.PP -Note that -.B clear -reminded us that override mode is still enabled (\fBsave\fP will do the same -if override mode is on while pushing a new definitions level). To turn it off -again, use the -.B underride -command. This will revert to the normal behaviour of adding new equations -below existing ones: -.sp -.nf -> \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 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 Special forms. -Special forms are recognized at compile time only. Thus the catch function as -well as the short-circuit logical connectives && and || are only treated as -special forms in direct (saturated) calls. They can still be used if you pass -them around as function values or partial applications, but in this case they -lose all their special call-by-name argument processing. -.PP -.B Manipulating function applications. -The ``head = function'' rule means that the head symbol f of an application f -x1 ... xn occurring on (or inside) the left-hand side of an equation, pattern -binding, or pattern-matching lambda expression, is always interpreted as a -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, -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 -or -.BR ::double . -This often helps the compiler to generate better code and makes your programs -run faster. -.PP -Talking about the built-in 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; for the latter -you'll have to use the ``big L'' notation `0L'. -.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 -files to determine whether you actually declared the function correctly! So -you have to be careful to give the proper declarations, otherwise your program -will probably segfault calling the function. -.PP -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 -.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 -recommended for 32 bit systems, systems with 64 bit pointers probably need -more). If the -.B PURE_STACK -environment variable is defined, the interpreter performs advisory stack -checks and raises a Pure exception if the current stack size exceeds the given -limit. The value of -.B PURE_STACK -should be the maximum stack size in kilobytes. Please note that this is only -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 -certain occasions, such as entry into a global function. -.PP -Fortunately, Pure normally does proper tail calls (if LLVM provides that -feature on the platform at hand), so most tail-recursive definitions should -work fine in limited stack space. For instance, the following little program -will loop forever if your platform supports the required optimizations: -.sp -.nf -loop = loop; -.fi -.PP -In the current implementation, a tail call will be eliminated \fIonly\fP if -the call is done \fIdirectly\fP, i.e., through an explicit call, not through a -(global or local) function variable. Otherwise the call will be handled by the -runtime system which is written in C and can't do proper tail calls because C -can't (at least not in a portable way). This also affects mutually recursive -global function calls, since there the calls are handled in an indirect way, -too, through an anonymous global variable. (This is done so that a global -function definition can be changed at any time during an interactive session, -without having to recompile the entire program.) However, mutual tail -recursion does work with \fIlocal\fP functions, so it's easy to work around -this limitation. -.PP -Scheme programmers should note that conditional expressions -(\fBif\fP-\fBthen\fP-\fBelse\fP) are tail-recursive in both branches, just -like in Scheme, while the logical operators && and || are -.I not -tail-recursive. This is because the logical operators always return a proper -truth value (0 or 1) which wouldn't be possible with tail call semantics. -.SH FILES -.TP -.B ~/.pure_history -Interactive command history. -.TP -.B prelude.pure -Standard prelude. If available, this script is loaded before any other -definitions, unless -.B -n -was specified. -.SH ENVIRONMENT -.TP -.B PURELIB -Directory to search for source files, including the prelude. If -.B PURELIB -is not set, it defaults to some default location specified at installation -time. -.TP -.B PURE_PS -Command prompt used in the interactive command loop (">\ " by default). -.TP -.B PURE_STACK -Maximum stack size in kilobytes (default: 0 = unlimited). -.SH LICENSE -GPL V3 or later. See the accompanying COPYING file for details. -.SH AUTHOR -Albert Graef <Dr....@t-...>, Dept. of Computer Music, Johannes -Gutenberg University of Mainz, Germany. -.SH SEE ALSO -.TP -.B Aardappel -Another functional programming language based on term rewriting, -\fIhttp://wouter.fov120.com/aardappel\fP. -.TP -.B Haskell -A popular non-strict FPL, \fIhttp://www.haskell.org\fP. -.TP -.B LLVM -The LLVM code generator framework, \fIhttp://llvm.org\fP. -.TP -.B ML -A popular strict FPL. See Robin Milner, Mads Tofte, Robert Harper, -D. MacQueen: \fIThe Definition of Standard ML (Revised)\fP. MIT Press, 1997. -.TP -.B Q -Another term rewriting language by yours truly, \fIhttp://q-lang.sf.net\fP. Copied: pure/trunk/pure.1.in (from rev 208, pure/trunk/pure.1) =================================================================== --- pure/trunk/pure.1.in (rev 0) +++ pure/trunk/pure.1.in 2008-06-13 11:21:35 UTC (rev 209) @@ -0,0 +1,1218 @@ +.TH Pure 1 "March 2008" "Pure Version @version@" +.SH NAME +pure \- the Pure interpreter +.SH SYNOPSIS +\fBpure\fP [-h] [-i] [-n] [-v[\fIlevel\fP]] [\fIscript\fP ...] [-- \fIargs\fP ...] +.SH OPTIONS +.TP +.B -h +Print help message and exit. +.TP +.B -i +Force interactive mode (read commands from stdin). +.TP +.B -n +Suppress automatic inclusion of the prelude. +.TP +.B -v +Set verbosity level. See below for details. +.TP +.B -- +Stop option processing and pass the remaining command line arguments in the +.B argv +variable. +.SH DESCRIPTION +Pure is a modern-style functional programming language based on term +rewriting. Pure programs are basically collections of equational rules used to +evaluate expressions in a symbolic fashion by reducing them to normal form. A +brief overview of the language can be found in the \fBPURE OVERVIEW\fP section +below. (In case you're wondering, the name ``Pure'' actually refers to the +adjective. But you can also write it as ``PURE'' and take this as a recursive +acronym for the ``Pure Universal Rewriting Engine''.) +.PP +.B pure +is the Pure interpreter. The interpreter has an LLVM backend which +JIT-compiles Pure programs to machine code, hence programs run blazingly fast +and interfacing to C modules is easy, while the interpreter still provides a +convenient, fully interactive environment for running Pure scripts and +evaluating expressions. +.PP +If any source scripts are specified on the command line, they are loaded and +executed, after which the interpreter exits. Otherwise the interpreter enters +the interactive read-eval-print loop. You can also use the +.B -i +option to enter the interactive loop (continue reading from stdin) even after +processing some source scripts. To exit the interpreter, just type the +.B quit +command or the end-of-file character (^D on Unix) at the beginning of the +command line. +.PP +When the interpreter is in interactive mode and reads from a tty, commands are +read using +.BR readline (3) +(providing completion for all commands listed in section +.B INTERACTIVE USAGE +below, as well as for global function and variable symbols) and, when exiting +the interpreter, the command history is stored in +.BR ~/.pure_history , +from where it is restored the next time you run the interpreter. +.PP +Options and source files are processed in the order in which they are given on +the command line. Processing of options and source files ends when the +.B -- +option is encountered. Any following parameters are passed to the executing +script by means of the global +.B argc +and +.B argv +variables. Moreover, the +.B version +variable is set to the Pure interpreter version, and the +.B sysinfo +variable provides information about the host system. +.PP +If available, the prelude script +.B prelude.pure +is loaded by the interpreter prior to any other other definitions, unless the +.B -n +option is specified. The prelude as well as other source scripts specified +with a relative pathname are first searched for in the current directory and +then in the directory specified with the +.B PURELIB +environment variable. If the +.B PURELIB +variable is not set, a system-specific default is used. +.PP +The +.B -v +option is most useful for debugging the interpreter, or if you are interested +in the code your program gets compiled to. The +.I level +argument is optional; it defaults to 1. Six different levels are implemented +at this time (two more bits are reserved for future extensions). For most +purposes, only the first two levels will be useful for the average Pure +programmer; the remaining levels are most likely to be used by the Pure +interpreter developers. +.TP +.B 1 (0x1) +denotes echoing of parsed definitions and expressions; +.TP +.B 2 (0x2) +adds special annotations concerning local bindings (de Bruijn indices, subterm +paths; this can be helpful to debug tricky variable binding issues); +.TP +.B 4 (0x4) +adds abstract code snippets (matching automata etc.; you probably want to see +this only when working on the guts of the interpreter). +.TP +.B 8 (0x8) +dumps the ``real'' output code (LLVM assembler, which is as close to the +native machine code for your program as it gets; you \fIdefinitely\fP don't +want to see this unless you have to inspect the generated code for bugs or +performance issues). +.TP +.B 16 (0x10) +adds debugging messages from the +.BR bison (1) +parser; useful for debugging the parser. +.TP +.B 32 (0x20) +adds debugging messages from the +.BR flex (1) +lexer; useful for debugging the lexer. +.PP +These values can be or'ed together, and, for convenience, can be specified in +either decimal or hexadecimal. Thus 0xff always gives you full debugging +output (which isn't most likely be used by anyone but the Pure developers). +.PP +Note that the +.B -v +option is only applied \fIafter\fP the prelude has been loaded. If you want to +debug the prelude, use the +.B -n +option and specify the +.B prelude.pure +file explicitly on the command line. Alternatively, you can also use the +interactive +.B list +command (see the \fBINTERACTIVE USAGE\fP section below) to list definitions +along with additional debugging information. +.SH PURE OVERVIEW +.PP +Pure is a fairly simple language. Programs are simply collections of +equational rules defining functions, \fBlet\fP commands binding global +variables, and expressions to be evaluated. Here's a simple example, entered +interactively in the interpreter: +.sp +.nf +> // my first Pure example +> fact 1 = 1; +> fact n::int = n*fact (n-1) \fBif\fP n>1; +> \fBlet\fP x = fact 10; x; +3628800 +.fi +.PP +The language is free-format (blanks are insignificant). As indicated, +definitions and expressions at the toplevel have to be terminated with a +semicolon. Comments have the same syntax as in C++ (using // for line-oriented +and /* ... */ for multiline comments; the latter may not be nested). +.PP +On the surface, Pure is quite similar to other modern functional languages +like Haskell and ML. But under the hood it is a much more dynamic and +reflective language, more akin to Lisp. In particular, Pure is dynamically +typed, so functions can be fully polymorphic and you can add to the definition +of an existing function at any time: +.sp +.nf +> fact 1.0 = 1.0; +> fact n::double = n*fact (n-1) \fBif\fP n>1; +> fact 10.0; +3628800.0 +> fact 10; +3628800 +.fi +.sp +Also, due to its term rewriting semantics, Pure can do symbolic evaluations: +.sp +.nf +> square x = x*x; +> square (a+b); +(a+b)*(a+b) +.fi +.PP +The Pure language provides built-in support for machine integers (32 bit), +bigints (implemented using GMP), floating point values (double precision +IEEE), character strings (UTF-8 encoded) and generic C pointers (these don't +have a syntactic representation in Pure, though, so they need to be created +with external C functions). Truth values are encoded as machine integers (as +you might expect, zero denotes ``false'' and any non-zero value ``true''). +.PP +Expressions are generally evaluated from left to right, innermost expressions +first, i.e., using +.I call by value +semantics. Pure also has a few built-in special forms (most notably, +conditional expressions and the short-circuit logical connectives && and ||) +which take some of their arguments using +.I call by name +semantics. +.PP +Expressions consist of the following elements: +.TP +.B Constants: \fR4711, 4711L, 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, 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, as in Python an integer literal immediately followed +by the uppercase letter ``L'' will always be interpreted as a bigint constant, +even if it fits into a machine integer. This 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 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 +.B \en +are also supported. Moreover, you can use symbolic character escapes of the +form +.BR \e&\fIname\fP; , +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 +underscore) and digits, starting with a letter. Case is significant, but it +doesn't carry any meaning (that's in contrast to languages like Prolog and Q, +where variables must be capitalized). Pure simply distinguishes function and +variable symbols on the left-hand side of an equation by the ``head = +function'' rule: Any symbol which occurs as the head symbol of a function +application is a function symbol, all other symbols are variables -- exc... [truncated message content] |
From: <ag...@us...> - 2008-06-13 11:21:09
|
Revision: 208 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=208&view=rev Author: agraef Date: 2008-06-13 04:21:12 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Include proper version number in manpage. Modified Paths: -------------- pure/trunk/Makefile.in pure/trunk/pure.1 Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-13 11:07:04 UTC (rev 207) +++ pure/trunk/Makefile.in 2008-06-13 11:21:12 UTC (rev 208) @@ -146,6 +146,15 @@ parser.hh location.hh position.hh stack.hh: parser.cc +# create the manpage from pure.1.in + +edit = sed -e 's,@version\@,$(version),g' + +pure.1: configure pure.1.in + rm -f pure.1 pure.1.tmp + $(edit) pure.1.in >pure.1.tmp + mv pure.1.tmp pure.1 + # documentation in various formats (requires groff) html: pure.html Modified: pure/trunk/pure.1 =================================================================== --- pure/trunk/pure.1 2008-06-13 11:07:04 UTC (rev 207) +++ pure/trunk/pure.1 2008-06-13 11:21:12 UTC (rev 208) @@ -1,4 +1,4 @@ -.TH Pure 1 "March 2008" "Pure Version 0.x" +.TH Pure 1 "March 2008" "Pure Version @version@" .SH NAME pure \- the Pure interpreter .SH SYNOPSIS This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 11:06:58
|
Revision: 207 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=207&view=rev Author: agraef Date: 2008-06-13 04:07:04 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Update installation instructions. Modified Paths: -------------- pure/trunk/INSTALL Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-06-13 10:47:29 UTC (rev 206) +++ pure/trunk/INSTALL 2008-06-13 11:07:04 UTC (rev 207) @@ -61,13 +61,13 @@ IMPORTANT: On x86-64 systems you also have to add --enable-pic. See the comments on 64 bit support in the SYSTEM NOTES section below. -Also note the configure flags; these are for an optimized (non-debug) build -and disable all compilation targets but the one for your system. You might -wish to omit the --enable-targets=host-only if you want to use other LLVM -applications offering cross-compilation capabilities. To do a debug build of -LLVM, simply leave away all the extra configure parameters (except possibly ---enable-targets=host-only). Note, however, that this will have an impact on -the speed of the Pure compiler. +Note that the configure flags are for an optimized (non-debug) build and +disable all compilation targets but the one for your system. You might wish to +omit --enable-targets=host-only if you want to enable cross-compilation (this +isn't supported by Pure right now, but other LLVM applications offer such +capabilities). To do a debug build of LLVM, simply leave away all the extra +configure parameters (except possibly --enable-targets=host-only). Note, +however, that this will have an impact on the speed of the Pure compiler. STEP 4. Get and unpack the Pure sources at: http://pure-lang.sf.net/ @@ -193,6 +193,13 @@ $ make install DESTDIR=tmp-root +Beginning with version 0.4, Pure fully supports parallel installations of +different versions of the interpreter without any further ado. To these ends, +bin/pure, lib/libpure.so, lib/pure and man/man1/pure.1 are actually symbolic +links to the current version (bin/pure-x.y, lib/libpure-x.y.so etc., where x.y +is the version number). If you install a new version of the interpreter, the +old version remains available as pure-x.y. + SEPARATE BUILD DIRECTORY -------- ----- --------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 10:47:29
|
Revision: 206 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=206&view=rev Author: agraef Date: 2008-06-13 03:47:29 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Bump version number. Modified Paths: -------------- pure/trunk/INSTALL pure/trunk/configure pure/trunk/configure.ac Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-06-13 10:33:49 UTC (rev 205) +++ pure/trunk/INSTALL 2008-06-13 10:47:29 UTC (rev 206) @@ -76,7 +76,7 @@ section. STEP 5. Configure, build and install Pure as follows (x.y denotes the current -Pure version number, 0.3 at the time of this writing): +Pure version number, 0.4 at the time of this writing): $ cd pure-x.y $ ./configure @@ -102,10 +102,10 @@ Run Pure interactively as: $ pure -Pure 0.3 (i686-pc-linux-gnu) Copyright (c) 2008 by Albert Graef +Pure 0.4 (i686-pc-linux-gnu) 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. +Loaded prelude from /usr/local/lib/pure-0.4/prelude.pure. Check that it works: Modified: pure/trunk/configure =================================================================== --- pure/trunk/configure 2008-06-13 10:33:49 UTC (rev 205) +++ pure/trunk/configure 2008-06-13 10:47:29 UTC (rev 206) @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.61 for pure 0.3. +# Generated by GNU Autoconf 2.61 for pure 0.4. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. @@ -572,8 +572,8 @@ # Identity of this package. PACKAGE_NAME='pure' PACKAGE_TARNAME='pure' -PACKAGE_VERSION='0.3' -PACKAGE_STRING='pure 0.3' +PACKAGE_VERSION='0.4' +PACKAGE_STRING='pure 0.4' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. @@ -1198,7 +1198,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pure 0.3 to adapt to many kinds of systems. +\`configure' configures pure 0.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1263,7 +1263,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pure 0.3:";; + short | recursive ) echo "Configuration of pure 0.4:";; esac cat <<\_ACEOF @@ -1356,7 +1356,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pure configure 0.3 +pure configure 0.4 generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1370,7 +1370,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pure $as_me 0.3, which was +It was created by pure $as_me 0.4, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ @@ -5764,7 +5764,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by pure $as_me 0.3, which was +This file was extended by pure $as_me 0.4, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -5813,7 +5813,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -pure config.status 0.3 +pure config.status 0.4 configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Modified: pure/trunk/configure.ac =================================================================== --- pure/trunk/configure.ac 2008-06-13 10:33:49 UTC (rev 205) +++ pure/trunk/configure.ac 2008-06-13 10:47:29 UTC (rev 206) @@ -1,5 +1,5 @@ -AC_INIT(pure, 0.3) +AC_INIT(pure, 0.4) AC_CONFIG_HEADERS(config.h) dnl Determine host information. AC_CANONICAL_HOST This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 10:33:42
|
Revision: 205 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=205&view=rev Author: agraef Date: 2008-06-13 03:33:49 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Add support for installing different Pure versions in parallel. Modified Paths: -------------- pure/trunk/Makefile.in pure/trunk/lexer.ll pure/trunk/pure.cc Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-13 09:59:39 UTC (rev 204) +++ pure/trunk/Makefile.in 2008-06-13 10:33:49 UTC (rev 205) @@ -57,9 +57,9 @@ CXXFLAGS = @CXXFLAGS@ # Pure library name. Currently we use a simple versioning scheme, which -# requires that the library version matches that of the interpreter. With some -# fiddling, this enables you to install different versions of the Pure -# interpreter on the same system. +# requires that the library version matches that of the interpreter. This +# enables you to install different versions of the Pure interpreter on the +# same system. libpure_base = $(name) libpure_vers = $(libpure_base)-$(version) @@ -130,7 +130,7 @@ ln -sf $(libpure) $(libpurelnk) pure.o: pure.cc - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LLVM_FLAGS) -DPURELIB='"$(libdir)/pure"' -c -o $@ $< + $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LLVM_FLAGS) -DPURELIB='"$(libdir)/pure-$(version)"' -c -o $@ $< interpreter.o: interpreter.cc $(CXX) $(CXXFLAGS) $(PIC) $(CPPFLAGS) $(LLVM_FLAGS) $(AUXLIBS) -c -o $@ $< @@ -190,17 +190,20 @@ # installation install: pure$(EXE) - for x in $(addprefix $(DESTDIR), $(bindir) $(libdir)/pure $(man1dir)); do $(INSTALL) -d $$x; done - $(INSTALL) pure$(EXE) $(DESTDIR)$(bindir)/pure$(EXE) + for x in $(addprefix $(DESTDIR), $(bindir) $(libdir)/pure-$(version) $(man1dir)); do $(INSTALL) -d $$x; done + $(INSTALL) pure$(EXE) $(DESTDIR)$(bindir)/pure-$(version)$(EXE) + ln -sf $(bindir)/pure-$(version)$(EXE) $(DESTDIR)$(bindir)/pure$(EXE) ifeq ($(sharedlib), yes) $(INSTALL) $(libpure) $(DESTDIR)$(libdir)/$(libpure) ln -sf $(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) endif - for x in $(srcdir)/lib/*.pure; do $(INSTALL) -m 644 $$x $(DESTDIR)$(libdir)/pure; done - $(INSTALL) -m 644 pure.1 $(DESTDIR)$(man1dir)/pure.1 + for x in $(srcdir)/lib/*.pure; do $(INSTALL) -m 644 $$x $(DESTDIR)$(libdir)/pure-$(version); done + ln -sf $(libdir)/pure-$(version) $(DESTDIR)$(libdir)/pure + $(INSTALL) -m 644 pure.1 $(DESTDIR)$(man1dir)/pure-$(version).1 + ln -sf $(man1dir)/pure-$(version).1 $(DESTDIR)$(man1dir)/pure.1 uninstall: - rm -rf $(DESTDIR)$(bindir)/pure$(EXE) $(DESTDIR)$(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(man1dir)/pure.1 + rm -rf $(DESTDIR)$(bindir)/pure$(EXE) $(DESTDIR)$(bindir)/pure-$(version)$(EXE) $(DESTDIR)$(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) $(DESTDIR)$(libdir)/pure $(DESTDIR)$(libdir)/pure-$(version) $(DESTDIR)$(man1dir)/pure.1 $(DESTDIR)$(man1dir)/pure-$(version).1 # roll a distribution tarball Modified: pure/trunk/lexer.ll =================================================================== --- pure/trunk/lexer.ll 2008-06-13 09:59:39 UTC (rev 204) +++ pure/trunk/lexer.ll 2008-06-13 10:33:49 UTC (rev 205) @@ -12,6 +12,8 @@ #include "parser.hh" #include "util.hh" +#include "config.h" + /* Work around an incompatibility in flex (at least versions 2.5.31 through 2.5.33): it generates code that does not conform to C89. See Debian bug 333231 <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */ @@ -196,7 +198,7 @@ if (*s && !isspace(*s)) REJECT; while (isspace(*s)) ++s; yylloc->step(); - string cmd = string("man ") + ((*s)?s:"pure"); + string cmd = string("man ") + ((*s)?s:("pure-" PACKAGE_VERSION)); system(cmd.c_str()); } ^ls.* { Modified: pure/trunk/pure.cc =================================================================== --- pure/trunk/pure.cc 2008-06-13 09:59:39 UTC (rev 204) +++ pure/trunk/pure.cc 2008-06-13 10:33:49 UTC (rev 205) @@ -25,7 +25,7 @@ #define PACKAGE_VERSION "0.0" #endif #ifndef PURELIB -#define PURELIB "/usr/local/lib/pure" +#define PURELIB "/usr/local/lib/pure-" PACKAGE_VERSION #endif #define COPYRIGHT "Copyright (c) 2008 by Albert Graef" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 09:59:31
|
Revision: 204 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=204&view=rev Author: agraef Date: 2008-06-13 02:59:39 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Refactoring of host-specific setup, add support for -dynamiclib on OSX. Modified Paths: -------------- pure/trunk/Makefile.in pure/trunk/configure pure/trunk/configure.ac Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-13 09:34:55 UTC (rev 203) +++ pure/trunk/Makefile.in 2008-06-13 09:59:39 UTC (rev 204) @@ -74,6 +74,10 @@ sharedlib = @sharedlib@ +# Flag needed to create shared libraries. On most systems this is just -shared. + +shared = @shared@ + # On some systems -fPIC is needed for code linked as a shared library. ifeq ($(sharedlib), yes) @@ -122,7 +126,7 @@ endif $(libpure): $(OBJECT) - $(CXX) -shared -o $@ $(LDFLAGS) $(OBJECT) $(LLVM_LIBS) $(LIBS) + $(CXX) $(shared) -o $@ $(LDFLAGS) $(OBJECT) $(LLVM_LIBS) $(LIBS) ln -sf $(libpure) $(libpurelnk) pure.o: pure.cc Modified: pure/trunk/configure =================================================================== --- pure/trunk/configure 2008-06-13 09:34:55 UTC (rev 203) +++ pure/trunk/configure 2008-06-13 09:59:39 UTC (rev 204) @@ -657,8 +657,9 @@ host_cpu host_vendor host_os +shared +rdynamic PIC -RDYNAMIC DLLEXT AUXLIBS INSTALL_PROGRAM @@ -1847,25 +1848,24 @@ _ACEOF +shared="-shared" +rdynamic="-rdynamic" PIC= -RDYNAMIC= DLLEXT=".so" -AUX_LIBS= +AUXLIBS= case "$host" in - *-*-mingw*) RDYNAMIC="-rdynamic"; DLLEXT=".dll"; - AUXLIBS="-DLIBGLOB='\"libglob.dll\"' -DLIBREGEX='\"libgnurx-0.dll\"'"; + *-*-mingw*) AUXLIBS="-DLIBGLOB='\"libglob.dll\"' -DLIBREGEX='\"libgnurx-0.dll\"'"; LIBS="$LIBS -limagehlp -lpsapi"; - LDFLAGS="-Wl,--enable-auto-import";; - x86_64-*-linux*) RDYNAMIC="-rdynamic"; PIC="-fPIC";; - *-*-linux*) RDYNAMIC="-rdynamic";; - *-*-freebsd*) RDYNAMIC="-rdynamic";; - *-*-darwin*) DLLEXT=".dylib";; - hppa*-hp-hpux*) DLLEXT=".sl";; + LDFLAGS="-Wl,--enable-auto-import"; DLLEXT=".dll";; + x86_64-*-linux*) PIC="-fPIC";; + *-*-darwin*) rdynamic=""; shared="-dynamiclib"; DLLEXT=".dylib";; + hppa*-hp-hpux*) rdynamic=""; DLLEXT=".sl";; esac + # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -4296,7 +4296,7 @@ # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then enableval=$enable_shared; case "${enableval}" in - no) LDFLAGS="$LDFLAGS $RDYNAMIC"; sharedlib=no ;; + no) LDFLAGS="$LDFLAGS $rdynamic"; sharedlib=no ;; esac fi @@ -6029,8 +6029,9 @@ host_cpu!$host_cpu$ac_delim host_vendor!$host_vendor$ac_delim host_os!$host_os$ac_delim +shared!$shared$ac_delim +rdynamic!$rdynamic$ac_delim PIC!$PIC$ac_delim -RDYNAMIC!$RDYNAMIC$ac_delim DLLEXT!$DLLEXT$ac_delim AUXLIBS!$AUXLIBS$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim @@ -6056,7 +6057,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 70; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 71; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Modified: pure/trunk/configure.ac =================================================================== --- pure/trunk/configure.ac 2008-06-13 09:34:55 UTC (rev 203) +++ pure/trunk/configure.ac 2008-06-13 09:59:39 UTC (rev 204) @@ -9,25 +9,24 @@ AC_DEFINE_UNQUOTED(HOST, "${host}", [Define to the name of the host system.]) AC_SUBST(host) dnl Figure out extra build flags and filename extensions for various systems. -dnl XXXFIXME: -fPIC is acurrently assumed for Linux x86-64 only. There might -dnl be other Unix systems which need this. +dnl XXXFIXME: This is probably incomplete. Please let me know about options +dnl needed for other Unix flavours. +shared="-shared" +rdynamic="-rdynamic" PIC= -RDYNAMIC= DLLEXT=".so" -AUX_LIBS= +AUXLIBS= case "$host" in - *-*-mingw*) RDYNAMIC="-rdynamic"; DLLEXT=".dll"; - AUXLIBS="-DLIBGLOB='\"libglob.dll\"' -DLIBREGEX='\"libgnurx-0.dll\"'"; + *-*-mingw*) AUXLIBS="-DLIBGLOB='\"libglob.dll\"' -DLIBREGEX='\"libgnurx-0.dll\"'"; LIBS="$LIBS -limagehlp -lpsapi"; - LDFLAGS="-Wl,--enable-auto-import";; - x86_64-*-linux*) RDYNAMIC="-rdynamic"; PIC="-fPIC";; - *-*-linux*) RDYNAMIC="-rdynamic";; - *-*-freebsd*) RDYNAMIC="-rdynamic";; - *-*-darwin*) DLLEXT=".dylib";; - hppa*-hp-hpux*) DLLEXT=".sl";; + LDFLAGS="-Wl,--enable-auto-import"; DLLEXT=".dll";; + x86_64-*-linux*) PIC="-fPIC";; + *-*-darwin*) rdynamic=""; shared="-dynamiclib"; DLLEXT=".dylib";; + hppa*-hp-hpux*) rdynamic=""; DLLEXT=".sl";; esac +AC_SUBST(shared) +AC_SUBST(rdynamic) AC_SUBST(PIC) -AC_SUBST(RDYNAMIC) AC_SUBST(DLLEXT) AC_SUBST(AUXLIBS) dnl Check for programs. @@ -55,7 +54,7 @@ AC_ARG_ENABLE(shared, [ --disable-shared link the interpreter statically], [case "${enableval}" in - no) LDFLAGS="$LDFLAGS $RDYNAMIC"; sharedlib=no ;; + no) LDFLAGS="$LDFLAGS $rdynamic"; sharedlib=no ;; esac]) AC_SUBST(sharedlib) AC_ARG_ENABLE(warnings, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 09:34:46
|
Revision: 203 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=203&view=rev Author: agraef Date: 2008-06-13 02:34:55 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Rename SHARED, eliminate LIBPURE variable. Modified Paths: -------------- pure/trunk/Makefile.in pure/trunk/configure pure/trunk/configure.ac Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-13 09:18:22 UTC (rev 202) +++ pure/trunk/Makefile.in 2008-06-13 09:34:55 UTC (rev 203) @@ -66,18 +66,17 @@ libpure = lib$(libpure_vers)$(DLL) libpurelnk = lib$(libpure_base)$(DLL) -LIBPURE = -l$(libpure_vers) # Whether to build the Pure runtime library. If this is set to anything but # "yes", the interpreter is linked statically and no separate library is # produced. This is necessary on some systems where LLVM cannot be linked in # dynamically. -SHARED = @SHARED@ +sharedlib = @sharedlib@ # On some systems -fPIC is needed for code linked as a shared library. -ifeq ($(SHARED), yes) +ifeq ($(sharedlib), yes) PIC = @PIC@ else PIC = @@ -87,7 +86,7 @@ # (when built), but on some systems we have to load additional dlls to resolve # some library functions. -ifeq ($(SHARED), yes) +ifeq ($(sharedlib), yes) AUXLIBS = -DLIBPURE='"$(libpure)"' @AUXLIBS@ else AUXLIBS = @AUXLIBS@ @@ -114,9 +113,9 @@ all: pure$(EXE) -ifeq ($(SHARED), yes) +ifeq ($(sharedlib), yes) pure$(EXE): pure.o $(libpure) - $(CXX) -o $@ $(LDFLAGS) pure.o -L. $(LIBPURE) $(LIBS) + $(CXX) -o $@ $(LDFLAGS) pure.o -L. -l$(libpure_vers) $(LIBS) else pure$(EXE): pure.o $(OBJECT) $(CXX) -o $@ $(LDFLAGS) pure.o $(OBJECT) $(LLVM_LIBS) $(LIBS) @@ -189,7 +188,7 @@ install: pure$(EXE) for x in $(addprefix $(DESTDIR), $(bindir) $(libdir)/pure $(man1dir)); do $(INSTALL) -d $$x; done $(INSTALL) pure$(EXE) $(DESTDIR)$(bindir)/pure$(EXE) -ifeq ($(SHARED), yes) +ifeq ($(sharedlib), yes) $(INSTALL) $(libpure) $(DESTDIR)$(libdir)/$(libpure) ln -sf $(libdir)/$(libpure) $(DESTDIR)$(libdir)/$(libpurelnk) endif Modified: pure/trunk/configure =================================================================== --- pure/trunk/configure 2008-06-13 09:18:22 UTC (rev 202) +++ pure/trunk/configure 2008-06-13 09:34:55 UTC (rev 203) @@ -677,7 +677,7 @@ CPP GREP EGREP -SHARED +sharedlib LIBICONV ALLOCA LIBOBJS @@ -4292,11 +4292,11 @@ esac fi -SHARED=yes +sharedlib=yes # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then enableval=$enable_shared; case "${enableval}" in - no) LDFLAGS="$LDFLAGS $RDYNAMIC"; SHARED=no ;; + no) LDFLAGS="$LDFLAGS $RDYNAMIC"; sharedlib=no ;; esac fi @@ -6049,7 +6049,7 @@ CPP!$CPP$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim -SHARED!$SHARED$ac_delim +sharedlib!$sharedlib$ac_delim LIBICONV!$LIBICONV$ac_delim ALLOCA!$ALLOCA$ac_delim LIBOBJS!$LIBOBJS$ac_delim @@ -6493,7 +6493,7 @@ Installation prefix: ${prefix} Compiler: $CXX $CXXFLAGS $CPPFLAGS Linker: $CXX $LDFLAGS $LIBS - Build libpure: $SHARED + Build libpure: $sharedlib Now run 'make' to build everything, and 'make install' to install this software on your system. To remove the installed software at a later @@ -6506,7 +6506,7 @@ Installation prefix: ${prefix} Compiler: $CXX $CXXFLAGS $CPPFLAGS Linker: $CXX $LDFLAGS $LIBS - Build libpure: $SHARED + Build libpure: $sharedlib Now run 'make' to build everything, and 'make install' to install this software on your system. To remove the installed software at a later Modified: pure/trunk/configure.ac =================================================================== --- pure/trunk/configure.ac 2008-06-13 09:18:22 UTC (rev 202) +++ pure/trunk/configure.ac 2008-06-13 09:34:55 UTC (rev 203) @@ -51,13 +51,13 @@ [case "${enableval}" in yes) CPPFLAGS="-DDEBUG=2"; CXXFLAGS="-g" ;; esac]) -SHARED=yes +sharedlib=yes AC_ARG_ENABLE(shared, [ --disable-shared link the interpreter statically], [case "${enableval}" in - no) LDFLAGS="$LDFLAGS $RDYNAMIC"; SHARED=no ;; + no) LDFLAGS="$LDFLAGS $RDYNAMIC"; sharedlib=no ;; esac]) -AC_SUBST(SHARED) +AC_SUBST(sharedlib) AC_ARG_ENABLE(warnings, [ --enable-warnings enable compiler warnings (-Wall)], [case "${enableval}" in @@ -91,7 +91,7 @@ Installation prefix: ${prefix} Compiler: $CXX $CXXFLAGS $CPPFLAGS Linker: $CXX $LDFLAGS $LIBS - Build libpure: $SHARED + Build libpure: $sharedlib Now run 'make' to build everything, and 'make install' to install this software on your system. To remove the installed software at a later This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 09:18:16
|
Revision: 202 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=202&view=rev Author: agraef Date: 2008-06-13 02:18:22 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Update installation instructions. Modified Paths: -------------- pure/trunk/INSTALL Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-06-13 08:32:03 UTC (rev 201) +++ pure/trunk/INSTALL 2008-06-13 09:18:22 UTC (rev 202) @@ -58,10 +58,13 @@ $ make $ sudo make install -Note the configure flags; these are for an optimized (non-debug) build and -disable all compilation targets but the one for your system. (You might wish -to omit the --enable-targets=host-only if you want to use other LLVM -applications offering cross-compilation capabilities.) To do a debug build of +IMPORTANT: On x86-64 systems you also have to add --enable-pic. See the +comments on 64 bit support in the SYSTEM NOTES section below. + +Also note the configure flags; these are for an optimized (non-debug) build +and disable all compilation targets but the one for your system. You might +wish to omit the --enable-targets=host-only if you want to use other LLVM +applications offering cross-compilation capabilities. To do a debug build of LLVM, simply leave away all the extra configure parameters (except possibly --enable-targets=host-only). Note, however, that this will have an impact on the speed of the Pure compiler. @@ -275,13 +278,11 @@ $ ./configure --disable-shared -This works with all build types and is provided as a temporary workaround for -systems like 64 bit Linux where LLVM refuses to be linked into shared -libraries (see the notes on 64 bit systems in the NOTES section below). Please -note, however, that it is *not* recommended to do this if you don't need it, -since it drastically increases the size of the executable and thereby the -memory footprint of the interpreter if several interpreter processes are -running simultaneously. +We strongly discourage from using this option, since it drastically increases +the size of the executable and thereby the memory footprint of the interpreter +if several interpreter processes are running simultaneously. We only provide +this as a workaround for systems on which LLVM refuses to be linked into +shared libraries. RUNNING PURE FROM THE SOURCE DIRECTORY ------- ---- ---- --- ------ --------- @@ -349,19 +350,16 @@ 64 BIT SYSTEMS -- --- ------- -64 bit systems are fully supported by Pure. However, LLVM 2.2 apparently -doesn't like to be linked into shared libraries on x86-64 systems. The symptom -is that you get strange relocation errors when linking the runtime library -during the build. In this case you have to build the interpreter as a -monolithic executable which statically includes all required LLVM and the Pure -runtime modules, by configuring with --disable-shared. This has several -disadvantages, but seems to be the only way to get Pure to work on x86-64 -right now. Hopefully, these issues will be fixed with the next LLVM release. +64 bit systems are fully supported by Pure. However, you'll need to patch up +LLVM 2.2 so that it can be linked into the Pure runtime library on x86-64 +systems. You also have to configure LLVM with --enable-pic. The patch by +Cyrille Berger, which is to be applied in the llvm-2.2 source directory, is +available at http://pure-lang.sf.net/X86JITInfo.cpp.pic.patch. -Also, for unknown reasons the debug build currently does *not* work on (some?) -64 bit systems using gcc. This has been seen on various different 64 bit Linux -versions, YMMV. You can tell that you're bitten by this bug if a normal build -works, but 'make check' fails on most tests with the debug build (or if you +Also, the debug build currently does *not* work on x86-64 Linux versions. This +seems to be a bug in LLVM, so there's hope that it will go away in a future +LLVM version. You can tell that you're bitten by this bug if a normal build +works, but 'make check' fails on some tests with the debug build (or if you manually disable optimization). Fortunately, it seems that you can easily work around this by making sure that you have at least -O enabled when compiling runtime.cc. Also please note that the default and release builds should work @@ -380,13 +378,12 @@ Pure has been reported to work on OSX, and a port by Ryan Schmidt exists in the MacPorts collection, see http://www.macports.org/. -Note that with at least some current versions of the Apple gcc compiler (4.0.1 -and similar), with all warnings turned on 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. +Note that with at least some versions of the Apple gcc compiler, with all +warnings turned on 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. MS WINDOWS -- ------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-13 08:32:02
|
Revision: 201 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=201&view=rev Author: agraef Date: 2008-06-13 01:32:03 -0700 (Fri, 13 Jun 2008) Log Message: ----------- Add configure magic to get -fPIC on Linux x86-64. Modified Paths: -------------- pure/trunk/Makefile.in pure/trunk/configure pure/trunk/configure.ac Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-09 23:11:12 UTC (rev 200) +++ pure/trunk/Makefile.in 2008-06-13 08:32:03 UTC (rev 201) @@ -53,7 +53,7 @@ LLVM_FLAGS = `llvm-config --cppflags` LLVM_LIBS = `llvm-config --ldflags --libs core jit native` -CPPFLAGS = @CPPFLAGS@ $(LLVM_FLAGS) +CPPFLAGS = @CPPFLAGS@ CXXFLAGS = @CXXFLAGS@ # Pure library name. Currently we use a simple versioning scheme, which @@ -68,13 +68,21 @@ libpurelnk = lib$(libpure_base)$(DLL) LIBPURE = -l$(libpure_vers) -# Whether to build the Pure library. If this is set to anything but "yes", the -# interpreter is linked statically and no separate runtime library is +# Whether to build the Pure runtime library. If this is set to anything but +# "yes", the interpreter is linked statically and no separate library is # produced. This is necessary on some systems where LLVM cannot be linked in # dynamically. SHARED = @SHARED@ +# On some systems -fPIC is needed for code linked as a shared library. + +ifeq ($(SHARED), yes) +PIC = @PIC@ +else +PIC = +endif + # Auxiliary libraries to be loaded at runtime. Usually this is just libpure # (when built), but on some systems we have to load additional dlls to resolve # some library functions. @@ -119,11 +127,14 @@ ln -sf $(libpure) $(libpurelnk) pure.o: pure.cc - $(CXX) $(CXXFLAGS) $(CPPFLAGS) -DPURELIB='"$(libdir)/pure"' -c -o $@ $< + $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LLVM_FLAGS) -DPURELIB='"$(libdir)/pure"' -c -o $@ $< interpreter.o: interpreter.cc - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(AUXLIBS) -c -o $@ $< + $(CXX) $(CXXFLAGS) $(PIC) $(CPPFLAGS) $(LLVM_FLAGS) $(AUXLIBS) -c -o $@ $< +%.o: %.cc + $(CXX) $(CXXFLAGS) $(PIC) $(CPPFLAGS) $(LLVM_FLAGS) -c -o $@ $< + lexer.cc: lexer.ll flex -o lexer.cc $< Modified: pure/trunk/configure =================================================================== --- pure/trunk/configure 2008-06-09 23:11:12 UTC (rev 200) +++ pure/trunk/configure 2008-06-13 08:32:03 UTC (rev 201) @@ -657,6 +657,7 @@ host_cpu host_vendor host_os +PIC RDYNAMIC DLLEXT AUXLIBS @@ -1846,6 +1847,7 @@ _ACEOF +PIC= RDYNAMIC= DLLEXT=".so" AUX_LIBS= @@ -1854,6 +1856,7 @@ AUXLIBS="-DLIBGLOB='\"libglob.dll\"' -DLIBREGEX='\"libgnurx-0.dll\"'"; LIBS="$LIBS -limagehlp -lpsapi"; LDFLAGS="-Wl,--enable-auto-import";; + x86_64-*-linux*) RDYNAMIC="-rdynamic"; PIC="-fPIC";; *-*-linux*) RDYNAMIC="-rdynamic";; *-*-freebsd*) RDYNAMIC="-rdynamic";; *-*-darwin*) DLLEXT=".dylib";; @@ -1862,6 +1865,7 @@ + # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: @@ -6025,6 +6029,7 @@ host_cpu!$host_cpu$ac_delim host_vendor!$host_vendor$ac_delim host_os!$host_os$ac_delim +PIC!$PIC$ac_delim RDYNAMIC!$RDYNAMIC$ac_delim DLLEXT!$DLLEXT$ac_delim AUXLIBS!$AUXLIBS$ac_delim @@ -6051,7 +6056,7 @@ LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 69; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 70; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Modified: pure/trunk/configure.ac =================================================================== --- pure/trunk/configure.ac 2008-06-09 23:11:12 UTC (rev 200) +++ pure/trunk/configure.ac 2008-06-13 08:32:03 UTC (rev 201) @@ -9,6 +9,9 @@ AC_DEFINE_UNQUOTED(HOST, "${host}", [Define to the name of the host system.]) AC_SUBST(host) dnl Figure out extra build flags and filename extensions for various systems. +dnl XXXFIXME: -fPIC is acurrently assumed for Linux x86-64 only. There might +dnl be other Unix systems which need this. +PIC= RDYNAMIC= DLLEXT=".so" AUX_LIBS= @@ -17,11 +20,13 @@ AUXLIBS="-DLIBGLOB='\"libglob.dll\"' -DLIBREGEX='\"libgnurx-0.dll\"'"; LIBS="$LIBS -limagehlp -lpsapi"; LDFLAGS="-Wl,--enable-auto-import";; + x86_64-*-linux*) RDYNAMIC="-rdynamic"; PIC="-fPIC";; *-*-linux*) RDYNAMIC="-rdynamic";; *-*-freebsd*) RDYNAMIC="-rdynamic";; *-*-darwin*) DLLEXT=".dylib";; hppa*-hp-hpux*) DLLEXT=".sl";; esac +AC_SUBST(PIC) AC_SUBST(RDYNAMIC) AC_SUBST(DLLEXT) AC_SUBST(AUXLIBS) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-09 23:11:04
|
Revision: 200 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=200&view=rev Author: agraef Date: 2008-06-09 16:11:12 -0700 (Mon, 09 Jun 2008) Log Message: ----------- Get alloca on Windows using mingw. Modified Paths: -------------- pure/trunk/runtime.cc Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-06-09 23:02:05 UTC (rev 199) +++ pure/trunk/runtime.cc 2008-06-09 23:11:12 UTC (rev 200) @@ -13,6 +13,9 @@ # endif # endif #endif +#ifdef __MINGW32__ +#include <malloc.h> +#endif #include "runtime.h" #include "expr.hh" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-09 23:02:00
|
Revision: 199 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=199&view=rev Author: agraef Date: 2008-06-09 16:02:05 -0700 (Mon, 09 Jun 2008) Log Message: ----------- Add necessary configure magic to get alloca. Modified Paths: -------------- pure/trunk/config.h.in pure/trunk/configure pure/trunk/configure.ac pure/trunk/runtime.cc Modified: pure/trunk/config.h.in =================================================================== --- pure/trunk/config.h.in 2008-06-09 22:40:23 UTC (rev 198) +++ pure/trunk/config.h.in 2008-06-09 23:02:05 UTC (rev 199) @@ -1,5 +1,20 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + /* Define if you have the iconv() function. */ #undef HAVE_ICONV @@ -72,5 +87,13 @@ /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at runtime. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS Modified: pure/trunk/configure =================================================================== --- pure/trunk/configure 2008-06-09 22:40:23 UTC (rev 198) +++ pure/trunk/configure 2008-06-09 23:02:05 UTC (rev 199) @@ -678,6 +678,7 @@ EGREP SHARED LIBICONV +ALLOCA LIBOBJS LTLIBOBJS' ac_subst_files='' @@ -5002,6 +5003,365 @@ fi +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +{ echo "$as_me:$LINENO: checking for working alloca.h" >&5 +echo $ECHO_N "checking for working alloca.h... $ECHO_C" >&6; } +if test "${ac_cv_working_alloca_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <alloca.h> +int +main () +{ +char *p = (char *) alloca (2 * sizeof (int)); + if (p) return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_working_alloca_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_working_alloca_h=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_working_alloca_h" >&5 +echo "${ECHO_T}$ac_cv_working_alloca_h" >&6; } +if test $ac_cv_working_alloca_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ALLOCA_H 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for alloca" >&5 +echo $ECHO_N "checking for alloca... $ECHO_C" >&6; } +if test "${ac_cv_func_alloca_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# ifdef _MSC_VER +# include <malloc.h> +# define alloca _alloca +# else +# ifdef HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +# endif +#endif + +int +main () +{ +char *p = (char *) alloca (1); + if (p) return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func_alloca_works=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_alloca_works=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_alloca_works" >&5 +echo "${ECHO_T}$ac_cv_func_alloca_works" >&6; } + +if test $ac_cv_func_alloca_works = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_ALLOCA 1 +_ACEOF + +else + # The SVR3 libPW and SVR4 libucb both contain incompatible functions +# that cause trouble. Some versions do not even contain alloca or +# contain a buggy version. If you still want to use their alloca, +# use ar to extract alloca.o from them instead of compiling alloca.c. + +ALLOCA=\${LIBOBJDIR}alloca.$ac_objext + +cat >>confdefs.h <<\_ACEOF +#define C_ALLOCA 1 +_ACEOF + + +{ echo "$as_me:$LINENO: checking whether \`alloca.c' needs Cray hooks" >&5 +echo $ECHO_N "checking whether \`alloca.c' needs Cray hooks... $ECHO_C" >&6; } +if test "${ac_cv_os_cray+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#if defined CRAY && ! defined CRAY2 +webecray +#else +wenotbecray +#endif + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "webecray" >/dev/null 2>&1; then + ac_cv_os_cray=yes +else + ac_cv_os_cray=no +fi +rm -f conftest* + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_os_cray" >&5 +echo "${ECHO_T}$ac_cv_os_cray" >&6; } +if test $ac_cv_os_cray = yes; then + for ac_func in _getb67 GETB67 getb67; do + as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func. + For example, HP-UX 11i <limits.h> declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since + <limits.h> exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include <limits.h> +#else +# include <assert.h> +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + +cat >>confdefs.h <<_ACEOF +#define CRAY_STACKSEG_END $ac_func +_ACEOF + + break +fi + + done +fi + +{ echo "$as_me:$LINENO: checking stack direction for C alloca" >&5 +echo $ECHO_N "checking stack direction for C alloca... $ECHO_C" >&6; } +if test "${ac_cv_c_stack_direction+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_c_stack_direction=0 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +find_stack_direction () +{ + static char *addr = 0; + auto char dummy; + if (addr == 0) + { + addr = &dummy; + return find_stack_direction (); + } + else + return (&dummy > addr) ? 1 : -1; +} + +int +main () +{ + return find_stack_direction () < 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_stack_direction=1 +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_stack_direction=-1 +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_stack_direction" >&5 +echo "${ECHO_T}$ac_cv_c_stack_direction" >&6; } + +cat >>confdefs.h <<_ACEOF +#define STACK_DIRECTION $ac_cv_c_stack_direction +_ACEOF + + +fi + ac_config_files="$ac_config_files Makefile" cat >confcache <<\_ACEOF @@ -5686,11 +6046,12 @@ EGREP!$EGREP$ac_delim SHARED!$SHARED$ac_delim LIBICONV!$LIBICONV$ac_delim +ALLOCA!$ALLOCA$ac_delim LIBOBJS!$LIBOBJS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF - if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 68; then + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 69; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 Modified: pure/trunk/configure.ac =================================================================== --- pure/trunk/configure.ac 2008-06-09 22:40:23 UTC (rev 198) +++ pure/trunk/configure.ac 2008-06-09 23:02:05 UTC (rev 199) @@ -74,6 +74,8 @@ dnl iconv and nl_langinfo need special treatment (macros by Bruno Haible). AM_ICONV AM_LANGINFO_CODESET +dnl Determine how to get alloca. +AC_FUNC_ALLOCA AC_CONFIG_FILES([Makefile]) AC_OUTPUT Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-06-09 22:40:23 UTC (rev 198) +++ pure/trunk/runtime.cc 2008-06-09 23:02:05 UTC (rev 199) @@ -1,4 +1,19 @@ +/* AIX requires this to be the first thing in the file. */ +#ifndef __GNUC__ +# if HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX +#pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +#endif + #include "runtime.h" #include "expr.hh" #include "interpreter.hh" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-09 22:40:16
|
Revision: 198 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=198&view=rev Author: agraef Date: 2008-06-09 15:40:23 -0700 (Mon, 09 Jun 2008) Log Message: ----------- Replace malloc.h with stdlib.h. Modified Paths: -------------- pure/trunk/runtime.cc Modified: pure/trunk/runtime.cc =================================================================== --- pure/trunk/runtime.cc 2008-06-09 22:26:09 UTC (rev 197) +++ pure/trunk/runtime.cc 2008-06-09 22:40:23 UTC (rev 198) @@ -5,7 +5,7 @@ #include "util.hh" #include <readline/readline.h> #include <readline/history.h> -#include <malloc.h> +#include <stdlib.h> #include <stdarg.h> #include <iostream> #include <sstream> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-09 22:26:03
|
Revision: 197 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=197&view=rev Author: agraef Date: 2008-06-09 15:26:09 -0700 (Mon, 09 Jun 2008) Log Message: ----------- Snapshot of Pure 0.3. Added Paths: ----------- pure/releases/pure-0.3/ pure/releases/pure-0.3/ChangeLog pure/releases/pure-0.3/INSTALL pure/releases/pure-0.3/Makefile.in pure/releases/pure-0.3/NEWS pure/releases/pure-0.3/README pure/releases/pure-0.3/aclocal.m4 pure/releases/pure-0.3/config.guess pure/releases/pure-0.3/config.h.in pure/releases/pure-0.3/config.sub pure/releases/pure-0.3/configure pure/releases/pure-0.3/configure.ac pure/releases/pure-0.3/examples/myutils.pure pure/releases/pure-0.3/examples/symbolic.pure pure/releases/pure-0.3/install-sh pure/releases/pure-0.3/interpreter.cc pure/releases/pure-0.3/interpreter.hh pure/releases/pure-0.3/lexer.ll pure/releases/pure-0.3/lib/system.pure pure/releases/pure-0.3/pure.1 pure/releases/pure-0.3/pure.cc pure/releases/pure-0.3/runtime.cc pure/releases/pure-0.3/runtime.h pure/releases/pure-0.3/util.cc Removed Paths: ------------- pure/releases/pure-0.3/ChangeLog pure/releases/pure-0.3/INSTALL pure/releases/pure-0.3/Makefile pure/releases/pure-0.3/NEWS pure/releases/pure-0.3/README pure/releases/pure-0.3/examples/symbolic.pure pure/releases/pure-0.3/interpreter.cc pure/releases/pure-0.3/interpreter.hh pure/releases/pure-0.3/lexer.ll pure/releases/pure-0.3/lib/system.pure pure/releases/pure-0.3/pure.1 pure/releases/pure-0.3/pure.cc pure/releases/pure-0.3/runtime.cc pure/releases/pure-0.3/runtime.h pure/releases/pure-0.3/util.cc Copied: pure/releases/pure-0.3 (from rev 164, pure/trunk) Deleted: pure/releases/pure-0.3/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-01 20:14:57 UTC (rev 164) +++ pure/releases/pure-0.3/ChangeLog 2008-06-09 22:26:09 UTC (rev 197) @@ -1,324 +0,0 @@ -2008-06-01 Albert Graef <Dr....@t-...> - - * Makefile, interpreter.cc: Put the runtime and interpreter into a - separate shared library, to make it possible for modules to link - against the runtime, and to reduce the memory footprint when - multiple instances of the interpreter are run as different - processes. Also, this makes it possible to access the runtime - routines on systems where a program cannot dlopen itself. - -2008-05-28 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Optimization pure_freenew calls. - - * lib/strings.pure: Make 'cycle' work on strings. Reported by - Eddie Rucker. - - * lib/prelude.pure: Make 'index' work on lists. Code contributed - by Eddie Rucker. - -2008-05-27 Albert Graef <Dr....@t-...> - - * lib/prelude.pure: Rewrite prelude operations to make them - tail-recursive. - - * interpreter.cc (toplevel_codegen): Experimental support for - tail-recursive logical operators (&& and ||). This works but is - disabled, since it makes these operations behave in different ways - depending on the context, which is a really bad idea because it - violates referential transparency. - -2008-05-26 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Overhaul of the shadow stack - machinery. Environment vectors are now maintained on the shadow - stack, so that all local functions and anonymous closures are - eligible for tail call optimization, even if they need access to - their environment. - -2008-05-25 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Add marshalling between long (64 - bit) ints and Pure bigints in the C interface. This means that - both Pure ints and bigints can now be passed for 'long' arguments - of externals (with sign extension/truncation as necessary), and - 'long' values are promoted to Pure bigints on return. Hence C - functions taking 64 bit integers as arguments and returning them - as results can now be called from Pure without loosing bits due to - truncation. - - * interpreter.cc: Make toplevel if-then-else properly - tail-recursive. Thus, e.g., the following function will now run in - constant stack space: count x = if x<=0 then x else count (x-1); - This also works with nested if-then-else constructs, as long as - they form the right-hand side of an equation. - -2008-05-24 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Fix more memory allocation bugs in - exception handling. - - * runtime.cc, lib/system.pure: Bugfixes in the scanf - functions. Reported by Jiri Spitz. - - * pure.cc, runtime.cc, util.cc: Windows/MinGW compatibility - fixes. Suggested by Jiri Spitz. - -2008-05-23 Albert Graef <Dr....@t-...> - - * runtime.cc: Fix premature freeing of eval result, and a minor - memory allocation glitch in the catch function. Reported by Eddie - Rucker. - - * Makefile: Bump version number. - - * interpreter.cc: If there are any child environments, doeval and - dodefn both create semi-permanent environments now, so that the - child environments and the corresponding LLVM IR survive for the - entire lifetime of any embedded closures, which might still be - called at a later time. This fixes the segfaults occurring when a - closure gets called after its associated environment was purged. A - partial fix for some situations (as reported earlier by Chris - Double) was already in the 0.2 release, but this didn't deal with - all cases, such as closures constructed in a call to the eval - function, as reported by Eddie Rucker. - -2008-05-22 Albert Graef <Dr....@t-...> - - * interpreter.cc, runtime.cc: Major overhaul of expression memory - handling. Fixed the shadow stack and memory debugging code. Both - function arguments and environment are now visible on the shadow - stack, and all remaining memory leaks have been fixed. Note that, - compared to previous revisions, the shadow stack slows down - compiled code by some 10% and it needs some additional memory. - OTOH, it also provides additional data that will be needed in the - planned symbolic debugger, and it seems to be the most efficient - way to handle dangling expression pointers after an exception - anyway. - -2008-05-17 Albert Graef <Dr....@t-...> - - * runtime.cc (pure_free_internal): Fixed a glitch which was - causing big memleaks. Reported by Libor Spacek. - - * interpreter.cc (define): Fixed error messages. - - * interpreter.cc, runtime.h: Reorganize pure_expr data structure - so that the data fields are *always* aligned on 8 byte boundaries. - This should now also work on 32 bit architectures where doubles - are aligned on 8 byte boundaries, such as Linux on 32 bit PPC. - Reported by Tim Haynes. - - * interpreter.cc: Fixed some case labels in switch instructions - which should be signed rather than unsigned values. Also made - void* a pointer to a dummy struct in LLVM IR, so that it can be - distinguished from all other pointer types, and added support for - short (16 bit) and long (64 bit) integer types (as well as the - corresponding pointer types) in the C interface. - - Please note that the typename 'long' *always* denotes signed 64 - bit integers in Pure's extern declarations, even if the C 'long' - type is actually 32 bit (as it usually is even on most 64 bit - systems). - -2008-05-16 Albert Graef <Dr....@t-...> - - * runtime.h: Fix compilation problems when header gets included - from C. - -2008-05-14 Albert Graef <Dr....@t-...> - - * funcall.h: Reduce maximum number of function parameters to - 64. This seems to be large enough for most purposes, and speeds up - compilation with -Ox by a factor of around 10. - - * Makefile: Overhaul of build options. In particular, the - 'default' build now includes basic optimization (-O) which makes - the interpreter almost as fast as with the 'release' build, and - produces a working interpreter also on 64 bit systems. (The - 'debug' build is still broken there, but see the SYSTEM NOTES - section in the INSTALL file for a workaround.) - - * interpreter.cc, runtime.cc: 64 bit compatibility fixes in bigint - handling. - -2008-05-12 Albert Graef <Dr....@t-...> - - * interpreter.cc: Fix a severe bug in the environment handling - code of the code generator, which could cause failed assertions in - the code generator, or wrong code to be generated in some cases. - To resolve this issue, the code generator now properly keeps - separate environments for each rule of a function - definition. Reported by John Lunney. - - * Makefile: Redirect warning and error messages from regression - tests to the logfile. - -2008-05-10 Albert Graef <Dr....@t-...> - - * interpreter.cc (uminop): Handle the value -0x80000000 at the - border of the int range, so that it is correctly treated as a - machine int. - -2008-05-09 Albert Graef <Dr....@t-...> - - * lexer.ll, printer.cc, etc.: Change the "G" suffix to denote - bigints to "L" ("G" can too easily be mistaken for a digit; also, - Python uses the same "L" notation for bigints). Reported by Eddie - Rucker. - -2008-05-06 Albert Graef <Dr....@t-...> - - * lib/primitives.pure: Made the pow function work with all - combinations of integer and double arguments. Also added the sqrt - function and the ^ operator. - - * runtime.cc, lib/primitives.pure: Added predicates funp, lambdap, - varp checking for named and anonymous closures and unbound global - variables, respectively. Requested by Libor Spacek. - - * interpreter.cc (declare_extern, fun_prolog): Handle some obscure - cases of name collisions between Pure and C functions. - -2008-05-05 Albert Graef <Dr....@t-...> - - * 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. - -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.3/ChangeLog (from rev 192, pure/trunk/ChangeLog) =================================================================== --- pure/releases/pure-0.3/ChangeLog (rev 0) +++ pure/releases/pure-0.3/ChangeLog 2008-06-09 22:26:09 UTC (rev 197) @@ -0,0 +1,332 @@ +2008-06-06 Albert Graef <Dr....@t-...> + + * 0.3 release. + + * configure.ac, etc.: Added autoconf support. Various fixes for 64 + bit and Windows compatibility. See the INSTALL file for updated + installation instructions. + +2008-06-01 Albert Graef <Dr....@t-...> + + * Makefile, interpreter.cc: Put the runtime and interpreter into a + separate shared library, to make it possible for modules to link + against the runtime, and to reduce the memory footprint when + multiple instances of the interpreter are run as different + processes. Also, this makes it possible to access the runtime + routines on systems where a program cannot dlopen itself. + +2008-05-28 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Optimization of pure_freenew calls. + + * lib/strings.pure: Make 'cycle' work on strings. Reported by + Eddie Rucker. + + * lib/prelude.pure: Make 'index' work on lists. Code contributed + by Eddie Rucker. + +2008-05-27 Albert Graef <Dr....@t-...> + + * lib/prelude.pure: Rewrite prelude operations to make them + tail-recursive. + + * interpreter.cc (toplevel_codegen): Experimental support for + tail-recursive logical operators (&& and ||). This works but is + disabled, since it makes these operations behave in different ways + depending on the context, which is a really bad idea because it + violates referential transparency. + +2008-05-26 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Overhaul of the shadow stack + machinery. Environment vectors are now maintained on the shadow + stack, so that all local functions and anonymous closures are + eligible for tail call optimization, even if they need access to + their environment. + +2008-05-25 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Add marshalling between long (64 + bit) ints and Pure bigints in the C interface. This means that + both Pure ints and bigints can now be passed for 'long' arguments + of externals (with sign extension/truncation as necessary), and + 'long' values are promoted to Pure bigints on return. Hence C + functions taking 64 bit integers as arguments and returning them + as results can now be called from Pure without loosing bits due to + truncation. + + * interpreter.cc: Make toplevel if-then-else properly + tail-recursive. Thus, e.g., the following function will now run in + constant stack space: count x = if x<=0 then x else count (x-1); + This also works with nested if-then-else constructs, as long as + they form the right-hand side of an equation. + +2008-05-24 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Fix more memory allocation bugs in + exception handling. + + * runtime.cc, lib/system.pure: Bugfixes in the scanf + functions. Reported by Jiri Spitz. + + * pure.cc, runtime.cc, util.cc: Windows/MinGW compatibility + fixes. Suggested by Jiri Spitz. + +2008-05-23 Albert Graef <Dr....@t-...> + + * runtime.cc: Fix premature freeing of eval result, and a minor + memory allocation glitch in the catch function. Reported by Eddie + Rucker. + + * Makefile: Bump version number. + + * interpreter.cc: If there are any child environments, doeval and + dodefn both create semi-permanent environments now, so that the + child environments and the corresponding LLVM IR survive for the + entire lifetime of any embedded closures, which might still be + called at a later time. This fixes the segfaults occurring when a + closure gets called after its associated environment was purged. A + partial fix for some situations (as reported earlier by Chris + Double) was already in the 0.2 release, but this didn't deal with + all cases, such as closures constructed in a call to the eval + function, as reported by Eddie Rucker. + +2008-05-22 Albert Graef <Dr....@t-...> + + * interpreter.cc, runtime.cc: Major overhaul of expression memory + handling. Fixed the shadow stack and memory debugging code. Both + function arguments and environment are now visible on the shadow + stack, and all remaining memory leaks have been fixed. Note that, + compared to previous revisions, the shadow stack slows down + compiled code by some 10% and it needs some additional memory. + OTOH, it also provides additional data that will be needed in the + planned symbolic debugger, and it seems to be the most efficient + way to handle dangling expression pointers after an exception + anyway. + +2008-05-17 Albert Graef <Dr....@t-...> + + * runtime.cc (pure_free_internal): Fixed a glitch which was + causing big memleaks. Reported by Libor Spacek. + + * interpreter.cc (define): Fixed error messages. + + * interpreter.cc, runtime.h: Reorganize pure_expr data structure + so that the data fields are *always* aligned on 8 byte boundaries. + This should now also work on 32 bit architectures where doubles + are aligned on 8 byte boundaries, such as Linux on 32 bit PPC. + Reported by Tim Haynes. + + * interpreter.cc: Fixed some case labels in switch instructions + which should be signed rather than unsigned values. Also made + void* a pointer to a dummy struct in LLVM IR, so that it can be + distinguished from all other pointer types, and added support for + short (16 bit) and long (64 bit) integer types (as well as the + corresponding pointer types) in the C interface. + + Please note that the typename 'long' *always* denotes signed 64 + bit integers in Pure's extern declarations, even if the C 'long' + type is actually 32 bit (as it usually is even on most 64 bit + systems). + +2008-05-16 Albert Graef <Dr....@t-...> + + * runtime.h: Fix compilation problems when header gets included + from C. + +2008-05-14 Albert Graef <Dr....@t-...> + + * funcall.h: Reduce maximum number of function parameters to + 64. This seems to be large enough for most purposes, and speeds up + compilation with -Ox by a factor of around 10. + + * Makefile: Overhaul of build options. In particular, the + 'default' build now includes basic optimization (-O) which makes + the interpreter almost as fast as with the 'release' build, and + produces a working interpreter also on 64 bit systems. (The + 'debug' build is still broken there, but see the SYSTEM NOTES + section in the INSTALL file for a workaround.) + + * interpreter.cc, runtime.cc: 64 bit compatibility fixes in bigint + handling. + +2008-05-12 Albert Graef <Dr....@t-...> + + * interpreter.cc: Fix a severe bug in the environment handling + code of the code generator, which could cause failed assertions in + the code generator, or wrong code to be generated in some cases. + To resolve this issue, the code generator now properly keeps + separate environments for each rule of a function + definition. Reported by John Lunney. + + * Makefile: Redirect warning and error messages from regression + tests to the logfile. + +2008-05-10 Albert Graef <Dr....@t-...> + + * interpreter.cc (uminop): Handle the value -0x80000000 at the + border of the int range, so that it is correctly treated as a + machine int. + +2008-05-09 Albert Graef <Dr....@t-...> + + * lexer.ll, printer.cc, etc.: Change the "G" suffix to denote + bigints to "L" ("G" can too easily be mistaken for a digit; also, + Python uses the same "L" notation for bigints). Reported by Eddie + Rucker. + +2008-05-06 Albert Graef <Dr....@t-...> + + * lib/primitives.pure: Made the pow function work with all + combinations of integer and double arguments. Also added the sqrt + function and the ^ operator. + + * runtime.cc, lib/primitives.pure: Added predicates funp, lambdap, + varp checking for named and anonymous closures and unbound global + variables, respectively. Requested by Libor Spacek. + + * interpreter.cc (declare_extern, fun_prolog): Handle some obscure + cases of name collisions between Pure and C functions. + +2008-05-05 Albert Graef <Dr....@t-...> + + * 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. + +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 + Deleted: pure/releases/pure-0.3/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-06-01 20:14:57 UTC (rev 164) +++ pure/releases/pure-0.3/INSTALL 2008-06-09 22:26:09 UTC (rev 197) @@ -1,296 +0,0 @@ - -INSTALLING PURE (AND LLVM) -========== ==== ==== ===== - -These instructions (mostly by courtesy of Eddie Rucker, thanks Eddie!) explain -how to compile and install LLVM (which is the compiler backend required by -Pure) and the Pure interpreter itself. The instructions are for Linux and -similar Unix-like systems; the SYSTEM NOTES section at the end of this file -details the tweaks necessary to make Pure compile and run on various other -platforms. More information about installing LLVM and the required LLVM source -packages can be found at http://llvm.org. - -Pure is known to work on Linux and Mac OSX, but should compile (with the usual -amount of tweaking) on all UNIX/POSIX-based platforms. We recommend using -version 4.x of the GNU C++ compiler; it should be available almost everywhere -(in fact, since you'll need LLVM anyway, you can also use the gcc frontend -available for LLVM). 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 -===== ============ - -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 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): - -- 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 --enable-optimized --disable-assertions --disable-expensive-checks --enable-targets=host-only -$ make ENABLE_OPTIMIZED=1 -$ sudo make install - -Note the configure flags; these are for an optimized (non-debug) build and -disable all compilation targets except the one for your system. To do a debug -build of LLVM, simply leave away all the extra configure parameters (except -possibly --enable-targets=host-only). Note, however, that this will -considerably slow down the Pure compiler. - -STEP 4. Get and unpack the Pure sources at: http://pure-lang.sf.net/ - -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 Pure as follows (x.y denotes the current Pure -version number, 0.3 at the time of this writing): - -$ cd pure-x.y -$ make -$ sudo make install -$ sudo /sbin/ldconfig - -(The latter step is required on Linux systems to tell the dynamic linker to -update its cache so that it finds the Pure runtime library, libpure.so. On -other systems it may be sufficient to install the library in a location which -is searched by the dynamic linker.) - -After the build is complete, you can check that Pure is working correctly on -your computer, as follows: - -$ make check - -STEP 6. The Pure interpreter should be ready to go now. - -Run Pure interactively as: - -$ pure -Pure 0.3 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 - -This step needs to be done only once; once you've checked out your working -copy, you can update it to the latest revision by running 'svn up'. - -STEP 5': Build and install Pure: - -$ cd pure-lang/pure/trunk -$ make -$ sudo make install -$ sudo /sbin/ldconfig - - -OTHER COMPILATION OPTIONS -===== =========== ======= - -By default, the pure program goes to /usr/local/bin, the libpure.so library to -/usr/local/lib, and the Pure library scripts to /usr/local/lib/pure. The -installation directory can be changed by editing the definition of the -'prefix' variable in the Makefile, or by specifying the desired value on the -'make' command line, e.g.: - -$ make all install prefix=/usr - -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). Also note that if you install Pure into a non-standard -location, you may have to set the LD_LIBRARY_PATH variable so that the dynamic -linker finds the Pure runtime library, libpure.so. - -After your build is done, you can (and should) also run 'make check' to verify -that your Pure interpreter works correctly. This can be done without -installing the software. In fact, there's no need to install the interpreter -if you just want to take it for a test drive, you can simply run it from the -source directory, if you set up the following environment variables: - -- LD_LIBRARY_PATH=. This is required on Linux systems so that libpure.so - is found. Other systems may require an analogous setting, or none at all. - -- PURELIB=./lib This is required on all systems so that the interpreter finds - the prelude and other library scripts. - -After that you should be able to run the Pure interpreter from the source -directory, by typing './pure'. - -There are a number of other variables you can set on the 'make' command line -if you need special compiler (CXXFLAGS) or linker flags (LDFLAGS), or if you -have to add platform-specific libraries (LIBS). The DLL variable allows you to -change the shared library suffix as appropriate for your system. Please see -the Makefile for additional information on these. - -As of Pure 0.3, the 'default' build now also includes basic optimizations -(-O). This build should be ok for most purposes, and has the advantage that it -does additional runtime checks which provide diagnostics useful for -maintainers if anything is wrong with the interpreter. - -However, you can also build a "release" version of the interpreter as follows: - -$ make build=release - -This disables all runtime checks and debugging information in the interpreter -and also uses a higher level of optimization. The 'release' build will usually -give you faster execution times, but the differences aren't really that big -anymore (less than 5% compared to the default flags on my Linux system running -gcc 4.1, YMMV), so you are encouraged to use the 'default' build unless -performance is really critical. - -To get smaller executables with either the default or the release build, add -'LDFLAGS=-s' to the 'make' command (gcc only, other compilers may provide a -similar flag or a separate command to strip compiled executables and -libraries). - -You can also do a 'debug' build as follows: - -$ make build=debug - -This is like the standard build, but disables all optimizations, so -compilation is faster but the compiled interpreter is *much* slower (a factor -of about 2 on my Linux box). Hence this build is only recommended for -debugging purposes. - -More details on the build and installation process and other available targets -and options can be found in the Makefile. - - -SYSTEM NOTES -====== ===== - -Pure is known to work on recent Linux and Mac OSX versions under x86, x86-64 -and ppc, but there are a few system-specific quirks which are discussed below. -(Please also see the CAVEATS AND NOTES section of the manual page for -information on other known limitations of the current implementation.) - -ALL PLATFORMS ---- --------- - -Compiling the release version (make build=release) using 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. - -If your Pure program runs out of stack space, the interpreter will segfault. -This is *not* a bug, it happens because runtime stack checks are disabled by -default for performance reasons. You can enable stack checks by setting the -PURE_STACK environment variable accordingly; see the pure(1) manual page for -details. The interpreter will then generate orderly "stack fault" exceptions -in case of a stack overflow. - -64 BIT SYSTEMS --- --- ------- - -64 bit systems are fully supported by Pure. Alas, for unknown reasons the -'debug' build currently does *not* work on (some?) 64 bit systems using -gcc. This has been seen on various different 64 bit Linux versions, YMMV. You -can tell that you're bitten by this bug if, after running 'make debug' (or -using similar, custom compilation flags), 'make check' fails on most tests. -Fortunately, it seems that you can easily work around this by making sure that -you have at least -O enabled when compiling runtime.cc. Also please note that -the 'default' and 'release' builds should work fine. 32 bit builds also seem -to be unaffected. - -LINUX ------ - -Linux is the primary development platform for this software, and the sources -should build out of the box on all recent Linux distributions. - -MAC OSX ---- --- - -A port by Ryan Schmidt exists in the MacPorts collection at -http://www.macports.org/. If you compile Pure from the original sources -yourself, you should add the -liconv flag to the link line. To these ends, -build Pure with the following make command (add the build=release option for -the release build): - -$ make 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. - -MS WINDOWS --- ------- - -Jiri Spitz is currently working on a Windows port using Mingw. Once this is -finished, we'll provide Windows installation instructions here. For the time -being, you can try for yourself; porting should be rather straightforward with -either Cygwin (http://www.cygwin.com/) or Mingw (http://www.mingw.org/), once -you have all the necessary dependencies and a suitable version of LLVM -installed. - - -May 2008 -Albert Graef <Dr.Graef at t-online.de> -Eddie Rucker <erucker at bmc.edu> Copied: pure/releases/pure-0.3/INSTALL (from rev 193, pure/trunk/INSTALL) =================================================================== --- pure/releases/pure-0.3/INSTALL (rev 0) +++ pure/releases/pure-0.3/INSTALL 2008-06-09 22:26:09 UTC (rev 197) @@ -0,0 +1,409 @@ + +INSTALLING PURE (AND LLVM) +========== ==== ==== ===== + +These instructions (mostly by courtesy of Eddie Rucker, thanks Eddie!) explain +how to compile and install LLVM (which is the compiler backend required by +Pure) and the Pure interpreter itself. The instructions are somewhat biased +towards Linux and other Unix-like systems; the SYSTEM NOTES section at the end +of this file details the tweaks necessary to make Pure compile and run on +various other platforms. More information about installing LLVM and the +required LLVM source packages can be found at http://llvm.org. + +Pure is known to work on Linux, Mac OSX and MS Windows, and should compile +(with the usual amount of tweaking) on all recent UNIX/POSIX-based platforms. +We recommend using version 4.x of the GNU C++ compiler; it should be available +almost everywhere (in fact, since you'll need LLVM anyway, you can also use +the gcc frontend available for LLVM). You'll also need a Bourne-compatible +shell and GNU make, which are also readily available on most platforms. + + +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 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): + +- 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 --enable-optimized --disable-assertions --disable-expensive-checks --enable-targets=host-only +$ make +$ sudo make install + +Note the configure flags; these are for an optimized (non-debug) build and +disable all compilation targets but the one for your system. (You might wish +to omit the --enable-targets=host-only if you want to use other LLVM +applications offering cross-compilation capabilities.) To do a debug build of +LLVM, simply leave away all the extra configure parameters (except possibly +--enable-targets=host-only). Note, however, that this will have an impact on +the speed of the Pure compiler. + +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. Configure, build and install Pure as follows (x.y denotes the current +Pure version number, 0.3 at the time of this writing): + +$ cd pure-x.y +$ ./configure +$ make +$ sudo make install + +On some systems you may have to tell the dynamic linker to update its cache so +that it finds the Pure runtime library, libpure.so. E.g., on Linux this can be +done as follows: + +$ sudo /sbin/ldconfig + +After the build is complete, you can also run a few tests to check that Pure +is working correctly on your computer: + +$ make check + +If all is well, all tests should pass. If not, email the author or the Pure +mailing list for help. + +STEP 6. The Pure interpreter should be ready to go now. + +Run Pure interactively as: + +$ pure +Pure 0.3 (i686-pc-linux-gnu) 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/trunk pure + +This will only fetch the latest development sources (the "trunk") from svn and +put it into the 'pure' subdirectory in the current directory. To check out the +entire tree, including past releases and other branches, into a subdirectory +named 'pure-lang', use the following command instead: + +$ svn co http://pure-lang.svn.sourceforge.net/svnroot/pure-lang pure-lang + +This step needs to be done only once; once you've checked out your working +copy, you can update it to the latest revision at any time by running +'svn up'. + +STEP 5': Configure, build and install Pure: + +$ cd pure (or 'cd pure-lang/pure/trunk', if you checked out the entire tree) +$ ./configure +$ make +$ sudo make install + + +OTHER COMPILATION OPTIONS +===== =========== ======= + +The Pure configure script takes a few options which enable you to change the +installation path and control a number of other build options. Moreover, there +are some environment variables which also affect compilation and installation. + +Use './configure --help' to print a summary of the provided options. + +INSTALLATION PATH +------------ ---- + +By default, the pure program, runtime library and library scripts are +installed in /usr/local/bin, /usr/local/lib and /usr/local/lib/pure, +respectively. This can be changed by specifying the desired installation +prefix with the --prefix option, e.g.: + +$ ./configure --prefix=/usr + +(Note that if you install Pure into a non-standard location, you may have to +set LD_LIBRARY_PATH or a similar variable so that the dynamic linker finds the +Pure runtime library, libpure.so.) + +In addition, the DESTDIR variable enables package maintainers to install Pure +into a special "staging" directory, so that installed files can be packaged +more easily. If set at installation time, DESTDIR will be used as an +additional prefix to all installation paths. For instance, the following +command will put all installed files into the tmp-root subdirectory of the +current directory: + +$ make install DESTDIR=tmp-root + +SEPARATE BUILD DIRECTORY +-------- ----- --------- + +It is possible to build Pure in a separate directory, in order to keep your +source tree tidy and clean, or to build multiple versions of the interpreter +with different compilation flags from the same source tree. + +To these ends, just cd to the build directory and run configure and make +there, e.g. (this assumes that you start from the source directory): + +$ mkdir BUILD +$ cd BUILD +$ ../configure +$ make + +COMPILER AND LINKER OPTIONS +-------- --- ------ ------- + +There are a number of environment variables you can set on the 'configure' +command line if you need special compiler or linker options: + +- CPPFLAGS: preprocessor options (-I, -D, etc.) +- CXXFLAGS: compilation options (-g, -O, etc.) +- LDFLAGS: linker flags (-s, -L, etc.) +- LIBS: additional objects and libraries (-lfoo, bar.o, etc.) + +For instance, the following 'configure' command changes the default +compilation options to '-g' and adds '/opt/include' and '/opt/lib' to the +include and library search paths, respectively: + +$ ./configure CPPFLAGS=-I/opt/include CXXFLAGS=-g LDFLAGS=-L/opt/lib + +More details on the build and installation process and other available targets +and options can be found in the Makefile. + +PREDEFINED BUILD TYPES +---------- ----- ----- + +For convenience, 'configure' provides some options to set up CPPFLAGS and +CXXFLAGS for various build types. + +Note that, as of Pure 0.3, the default build already includes most +optimizations (-O2). This build should be ok for most purposes, and has the +advantage that it does additional runtime checks which provide diagnostics +useful for maintainers if anything is wrong with the interpreter. However, you +can also build a "release" version of the interpreter by running configure as +follows: + +$ ./configure --enable-release + +This disables all runtime checks and debugging information in the interpreter, +and uses a higher optimization level (-O3). The release build will usually +give you faster execution times, but the differences to the default build +aren't really that big anymore (less than 5% compared to the default flags on +my Linux system running gcc 4.1, YMMV), so you are encouraged to use the +default build unless performance is really critical. + +To get smaller executables with either the default or the release build, add +'LDFLAGS=-s' to the 'configure' command (gcc only, other compilers may provide +a similar flag or a separate command to strip compiled executables and +libraries). + +You can also do a "debug" build as follows: + +$ ./configure --enable-debug + +This is like the default build, but disables all optimizations, so compilation +is faster but the compiled interpreter is *much* slower (a factor of about 2 +on my Linux box). Hence this build is only recommended for debugging purposes. + +You can combine all build types with the following option to enable compiler +warnings (-Wall): + +$ ./configure --enable-warnings + +This option is useful to check the interpreter sources for questionable +constructs which might actually be bugs. However, for some older gcc versions +it spits out lots of bogus warnings, so it is not enabled by default. + +In addition, there is an option to build a "monolithic" interpreter which is +linked statically against the LLVM libraries, instead of producing a separate +runtime library: + +$ ./configure --disable-shared + +This works with all build types and is provided as a temporary workaround for +systems like 64 bit Linux where LLVM refuses to be linked into shared +libraries (see the notes on 64 bit systems in the NOTES section below). Please +note, however, that it is *not* recommended to do this if you don't need it, +since it drastically increases the size of the executable and thereby the +memory footprint of the interpreter if several interpreter processes are +running simultaneously. + +RUNNING PURE FROM THE SOURCE DIRECTORY +------- ---- ---- --- ------ --------- + +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 +at all if you just want to take it for a test drive, you can simply run it +from the source directory, if you set up the following environment variables +(this assumes that you built Pure in the source directory; when using a +separate build directory, you'll have to change the paths accordingly): + +- LD_LIBRARY_PATH=. This is required on Linux systems so that libpure.so + is found. Other systems may require an analogous setting, or none at all. + +- PURELIB=./lib This is required on all systems so that the interpreter finds + the prelude and other library scripts. + +After that you should be able to run the Pure interpreter from the source +directory, by typing './pure'. + +OTHER TARGETS +----- ------- + +The Makefile supports the usual 'clean' and 'distclean' targets, and +'realclean' will remove all files created by the maintainer, including test +logs and C++ source files generated from Flex and Bison grammars. (Only use +the latter if you know what you are doing, since it will remove files which +require special tools to be regenerated.) + +There also are a number of targets like 'html' and 'pdf' which generate the +documentation in a variety of formats (this requires groff); see the Makefile +for details. + +Last but not least, maintainers can roll distribution tarballs with 'make +dist' and 'make distcheck' (the latter is like 'make dist', but also does a +test build and installation to verify that your tarball contains all needed +bits and pieces). + + +SYSTEM NOTES +====== ===== + +Pure is known to work on recent Linux and Mac OSX versions under x86, x86-64 +and ppc, as well as on MS Windows, but there are a few system-specific quirks +which are discussed below. (Please also see the CAVEATS AND NOTES section of +the manual page for information on other known limitations of the current +implementation.) + +ALL PLATFORMS +--- --------- + +Compiling the default and release versions using gcc with all warnings turned +on (-Wall) 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. + +If your Pure program runs out of stack space, the interpreter will segfault. +This is *not* a bug, it happens because runtime stack checks are disabled by +default for performance reasons. You can enable stack checks by setting the +PURE_STACK environment variable accordingly; see the pure(1) manual page for +details. The interpreter will then generate orderly "stack fault" exceptions +in case of a stack overflow. + +64 BIT SYSTEMS +-- --- ------- + +64 bit systems are fully supported by Pure. However, LLVM 2.2 apparently +doesn't like to be linked into shared libraries on x86-64 systems. The symptom +is that you get strange relocation errors when linking the runtime library +during the build. In this case you have to build the interpreter as a +monolithic executable which statically includes all required LLVM and the Pure +runtime modules, by configuring with --disable-shared. This has several +disadvantages, but seems to be the only way to get Pure to work on x86-64 +right now. Hopefully, these issues will be fixed with the next LLVM release. + +Also, for unknown reasons the debug build currently does *not* work on (some?) +64 bit systems using gcc. This has been seen on various different 64 bit Linux +versions, YMMV. You can tell that you're bitten by this bug if a normal build +works, but 'make check' fails on most tests with the debug build (or if you +manually disable optimization). Fortunately, it seems that you can easily work +around this by making sure that you have at least -O enabled when compiling +runtime.cc. Also please note that the default and release builds should work +fine. 32 bit builds also seem to be unaffected. + +LINUX +----- + +Linux is the primary development platform for this software, and the sources +should build out of the box on all recent Linux distributions. (But note the +issues on x86-64 Linux systems described above.) + +MAC OSX +--- --- + +Pure has been reported to work on OSX, and a port by Ryan Schmidt exists in +the MacPorts collection, see http://www.macports.org/. + +Note that with at least some current versions of the Apple gcc compiler (4.0.1 +and similar), with all warnings turned on 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. + +MS WINDOWS +-- ------- + +Thanks to Jiri Spitz' perseverance, tireless testing and bug reports, the +sources compile and run fine on Windows now, using the Mingw port of the GNU +C++ compiler and the MSYS environment from http://www.mingw.org/. Just do the +usual './configure && make && make install'. You'll need LLVM, of course +(which builds with Mingw just fine), and a few additional libraries for which +headers and precompiled binaries are available from the Pure website +(http://pure-lang.sf.net/). + +A binary package in msi format is available as well (see "Downloads" on the +Pure website), which includes all required libraries and some shortcuts to run +the Pure interpreter and read online documentation in html help format. + + +June 2008 +Albert Graef <Dr.Graef at t-online.de> +Eddie Rucker <erucker at bmc.edu> Deleted: pure/releases/pure-0.3/Makefile =================================================================== --- pure/trunk/Makefile 2008-06-01 20:14:57 UTC (rev 164) +++ pure/releases/pure-0.3/Makefile 2008-06-09 22:26:09 UTC (rev 197) @@ -1,265 +0,0 @@ - -# This Makefile requires GNU make. Really. - -# Basic setup. You can change the version number and installation paths here. - -# For instance, to install under /usr instead of /usr/local, run 'make -# prefix=/usr && make install prefix=/usr'. Please note that the 'prefix' -# option must be specified *both* at build and at installation time. At -# installation time, you can also specify a DESTDIR path if you want to -# install into a staging directory, e.g.: 'make install DESTDIR=$PWD/BUILD'. - -version = 0.3 -dist = pure-$(version) - -prefix = /usr/local -bindir = $(prefix)/bin -libdir = $(prefix)/lib -mandir = $(prefix)/share/man/man1 - -# Shared library suffix. The default should work on most Linux and Unix -# systems. Use DLL=dll on Windows. - -DLL=so - -# Staging directory for 'make install'. If you use this, make sure that this -# ends in a slash. - -DESTDIR= - -# Linker flags. Adjust these as necessary for your system. - -# LDFLAGS is for additional linker options, LIBS for additional libraries that -# might be needed (e.g., -liconv on OSX and Windows). - -LDFLAGS= -LIBS= - -# Compilation flags. We currently provide the following build profiles: - -# 'default' compiles with extra runtime checks and debugging information. -# 'release' optimizes for execution speed (release version). -# 'debug' like 'default', but without any optimizations. -# 'debug2' extensive debugging output, useful to debug the interpreter. - -# The 'default' build should be suitable for most purposes. As of Pure 0.3, -# this build now also does basic optimizations and so isn't much slower than -# the 'release' build any more. In contrast to 'release', this build also -# provides diagnostics useful for maintainers if anything is wrong with the -# interpreter. - -# The 'release' build disables all runtime checks and debugging information -# and compiles with additional optimizations which makes programs go a little -# faster (some 5-10% on a single-cpu AMD system running Linux and gcc 4.1, -# YMMV); use this if performance is critical. - -# The 'debug' build is like 'default' but without any optimizations; it builds -# faster than 'default', but runs *much* slower, and isn't recommended for -# anything but debugging the interpreter. The 'debug2' build generates massive -# amounts of additional debugging messages, and is really only to be used by -# maintainers debugging the interpreter. - -# To build with a given profile, just say 'make build=<profile>', e.g.: 'make -# build=release'. (This option only has to be specified at build time, not for -# installation or any other targets except 'all'.) Just 'make' builds with the -# default flags. - -build=default - -LLVM_FLAGS = `llvm-config --cppflags` -LLVM_LIBS = `llvm-config --ldflags --l... [truncated message content] |
From: <ag...@us...> - 2008-06-09 21:51:27
|
Revision: 196 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=196&view=rev Author: agraef Date: 2008-06-09 14:51:35 -0700 (Mon, 09 Jun 2008) Log Message: ----------- Use syntactic equality in differentiation rule. Modified Paths: -------------- pure/trunk/examples/symbolic.pure Modified: pure/trunk/examples/symbolic.pure =================================================================== --- pure/trunk/examples/symbolic.pure 2008-06-08 10:14:35 UTC (rev 195) +++ pure/trunk/examples/symbolic.pure 2008-06-09 21:51:35 UTC (rev 196) @@ -19,7 +19,7 @@ diff x (u+v) = diff x u + diff x v; diff x (u*v) = u*diff x v + v*diff x u; -diff x y = 1 if str x==str y; +diff x y = 1 if x===y; = 0 otherwise; // Example: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-08 10:14:31
|
Revision: 195 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=195&view=rev Author: agraef Date: 2008-06-08 03:14:35 -0700 (Sun, 08 Jun 2008) Log Message: ----------- Fix rman rule. Modified Paths: -------------- pure/trunk/Makefile.in Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-08 09:21:21 UTC (rev 194) +++ pure/trunk/Makefile.in 2008-06-08 10:14:35 UTC (rev 195) @@ -143,7 +143,7 @@ # don't have rman, uncomment the rule below instead. %.html: %.1 - rman -f HTML -r off $< | sed -e 's/dq/\"/g' -e '/<br>/d' > $@ + rman -f HTML $< | sed -e 's/dq/\"/g' -e '/<br>/d' > $@ #%.html: %.1 # groff -man -Thtml $< > $@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-08 09:21:17
|
Revision: 194 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=194&view=rev Author: agraef Date: 2008-06-08 02:21:21 -0700 (Sun, 08 Jun 2008) Log Message: ----------- Format HTML version of manpage with rman, looks nicer. Modified Paths: -------------- pure/trunk/Makefile.in Modified: pure/trunk/Makefile.in =================================================================== --- pure/trunk/Makefile.in 2008-06-08 09:20:05 UTC (rev 193) +++ pure/trunk/Makefile.in 2008-06-08 09:21:21 UTC (rev 194) @@ -139,9 +139,15 @@ ps: pure.ps pdf: pure.pdf +# We do the html format using rman, because it produces nicer output. If you +# don't have rman, uncomment the rule below instead. + %.html: %.1 - groff -man -Thtml $< > $@ + rman -f HTML -r off $< | sed -e 's/dq/\"/g' -e '/<br>/d' > $@ +#%.html: %.1 +# groff -man -Thtml $< > $@ + %.dvi: %.1 groff -man -Tdvi $< > $@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-08 09:20:04
|
Revision: 193 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=193&view=rev Author: agraef Date: 2008-06-08 02:20:05 -0700 (Sun, 08 Jun 2008) Log Message: ----------- Final touches for 0.3 release. Modified Paths: -------------- pure/trunk/INSTALL Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-06-07 23:42:04 UTC (rev 192) +++ pure/trunk/INSTALL 2008-06-08 09:20:05 UTC (rev 193) @@ -392,18 +392,16 @@ -- ------- Thanks to Jiri Spitz' perseverance, tireless testing and bug reports, the -latest sources compile and run fine on Windows, using the Mingw port of the -GNU C++ compiler and the MSYS environment from http://www.mingw.org/. Just do -the usual './configure && make && make install'. You'll need LLVM, of course +sources compile and run fine on Windows now, using the Mingw port of the GNU +C++ compiler and the MSYS environment from http://www.mingw.org/. Just do the +usual './configure && make && make install'. You'll need LLVM, of course (which builds with Mingw just fine), and a few additional libraries for which headers and precompiled binaries are available from the Pure website (http://pure-lang.sf.net/). A binary package in msi format is available as well (see "Downloads" on the -Pure website), which includes all required libraries. The package also -includes some shortcuts which will be installed in your Program menu, allowing -you to run the Pure interpreter either in a normal Windows command window or -the MSYS shell available from http://www.mingw.org/. +Pure website), which includes all required libraries and some shortcuts to run +the Pure interpreter and read online documentation in html help format. June 2008 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-07 23:42:01
|
Revision: 192 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=192&view=rev Author: agraef Date: 2008-06-07 16:42:04 -0700 (Sat, 07 Jun 2008) Log Message: ----------- Final touches for 0.3 release. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/INSTALL pure/trunk/README pure/trunk/pure.1 Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-06-07 06:36:38 UTC (rev 191) +++ pure/trunk/ChangeLog 2008-06-07 23:42:04 UTC (rev 192) @@ -1,5 +1,7 @@ 2008-06-06 Albert Graef <Dr....@t-...> + * 0.3 release. + * configure.ac, etc.: Added autoconf support. Various fixes for 64 bit and Windows compatibility. See the INSTALL file for updated installation instructions. Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-06-07 06:36:38 UTC (rev 191) +++ pure/trunk/INSTALL 2008-06-07 23:42:04 UTC (rev 192) @@ -61,8 +61,8 @@ Note the configure flags; these are for an optimized (non-debug) build and disable all compilation targets but the one for your system. (You might wish to omit the --enable-targets=host-only if you want to use other LLVM -applications and offering cross-compilation capabilities.) To do a debug build -of LLVM, simply leave away all the extra configure parameters (except possibly +applications offering cross-compilation capabilities.) To do a debug build of +LLVM, simply leave away all the extra configure parameters (except possibly --enable-targets=host-only). Note, however, that this will have an impact on the speed of the Pure compiler. @@ -99,7 +99,7 @@ Run Pure interactively as: $ pure -Pure 0.3 Copyright (c) 2008 by Albert Graef +Pure 0.3 (i686-pc-linux-gnu) 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. @@ -147,7 +147,8 @@ $ svn co http://pure-lang.svn.sourceforge.net/svnroot/pure-lang pure-lang This step needs to be done only once; once you've checked out your working -copy, you can update it to the latest revision by running 'svn up'. +copy, you can update it to the latest revision at any time by running +'svn up'. STEP 5': Configure, build and install Pure: @@ -325,10 +326,10 @@ ====== ===== Pure is known to work on recent Linux and Mac OSX versions under x86, x86-64 -and ppc, as well as on MS Windows XP, but there are a few system-specific -quirks which are discussed below. (Please also see the CAVEATS AND NOTES -section of the manual page for information on other known limitations of the -current implementation.) +and ppc, as well as on MS Windows, but there are a few system-specific quirks +which are discussed below. (Please also see the CAVEATS AND NOTES section of +the manual page for information on other known limitations of the current +implementation.) ALL PLATFORMS --- --------- @@ -392,14 +393,19 @@ Thanks to Jiri Spitz' perseverance, tireless testing and bug reports, the latest sources compile and run fine on Windows, using the Mingw port of the -GNU C++ compiler and the MSys environment from http://www.mingw.org/. (Cygwin -from http://www.cygwin.com/ probably works as well, but this has not been -tested.) Just do the usual './configure && make && make install'. You'll need -LLVM, of course (which builds with Mingw just fine), and a few additional -libraries for which headers and precompiled binaries are available from the -Pure website (http://pure-lang.sf.net/). +GNU C++ compiler and the MSYS environment from http://www.mingw.org/. Just do +the usual './configure && make && make install'. You'll need LLVM, of course +(which builds with Mingw just fine), and a few additional libraries for which +headers and precompiled binaries are available from the Pure website +(http://pure-lang.sf.net/). +A binary package in msi format is available as well (see "Downloads" on the +Pure website), which includes all required libraries. The package also +includes some shortcuts which will be installed in your Program menu, allowing +you to run the Pure interpreter either in a normal Windows command window or +the MSYS shell available from http://www.mingw.org/. + June 2008 Albert Graef <Dr.Graef at t-online.de> Eddie Rucker <erucker at bmc.edu> Modified: pure/trunk/README =================================================================== --- pure/trunk/README 2008-06-07 06:36:38 UTC (rev 191) +++ pure/trunk/README 2008-06-07 23:42:04 UTC (rev 192) @@ -15,7 +15,8 @@ WHERE TO GET IT -You can find tarballs and the svn repository at http://pure-lang.sf.net. +You can find tarballs, binary packages and the svn repository at +http://pure-lang.sf.net. LICENSE Modified: pure/trunk/pure.1 =================================================================== --- pure/trunk/pure.1 2008-06-07 06:36:38 UTC (rev 191) +++ pure/trunk/pure.1 2008-06-07 23:42:04 UTC (rev 192) @@ -198,7 +198,7 @@ .PP Expressions consist of the following elements: .TP -.B Constants: \fR4711, 4711G, 1.2e-3, \(dqHello,\ world!\en\(dq +.B Constants: \fR4711, 4711L, 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, although the Pure syntax differs in some minor ways, as discussed in the following. First, there @@ -491,7 +491,7 @@ to handle these kinds of exceptions just like any other. For instance: .sp .nf -> fact n = if n>0 then n*fact(n-1) else 1; +> fact n = \fBif\fP n>0 \fBthen\fP n*fact(n-1) \fBelse\fP 1; > catch error (fact foo); error failed_cond > catch error (fact 100000); @@ -604,7 +604,7 @@ declaration into a script): .sp .nf -> extern double sin(double); +> \fBextern\fP double sin(double); > sin 0.3; 0.29552020666134 .fi @@ -613,7 +613,7 @@ e.g.: .sp .nf -extern double sin(double x); +\fBextern\fP double sin(double x); .fi .sp Parameter names in prototypes only serve informational purposes and are for @@ -678,7 +678,7 @@ declaration with a clause of the form ``= \fIalias\fP''. For instance: .sp .nf -> extern double sin(double) = c_sin; +> \fBextern\fP double sin(double) = c_sin; > sin x::double = c_sin x; > sin x::int = c_sin (double x); > sin 0.3; sin 0; @@ -687,12 +687,12 @@ .fi .PP External C functions are resolved by the LLVM runtime, which first looks for -the symbol in the interpreter executable. Since the interpreter links in its -own runtime support as well as all of the standard C library, these functions -are ready to be used in Pure programs. Other functions can be made available -by including them in the runtime, or by linking the interpreter against the -corresponding modules. Or, better yet, you can just ``dlopen'' shared -libraries at runtime with a special form of the +the symbol in the C library and Pure's runtime library (or the interpreter +executable, if the interpreter was linked statically). Thus all C library and +Pure runtime functions are readily available in Pure programs. Other functions +can be provided by including them in the runtime, or by linking the +interpreter against the corresponding modules. Or, better yet, you can just +``dlopen'' shared libraries at runtime with a special form of the .B using clause: .sp @@ -713,9 +713,9 @@ .PP Shared libraries opened with \fBusing\fP clauses are searched for on the usual system linker path (\fBLD_LIBRARY_PATH\fP on Linux). The necessary filename -suffix (\fB.so\fP on Linux) will also be supplied automatically. You can also -specify a full pathname for the library if you prefer that. If a library file -cannot be found, or if an +suffix (e.g., \fB.so\fP on Linux or \fB.dll\fP on Windows) will also be +supplied automatically. You can also specify a full pathname for the library +if you prefer that. If a library file cannot be found, or if an .B extern declaration names a function symbol which cannot be resolved, an appropriate error message is printed. @@ -886,7 +886,9 @@ Output is piped through the .BR more (1) program to make it easier to read, as some of the options (in particular, -.BR -c and -d ) +.B -c +and +.BR -d ) may produce excessive amounts of information. .PP For instance, to list all definitions in all loaded scripts (including the @@ -1009,8 +1011,8 @@ rules, but \fIbelow\fP our previous `foo (x:xs) = x*foo xs;' equation entered at the same level. As you can see, we have now effectively replaced our original definition of `foo' with a version that calculates list products -instead of sums, but of course we can easily go back to the previous level to -restore the previous definition: +instead of sums, but of course we can easily go back one level to restore the +previous definition: .sp .nf > \fBclear\fP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |