wisp
 
(Arne Babenhauserheide)
2017-09-25: self-contained language/wisp and fixed partial un-indent stable v0.9.5

self-contained language/wisp and fixed partial un-indent

diff --git a/Makefile.am b/Makefile.am
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,11 +4,11 @@ sitedir = $(GUILE_SITE)
 site_DATA = wisp-scheme.scm
 
 langdir = ${datarootdir}/guile/site/$(GUILE_EFFECTIVE_VERSION)/language/wisp
-lang_DATA = language/wisp/spec.scm
+lang_DATA = language/wisp/spec.scm language/wisp.scm
 
 WISP = wisp-guile.w wisp-reader.w wisp-scheme.w
 
-EXTRA_DIST = $(WISP) bootstrap.sh bootstrap-reader.sh examples tests wisp-repl-guile.sh testrunner.w wisp.py wisp.scm $(wildcard m4/*)
+EXTRA_DIST = $(WISP) bootstrap.sh bootstrap-reader.sh language examples tests wisp-repl-guile.sh testrunner.w wisp.py wisp.scm m4
 CLEANFILES = 1 2
 DISTCLEANFILES = $(lang_DATA) $(site_DATA)
 # don't spout out lots of stuff at each distcheck. Disable for debugging.
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
 wisp ():
 
+wisp 0.9.5:
+- Fix bug with using not yet defined lower indentation levels.
+  See tests/partial-indent.{w,scm}
+- move wisp-scheme.scm to language/wisp.scm
+  this allows creating a wisp-project by simply copying language/
+
 wisp 0.9.4:
 - provide realpath on OSX to get the tests to run
 - change installation to guile/site/(guile version)/language/wisp
diff --git a/bootstrap-reader.sh b/bootstrap-reader.sh
--- a/bootstrap-reader.sh
+++ b/bootstrap-reader.sh
@@ -34,11 +34,11 @@ mkdir -p ${builddir}/language/wisp
 echo ";;;" preparing the reader: wisp at the REPL 1>&2
 
 echo ";;;" parsing wisp-scheme.w with the parser for the REPL 1>&2
-${guile} ${wisp} ${srcdir}/wisp-scheme.w 2>/dev/null > ${builddir}/wisp-scheme.scm \
+${guile} ${wisp} ${srcdir}/wisp-scheme.w 2>/dev/null > ${builddir}/language/wisp.scm \
     && echo ";;;" ...precompiling the parser... 1>&2 \
-    && ${guile} -s ${builddir}/wisp-scheme.scm 2>/dev/null \
+    && ${guile} -s ${builddir}/language/wisp.scm 2>/dev/null \
     && echo ";;;" ...succeeded 1>&2 \
-    || echo creating wisp-scheme.scm failed
+    || echo creating language/wisp.scm failed
 
 echo ";;;"  parsing the spec file... 1>&2
 ${guile} ${wisp} ${srcdir}/wisp-reader.w 2>/dev/null > ${builddir}/language/wisp/spec.scm \
diff --git a/configure.ac b/configure.ac
--- a/configure.ac
+++ b/configure.ac
@@ -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], [0.9.4],
+AC_INIT([wisp], [0.9.5],
         [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])
diff --git a/examples/evaluate-r7rs-benchmark.w b/examples/evaluate-r7rs-benchmark.w
--- a/examples/evaluate-r7rs-benchmark.w
+++ b/examples/evaluate-r7rs-benchmark.w
@@ -6,6 +6,10 @@ exec guile -L ~/wisp --language=wisp -s 
 ;; Evaluate the benchmarks from ecraven at http://ecraven.github.io/r7rs-benchmarks/benchmark.html
 ;; Uses data from http://ecraven.github.io/r7rs-benchmarks/all.csv
 
+;; example usage: 
+;; $ for i in bigloo bones chez chibi chicken- chickencsi- cyclone femtolisp foment gambitc gauche guile ironscheme kawa larceny mit mosh petite picrin racket rhizome rscheme s9fes sagittarius scheme48- stalin tinyscheme vicare ypsilon; do echo $i $(./evaluate-r7rs-benchmark.w guile-ecraven-benchmarks-result-2017-08-13.csv $i | grep Geom -A 2 | grep -v = | grep .); done | sed 's/(//' > evaluate-r7rs-benchmark.data
+;; $ echo -e 'set xtics rotate by 90 right\nplot "< sort -g -k2 evaluate-r7rs-benchmark.data" using 0:2:xtic(1) with lines title "runtime: geometric mean multiple of fastest", "< sort -g -k2 evaluate-r7rs-benchmark.data" using 0:3:xtic(1) with lines title "successful tests"' | gnuplot -p
+
 import : ice-9 rdelim
          srfi srfi-1
          ice-9 pretty-print
diff --git a/testrunner.w b/testrunner.w
--- a/testrunner.w
+++ b/testrunner.w
@@ -11,7 +11,7 @@ define scheme-file : list-ref (command-l
 
 use-modules 
   srfi srfi-1
-  wisp-scheme
+  language wisp
 
 
 define : read-all port
diff --git a/tests/partial-indent.scm b/tests/partial-indent.scm
new file mode 100644
--- /dev/null
+++ b/tests/partial-indent.scm
@@ -0,0 +1,14 @@
+(write
+ (list
+    (+ 1 2)
+   (+ 2 3)))
+(newline)
+
+(write
+ (list
+    (+ 1 2
+      (+ 3 4))
+   (+ 2 3)))
+(newline)
+
+
diff --git a/tests/partial-indent.w b/tests/partial-indent.w
new file mode 100644
--- /dev/null
+++ b/tests/partial-indent.w
@@ -0,0 +1,12 @@
+write
+ list
+    + 1 2
+   + 2 3
+newline
+
+write
+ list
+    + 1 2
+      + 3 4
+   + 2 3
+newline
diff --git a/wisp-reader.w b/wisp-reader.w
--- a/wisp-reader.w
+++ b/wisp-reader.w
@@ -8,7 +8,7 @@
 ; adapted from spec.scm: https://gitorious.org/nacre/guile-sweet/source/ae306867e371cb4b56e00bb60a50d9a0b8353109:sweet/spec.scm
 define-module : language wisp spec
 ;   . #:use-module : wisp
-  . #:use-module : wisp-scheme
+  . #:use-module : language wisp
   . #:use-module : system base compile
   . #:use-module : system base language
   . #:use-module : language scheme compile-tree-il
diff --git a/wisp-scheme.w b/wisp-scheme.w
--- a/wisp-scheme.w
+++ b/wisp-scheme.w
@@ -35,7 +35,7 @@ exec guile -L . --language=wisp -s "$0" 
 ;; SOFTWARE.
 
 
-define-module : wisp-scheme
+define-module : language wisp
    . #:export (wisp-scheme-read-chunk wisp-scheme-read-all 
                wisp-scheme-read-file-chunk wisp-scheme-read-file
                wisp-scheme-read-string)
@@ -460,9 +460,6 @@ define : wisp-propagate-source-propertie
 
 define : wisp-scheme-indentation-to-parens lines
          . "Add parentheses to lines and remove the indentation markers"
-         ; FIXME: Find new algorithm which mostly uses current-line
-         ; and the indentation-levels for tracking. The try I have in
-         ; here right now is wrong.
          when 
            and 
              not : null? lines
@@ -531,7 +528,15 @@ define : wisp-scheme-indentation-to-pare
                      : > current-indentation current-line-indentation
                        ; display "current-indent > next-line\n"
                        ; this just steps back one level via the side-recursion.
-                       values processed unprocessed
+                       let : : previous-indentation : car : cdr indentation-levels
+                         if : <= current-line-indentation previous-indentation
+                            values processed unprocessed
+                            loop ;; not yet used level! TODO: maybe throw an error here.
+                              . processed
+                              . unprocessed
+                              cons ; recursion via the indentation-levels
+                                . current-line-indentation 
+                                cdr indentation-levels
                      : = current-indentation current-line-indentation
                        ; display "current-indent = next-line\n"
                        let