M NEWS +4 -0
@@ 1,3 1,7 @@
+wisp 1.0.6
+- allow (and ignore!) a single space indentation for the first line of a chunk to support meta-commands
+- ensure that (language wisp) is compiled in the wisp REPL
+
wisp 1.0.5
- explicitly allow using wisp as language under the expat-license for easier embedding in Guile-using games like Tsukundere Shitsumon: https://gitlab.com/leoprikler/tsukundere-shitsumon/
M configure.ac +1 -1
@@ 1,7 1,7 @@
dnl run `autoreconf -i` to generate a configure script.
dnl Then run ./configure to generate a Makefile.
dnl Finally run make to generate the project.
-AC_INIT([wisp], [1.0.5],
+AC_INIT([wisp], [1.0.6],
[arne_bab@web.de])
# Add macros in m4/ to ensure that wisp builds without having Guile in the aclocal path
AC_CONFIG_MACRO_DIR([m4])
M examples/evaluate-r7rs-benchmark.w +1 -0
@@ 120,6 120,7 @@ define : main args
: port : open-input-file csv-file
data-by-project : read-csv port
data-min-by-test : min-alist-by-test data-by-project
+ guile-data : select-project-data data-by-project project-prefix
when : member "--csv" args
; display "test slowdown\n"
map : λ (x) : apply format #t "~a ~a\n" : list (car x) (cdr x)
A => examples/lisp2wisp.w +87 -0
@@ 0,0 1,87 @@
+#!/usr/bin/env bash
+# -*- wisp -*-
+guile -L $(dirname $(dirname $(realpath "$0"))) -c '(import (language wisp spec))'
+exec -a "$0" guile -L $(dirname $(dirname $(realpath "$0"))) --language=wisp -x .w -e '(examples lisp2wisp)' -c '' "$@"
+; !#
+
+;; Turning lisp-code programs into wisp-code — approximate inverse of wisp2lisp.
+
+;; Limitation: Currently this strips out comments. TODO: strip all comments and assign them to the correct lines categorized by line-number.
+
+;; Approach:
+;; - Read the AST as list of lists with repeated (read)
+;; - Turn it into basic wisp that only uses the : for empty lines and uses no parens at all
+;; - Collapse lines using : and () with a heuristic (maximum line-length, known forms).
+;; - use curly-infix
+
+;; for emacs (progn (defun test-this-file () (interactive) (save-current-buffer) (async-shell-command (concat (buffer-file-name (current-buffer)) " --test"))) (local-set-key (kbd "<f9>") 'test-this-file))
+
+
+
+define-module : examples lisp2wisp
+ . #:export (lisp2wisp main)
+
+import : examples doctests
+ srfi srfi-1 ; list operations
+ srfi srfi-37 ; commandline parsing
+ srfi srfi-9 ; records
+ only (srfi srfi-26) cut
+ rnrs bytevectors
+ ice-9 optargs
+ ice-9 match
+ ice-9 format
+ ice-9 rdelim ; for read-string
+ ice-9 binary-ports
+ ice-9 pretty-print
+
+define : read-file filepath
+ let*
+ : port : open-input-file filepath
+ data : read-delimited "" port
+ close port
+ . data
+
+define : write-file filepath bytevector
+ let*
+ : port : open-output-file filepath
+ put-bytevector port bytevector
+ close port
+
+
+define : read-all port
+ let loop : : res : '
+ let : : next : read port
+ if : eof-object? next
+ . res
+ loop : append res : list next
+
+define : format-basic-wisp code
+ let loop : (depth 0) (code code)
+ cond
+ : list? code
+ string-append
+ loop depth : car code
+ if (null? (cdr code)) "" " "
+ string-join : map (cut loop (+ depth 1) <>) : cdr code
+ if (pair? (car code)) "\n" " "
+ else
+ pretty-print code
+ format #f "~s" code
+
+define : format-wisp-lines code
+ string-join
+ map format-basic-wisp code
+ . "\n"
+
+define : lisp2wisp port
+ ##
+ tests
+ test-equal : string-trim-right : read-file "../tests/btest.w"
+ lisp2wisp : open-input-file "../tests/btest.scm"
+ test-equal : string-trim-right : read-file "../tests/dotted-pair.w"
+ lisp2wisp : open-input-file "../tests/dotted-pair.scm"
+ format-wisp-lines : read-all port
+
+define %this-module : current-module
+define : main args
+ doctests-testmod %this-module
M ob-wisp.el +3 -3
@@ 80,7 80,7 @@ This will typically be either 'wisp or '
:type 'symbol)
(defun org-babel-execute:wisp (body params)
- "Execute a block of Wisp code with Babel.
+ "Execute a block of Wisp code BODY with Babel using PARAMS.
This function is called by `org-babel-execute-src-block'."
(let* ((session (org-babel-wisp-initiate-session
(cdr (assoc :session params))))
@@ 143,8 143,8 @@ specifying a variable of the same value.
(concat "list" (mapconcat #'org-babel-wisp-var-to-wisp var " "))
(if (equal var 'hline)
org-babel-wisp-hline-to
- (format ;; TODO: adjust to wisp
- (if (and (stringp var) (string-match "[\n\r]" var)) "\"\"%S\"\"" "%S")
+ (format
+ (if (and (stringp var) (string-match "[\n\r]" var)) "\"%S\"" "%S")
(if (stringp var) (substring-no-properties var) var)))))
(defun org-babel-wisp-table-or-string (results)
M wisp-scheme.w +9 -3
@@ 465,9 465,15 @@ define* : wisp-scheme-indentation-to-par
not : null? lines
not : line-empty-code? : car lines
not : = 0 : line-real-indent : car lines ; -1 is a line with a comment
- throw 'wisp-syntax-error
- format #f "The first symbol in a chunk must start at zero indentation. Indentation and line: ~A"
- car lines
+ if : = 1 : line-real-indent : car lines
+ ;; accept a single space as indentation of the first line (and ignore the indentation) to support meta commands
+ set! lines
+ cons
+ cons 0 : cdr : car lines
+ cdr lines
+ throw 'wisp-syntax-error
+ format #f "The first symbol in a chunk must start at zero indentation. Indentation and line: ~A"
+ car lines
let loop
: processed '()
unprocessed lines
M wisp.in +2 -0
@@ 4,4 4,6 @@
if [ -z ${GUILE+x} ]; then
GUILE=guile
fi
+;; ensure that wisp is compiled
+"${GUILE}" -c '(import (language wisp))' >/dev/null 2>&1
exec -a "$0" "${GUILE}" -x .w --language=wisp "$@"