(Arne Babenhauserheide)
2015-02-23: merge merge
diff --git a/README b/README --- a/README +++ b/README @@ -4,18 +4,21 @@ Wisp: Whitespace to Lisp define : hello (define (hello) display "Hello World" ⇒ (display "Hello World")) +<a name="fibonacci"></a> define : fibonacci n (define (fibonacci n) let rek : (i 0) (u 1) (v 1) (let rek ((i 0) (u 1) (v 1)) - if : >= i : - n 2 ⇒ (if (>= i (- n 2)) + if : >= i {n - 2} ⇒ (if (>= i (- n 2)) . v v - rek (+ i 1) v (+ u v) (rek (+ i 1) v (+ u v))))) + rek {i + 1} v {u + v} (rek (+ i 1) v (+ u v))))) -Wisp turns indentation based syntax into Lisp. The conversion is homoiconic[^h], generic[^g], and backwards-compatible[^b]. It is inspired by [project readable][], but tries to keep itself simple (and stupid: just a preprocessor). More information on the [wisp-website][] and code in the [wisp-repository][]. +Wisp turns indentation based syntax into Lisp. The conversion is homoiconic[^h], generic[^g], and backwards-compatible[^b]. It is inspired by [project readable][], but tries to keep itself simple (and stupid: just add parens for indentation). More information is available on the [wisp-website][], and code in the [wisp-repository][]. For a short presentation, see [Why Wisp?](why-wisp.html) +Note that this is full-fledged scheme, with all its capabilities like hygienic macros (programmable syntax!) and full tail recursion. + [wisp-website]: http://draketo.de/light/english/wisp-lisp-indentation-preprocessor "wisp: Whitespace to Lisp: An indentation to parentheses preprocessor to get more readable Lisp" [wisp-repository]: http://draketo.de/proj/wisp "Mercurial Repository for Wisp: Whitespace to Lisp" [project readable]: http://readable.sourceforge.net/ "Readable Lisp S-expressions Project" @@ -40,24 +43,15 @@ Usage Wisp and curly infix (SRFI-105) ------------------------------- -Wisp treats braces "{}" the same as parentheses "()" and square brackets "[]", so you can use it with curly infix ([SRFI-105](http://srfi.schemers.org/srfi-105/srfi-105.html)) to get more customary math expressions. In Guile Scheme with Wisp you can activate curly infix using the following line `. #!curly-infix ` (with a final space!) - -<a name="fibonacci"></a>By combining curly-infix and wisp, the well-known Fibonacci sequence can be defined as follows: - - . #!curly-infix - define : fibonacci n - let rek : (i 0) (u 1) (v 1) - if {i >= {n - 2}} - . v - rek {i + 1} v {u + v} - -Note that this is full-fledged scheme, with all its capabilities like hygienic macros (programmable syntax!) and full tail recursion. +Wisp treats braces "{}" the same as parentheses "()" and square brackets "[]", so you can use it with curly infix ([SRFI-105](http://srfi.schemers.org/srfi-105/srfi-105.html)) to get more customary math expressions. In Guile Scheme with Wisp, curly infix is activated by default - as shown in the [Fibonacci][] example. If you want to use a curly-infix expression starting a line, you have to prefix it with a dot: . {1 + 1} ; = 2 +[Fibonacci]: #fibonacci "Generation of the fibonacci sequence in wisp and s-expressions" + Notes ----- diff --git a/docs/srfi-from-template.html b/docs/srfi-from-template.html --- a/docs/srfi-from-template.html +++ b/docs/srfi-from-template.html @@ -1,9 +1,9 @@ -<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head> <title>SRFI ?: wisp: simpler indentation-sensitive scheme</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> - <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <body> <H1>Title</H1> @@ -32,7 +32,7 @@ This SRFI describes a simple syntax whic </p> <p> -Different from its precedessors, wisp only uses the absolute minimum of additional syntax-elements which are required for writing and exchanging arbitrary code-structures. As syntax elements it only uses a colon surrounded by whitespace, the period followed by whitespace as first code-character on the line and optional underscores followed by whitespace at the beginning of the line. +Different from its predecessors, wisp only uses the absolute minimum of additional syntax-elements which are required for writing and exchanging arbitrary code-structures. As syntax elements it only uses a colon surrounded by whitespace, the period followed by whitespace as first code-character on the line and optional underscores followed by whitespace at the beginning of the line. </p> <p> @@ -64,7 +64,7 @@ Wisp expressions can include any s-expre <H1>Rationale</H1> -<p>A big strength of Scheme and other lisp-like languages is their minimalistic syntax. By using only the most common characters like the period, the comma, the quote and quasiquote, the hash, the semicolon and the parens for the syntax (<code>.,"'`#;()</code>), they are very close to natural language.<a href="#common-letters" name="common-letters-reference">⁽¹⁾</a> Along with the minimal list-structure of the code, this gives these languages a timeless elegance.</p> +<p>A big strength of Scheme and other lisp-like languages is their minimalistic syntax. By using only the most common characters like the period, the comma, the quote and quasiquote, the hash, the semicolon and the parens for the syntax (<code>.,"'`#;()</code><!--"-->), they are very close to natural language.<a href="#common-letters" name="common-letters-reference">⁽¹⁾</a> Along with the minimal list-structure of the code, this gives these languages a timeless elegance.</p> <p>But as SRFI-110 explains very thoroughly (which we need not repeat here), the parentheses at the beginning of lines hurt readability and scare away newcomers. Additionally using indentation to mark the structure of the code follows naturally from the observation that most programmers use indentation, with many programmers letting their editor indent code automatically to fit the structure. Indentation is an important way how programmers understand code and using it directly to define the structure avoids errors due to mismatches between indentation and actual meaning.</p> @@ -89,7 +89,7 @@ Wisp expressions can include any s-expre <p>Here wisp uses the leading period to mark a line as continuing the argument list.<a href="#period-concept" name="period-concept-reference">⁽²⁾</a></p> -<p>SRFI-110 improves a lot over the implementation of SRFI-49. It resolves the group-naming and reduces the need to continue the argument-list by introducing 3 different grouping syntaxes (<code>$</code>, <code>\\</code> and <code><* *></code>). These additional syntax-elements however hurt readability for newcomers (obviously the authors of SRFI-110 disagree with this assertion. Their view is discussed in SRFI-110 in the section about wisp). The additional syntax elements lead to structures like the following (taken from examples from the readable project):</p> +<p>SRFI-110 improves a lot over the implementation of SRFI-49. It resolves the group-naming and reduces the need to continue the argument-list by introducing 3 different grouping syntax forms (<code>$</code>, <code>\\</code> and <code><* *></code>). These additional syntax-elements however hurt readability for newcomers (obviously the authors of SRFI-110 disagree with this assertion. Their view is discussed in SRFI-110 in the section about wisp). The additional syntax elements lead to structures like the following (taken from examples from the readable project):</p> <table><tr><th>SRFI-110 / readable</th></tr><tr><td> @@ -111,7 +111,7 @@ Wisp expressions can include any s-expre <p>This is not only hard to read, but also makes it harder to work with the code, because the programmer has to learn these additional syntax elements and keep them in mind before being able to understand the code.</p> -<p>Like SRFI-49 SRFI-110 also cannot continue the argument-list without resorting to single-element lines, though it reduces this problem by the above grouping syntaxes and advertising the use of neoteric expressions from SRFI-105.</p> +<p>Like SRFI-49 SRFI-110 also cannot continue the argument-list without resorting to single-element lines, though it reduces this problem by the above grouping syntax forms and advertising the use of neoteric expressions from SRFI-105.</p> <h2>Wisp example</h2> @@ -148,7 +148,7 @@ Since an example speaks more than a hund <h2>Related SRFIs</h2> <ul> -<li>SRFI-49 (Indentation-sensitive syntax): superceded by this SRFI, +<li>SRFI-49 (Indentation-sensitive syntax): superseded by this SRFI, </li> <li>SRFI-110 (Sweet-expressions (t-expressions)): alternative to this SRFI, </li> @@ -161,8 +161,8 @@ Since an example speaks more than a hund <h2>Footnotes</h2> -<ul><li><a name="common-letters" href="#common-letters-reference">⁽¹⁾</a> The most common non-letter, non-math characters in prose are <code>.,":'_#?!;</code>, in the given order as derived from newspapers and other sources (for the ngram assembling scripts, see the <a href="http://bitbucket.org/ArneBab/evolve-keyboard-layout">evolve keyboard layout project</a>).</li> - <li><a name="period-concept" href="#period-concept-reference">⁽²⁾</a> Conceptually, continuing the argument list with a period uses syntax to mark the rare case of not calling a function as opposed to marking the common case of calling a function. To back the claim, that calling a function is actually the common case in scheme-code, grepping the the modules in the Guile source code shows over 27000 code-lines which start with a paren and only slightly above 10000 code-lines which start with a non-paren, non-comment character. Since wisp-syntax mostly follows the regular scheme indentation guidelines (as realized for example by emacs), the whitespace in front of lines does not need to change.</li> +<ul><li><a name="common-letters" href="#common-letters-reference">⁽¹⁾</a> The most common non-letter, non-math characters in prose are <code>.,":'_#?!;</code><!--"-->, in the given order as derived from newspapers and other sources (for the ngram assembling scripts, see the <a href="http://bitbucket.org/ArneBab/evolve-keyboard-layout">evolve keyboard layout project</a>).</li> + <li><a name="period-concept" href="#period-concept-reference">⁽²⁾</a> Conceptually, continuing the argument list with a period uses syntax to mark the rare case of not calling a function as opposed to marking the common case of calling a function. To back the claim, that calling a function is actually the common case in scheme-code, grepping the the modules in the Guile source code shows over 27000 code-lines which start with a paren and only slightly above 10000 code-lines which start with a non-paren, non-comment character. Since wisp-syntax mostly follows the regular scheme indentation guidelines (as realized for example by Emacs), the whitespace in front of lines does not need to change.</li> <li><a name="typed-racket" href="#typed-racket-reference">⁽³⁾</a> Typed Racket uses calls of the form <code>(: x Number)</code> to declare types. These forms can still be used directly in parenthesized form, but in wisp-form the colon has to be replaced with <code>\:</code>. In most cases type-declarations are not needed in typed racket, since the type can be inferred. See <a href="http://docs.racket-lang.org/ts-guide/more.html?q=typed#%28part._when-annotations~3f%29">When do you need type annotations?</a></li> </ul> @@ -238,7 +238,7 @@ Since an example speaks more than a hund (<i>body</i>)) </pre> -<p><i>requirement: represent code with two adjadent blocks in double-parentheses.</i></p> +<p><i>requirement: represent code with two adjacent blocks in double-parentheses.</i></p> <h3>Wisp syntax 4/4: Resilient Indentation</h3> @@ -302,10 +302,6 @@ Since an example speaks more than a hund </pre> -<!--TODO: add syntax highlighting.--> - - - <h4>Closing line</h4> @@ -315,9 +311,9 @@ Since an example speaks more than a hund -<pre>display ; (display - string-append "Hello " "World!" ; (string-append "Hello " "World!")) -display "Hello Again!" ; (display "Hello Again!") +<pre><i>display</i> ; (<i>display</i> + <i>string-append</i> "Hello " "World!" ; (<i>string-append</i> "Hello " "World!")) +<i>display</i> "Hello Again!" ; (<i>display</i> "Hello Again!") </pre> @@ -348,8 +344,8 @@ display "Hello Again!" ; -<pre>string-append "Hello" ; (string-append "Hello" - string-append " " "World" ; (string-append " " "World") +<pre><i>string-append</i> "Hello" ; (<i>string-append</i> "Hello" + <i>string-append</i> " " "World" ; (<i>string-append</i> " " "World") . "!" ; "!") </pre> @@ -366,10 +362,10 @@ display "Hello Again!" ; -<pre>let ; (let +<pre><b>let</b> ; (<b>let</b> : ; ( - msg "Hello World!" ; (msg "Hello World!")) - display msg ; (display msg)) + <i>msg</i> "Hello World!" ; (<i>msg</i> "Hello World!")) + <i>display</i> msg ; (<i>display</i> msg)) </pre> @@ -380,14 +376,14 @@ display "Hello Again!" ; <h4>Inline Colon</h4> <p> -<b>A colon sourrounded by whitespace (" : ") starts a parenthesis which gets closed at the end of the line</b>. +<b>A colon surrounded by whitespace (" : ") starts a parenthesis which gets closed at the end of the line</b>. </p> -<pre>define : hello who ; (define (hello who) - display ; (display - string-append "Hello " who "!" ; (string-append "Hello " who "!"))) +<pre><b>define</b> : <i>hello</i> who ; (<b>define</b> (<i>hello</i> who) + <i>display </i> ; (<i>display</i> + <i>string-append</i> "Hello " who "!" ; (<i>string-append</i> "Hello " who "!"))) </pre> @@ -401,8 +397,8 @@ If the colon is the last non-whitespace -<pre>let : ; (let () - display "Hello" ; (display "Hello")) +<pre><b>let</b> : ; (<b>let</b> () + <i>display</i> "Hello" ; (<i>display</i> "Hello")) </pre> @@ -417,9 +413,9 @@ If the colon is the last non-whitespace -<pre>define : hello who ; (define (hello who) -_ display ; (display -___ string-append "Hello " who "!" ; (string-append "Hello " who "!"))) +<pre><b>define</b> : <i>hello</i> who ; (<b>define</b> (<i>hello</i> who) +_ <i>display</i> ; (<i>display</i> +___ <i>string-append</i> "Hello " who "!" ; (<i>string-append</i> "Hello " who "!"))) </pre> @@ -434,11 +430,11 @@ If the colon is the last non-whitespace -<pre>define : stringy s - string-append s " reversed and capitalized: +<pre><b>define</b> : <i>stringy</i> s + <i>string-append</i> s " reversed and capitalized: " ; linebreaks in strings do not affect wisp parsing - . (string-capitalize ; same for linebreaks in parentheses - (string-reverse s)) + . (<i>string-capitalize</i> ; same for linebreaks in parentheses + (<i>string-reverse</i> s)) </pre> @@ -448,8 +444,8 @@ Effectively code in parentheses and stri -<pre>define foo (+ 1 - (* 2 3)) ; defines foo as 7 +<pre><b>define</b> foo (<i>+</i> 1 + (<i>*</i> 2 3)) ; defines foo as 7 </pre> @@ -475,7 +471,7 @@ Effectively code in parentheses and stri <li>A colon (:) at the beginning of a line adds an extra open parentheses that gets closed at end-of-line <b>and</b> defines an indentation level. </li> -<li>using a quote to escape a symbol separated from it by whitespace is forbidden. This would make the meaning of quoted lines ambigous. +<li>Using a quote to escape a symbol separated from it by whitespace is forbidden. This would make the meaning of quoted lines ambiguous. </li> <li>Curly braces should be treated as curly-infix following SRFI-105. This makes most math look natural to newcomers. @@ -484,22 +480,25 @@ Effectively code in parentheses and stri <li>Neoteric expressions from SRFI-105 are not required because they create multiple ways to represent the same code. In wisp they add much less advantages than in sweet expressions from SRFI-110, because wisp can continue the arguments to a function after a function call (with the leading period) and the inline colon provides most of the benefits neoteric expressions give to sweet. However implementations providing wisp should give users the option to activate neoteric expressions as by SRFI-105 to allow experimentation and evolution (<a href="http://sourceforge.net/p/readable/mailman/message/33068104/">discussion</a>). </li> -<li>It is possible to write code which is at the same time valid wisp and sweet. The readable mailinglist <a href="http://sourceforge.net/p/readable/mailman/message/33058992/">contains details</a>. +<li>It is possible to write code which is at the same time valid wisp and sweet. The readable mailing list <a href="http://sourceforge.net/p/readable/mailman/message/33058992/">contains details</a>. </li> + +<li>The suggested suffix for files using wisp-syntax is <code>.w</code>. + </ul> <h2>Syntax justification</h2> <p> -<i>I do not like adding any unnecessary syntax element to lisp. So I want to show explicitely why the syntax elements are required.</i> +<i>I do not like adding any unnecessary syntax element to lisp. So I want to show explicitly why the syntax elements are required.</i> </p> +<p> <small> -<p> See also <a href="http://draketo.de/light/english/wisp-lisp-indentation-preprocessor#sec-4">http://draketo.de/light/english/wisp-lisp-indentation-preprocessor#sec-4</a> +</small> </p> -</small> @@ -537,7 +536,7 @@ At its core, this dot-rule means that we <h3> : (the colon)</h3> <p> -For double parentheses and for some other cases we must have a way to mark indentation levels which do not contain code. Wisp uses the colon, because it is the most common non-alpha-numeric character in normal prose which is not already reserved as syntax by Scheme when it is surrounded by whitespace, and because it already gets used without sourrounding whitespace for marking keyword arguments to functions in Emacs Lisp and Common Lisp, so it does not add completely alien concepts. +For double parentheses and for some other cases we must have a way to mark indentation levels which do not contain code. Wisp uses the colon, because it is the most common non-alpha-numeric character in normal prose which is not already reserved as syntax by Scheme when it is surrounded by whitespace, and because it already gets used without surrounding whitespace for marking keyword arguments to functions in Emacs Lisp and Common Lisp, so it does not add completely alien concepts. </p> <p> @@ -553,7 +552,7 @@ For simple cases, the colon could be rep </p> -<pre>(doublelet +<pre>(<i>doublelet</i> ((foo bar)) ((bla foo))) </pre> @@ -563,10 +562,10 @@ For simple cases, the colon could be rep The wisp version of this is </p> -<pre>doublelet +<pre><i>doublelet</i> : foo bar - : ; <- this empty backstep is the real issue + : ; <- this empty back step is the real issue bla foo </pre> @@ -577,7 +576,7 @@ or shorter with inline colon (which you -<pre>doublelet +<pre><i>doublelet</i> : foo bar : bla foo </pre> @@ -601,7 +600,7 @@ Defining intermediate indentation-levels -<pre>define (flubb) +<pre><b>define</b> (<i>flubb</i>) nubb hubb subb @@ -615,7 +614,7 @@ would become -<pre>(define (flubb) +<pre>(<b>define</b> (<i>flubb</i>) ((nubb)) ((hubb)) ((subb)) @@ -629,7 +628,7 @@ while -<pre>define (flubb) +<pre><b>define</b> (<i>flubb</i>) nubb hubb subb @@ -642,7 +641,7 @@ would become -<pre>(define (flubb) +<pre>(<b>define</b> (<i>flubb</i>) (nubb) (hubb) (subb)) @@ -659,10 +658,10 @@ Fixed indentation width (alternative opt -<pre>when - equal? wrong - isright? stuff - fixstuff +<pre><b>when</b> + <i>equal?</i> wrong + <i>isright?</i> stuff + <i>fixstuff</i> </pre> @@ -672,7 +671,7 @@ Fixed indentation width (alternative opt <h3> _ (the underscore)</h3> <p> -In Python the whitespace hostile html already presents problems with sharing code - for example in email list archives and forums. But Python-programmers can mostly infer the indentation by looking at the previous line: If that ends with a colon, the next line must be more indented (there is nothing to clearly mark reduced indentation, though). In wisp we do not have this support, so we need a way to survive in the hostile environment of todays web. +In Python the whitespace hostile html already presents problems with sharing code - for example in email list archives and forums. But Python-programmers can mostly infer the indentation by looking at the previous line: If that ends with a colon, the next line must be more indented (there is nothing to clearly mark reduced indentation, though). In wisp we do not have this support, so we need a way to survive in the hostile environment of today's web. </p> <p> @@ -687,7 +686,7 @@ You can still use underscores anywhere b <H1>Implementation</H1> -<p>The reference implementation realizes a specialized parser for Scheme. It uses GNU Guile and can also be used at the REPL.</p> +<p>The reference implementation realizes a specialized parser for Scheme. It uses <a href="https://gnu.org/s/guile" title="GNU Guile: The GNU extension language">GNU Guile</a> and can also be used at the REPL.</p> <p>The wisp code also contains a general wisp-preprocessor which can be used for any lisp-like language and can used as an external program which gets called on reading. It does not actually have to understand the code itself.</p> @@ -695,16 +694,15 @@ You can still use underscores anywhere b <p>The wisp preprocessor implementation can be found in the <a href="http://draketo.de/proj/wisp">wisp code repository</a>. Both implementations are explicitly licensed to allow inclusion in an SRFI.</p> - -<!--TODO: Link to implementation as plain Scheme fil and HTML with only the testsuite.--> +<p>The reference implementation linked below generates a syntax tree from wisp which can be executed. It is written in indentation-based wisp-syntax and converted with the preprocessor from the code repository (wisp-guile.w) to parenthesized scheme syntax.</p> <ul> - <li><A HREF="srfi minus ???-reference.scm">Source for the reference implementation.</A></li> - <li><A HREF="srfi minus ???-testsuite.html">Basic Testsuite for wisp implementations.</A> <br />(a more exhaustive testsuite is available in the <a href="http://draketo.de/proj/wisp">wisp code repository</a>)</li> + <li><A HREF="http://draketo.de/proj/wisp/srfi-reference.scm">Source for the reference implementation</A>.</li> + <li><A HREF="http://draketo.de/proj/wisp/srfi-testsuite.html">Basic Testsuite for wisp implementations</A>. <br>(a more exhaustive testsuite is available in the <a href="http://draketo.de/proj/wisp">wisp code repository</a>)</li> </ul> <H1>Copyright</H1> -Copyright (C) ??? (199?). All Rights Reserved. +Copyright (C) Arne Babenhauserheide (2014). All Rights Reserved. <p> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), diff --git a/docs/srfi-testsuite.html b/docs/srfi-testsuite.html new file mode 100644 --- /dev/null +++ b/docs/srfi-testsuite.html @@ -0,0 +1,957 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> +<head> +<title>Test Suite</title> +<!-- 2014-12-23 Di 22:50 --> +<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +<meta name="generator" content="Org-mode" /> +<meta name="author" content="Arne Babenhauserheide" /> +<style type="text/css"> + <!--/*--><![CDATA[/*><!--*/ + .title { text-align: center; } + .todo { font-family: monospace; color: red; } + .done { color: green; } + .tag { background-color: #eee; font-family: monospace; + padding: 2px; font-size: 80%; font-weight: normal; } + .timestamp { color: #bebebe; } + .timestamp-kwd { color: #5f9ea0; } + .right { margin-left: auto; margin-right: 0px; text-align: right; } + .left { margin-left: 0px; margin-right: auto; text-align: left; } + .center { margin-left: auto; margin-right: auto; text-align: center; } + .underline { text-decoration: underline; } + #postamble p, #preamble p { font-size: 90%; margin: .2em; } + p.verse { margin-left: 3%; } + pre { + border: 1px solid #ccc; + box-shadow: 3px 3px 3px #eee; + padding: 8pt; + font-family: monospace; + overflow: auto; + margin: 1.2em; + } + pre.src { + position: relative; + overflow: visible; + padding-top: 1.2em; + } + pre.src:before { + display: none; + position: absolute; + background-color: white; + top: -10px; + right: 10px; + padding: 3px; + border: 1px solid black; + } + pre.src:hover:before { display: inline;} + pre.src-sh:before { content: 'sh'; } + pre.src-bash:before { content: 'sh'; } + pre.src-emacs-lisp:before { content: 'Emacs Lisp'; } + pre.src-R:before { content: 'R'; } + pre.src-perl:before { content: 'Perl'; } + pre.src-java:before { content: 'Java'; } + pre.src-sql:before { content: 'SQL'; } + + table { border-collapse:collapse; } + caption.t-above { caption-side: top; } + caption.t-bottom { caption-side: bottom; } + td, th { vertical-align:top; } + th.right { text-align: center; } + th.left { text-align: center; } + th.center { text-align: center; } + td.right { text-align: right; } + td.left { text-align: left; } + td.center { text-align: center; } + dt { font-weight: bold; } + .footpara:nth-child(2) { display: inline; } + .footpara { display: block; } + .footdef { margin-bottom: 1em; } + .figure { padding: 1em; } + .figure p { text-align: center; } + .inlinetask { + padding: 10px; + border: 2px solid gray; + margin: 10px; + background: #ffffcc; + } + #org-div-home-and-up + { text-align: right; font-size: 70%; white-space: nowrap; } + textarea { overflow-x: auto; } + .linenr { font-size: smaller } + .code-highlighted { background-color: #ffff00; } + .org-info-js_info-navigation { border-style: none; } + #org-info-js_console-label + { font-size: 10px; font-weight: bold; white-space: nowrap; } + .org-info-js_search-highlight + { background-color: #ffff00; color: #000000; font-weight: bold; } + /*]]>*/--> +</style> +<script type="text/javascript"> +/* +@licstart The following is the entire license notice for the +JavaScript code in this tag. + +Copyright (C) 2012-2013 Free Software Foundation, Inc. + +The JavaScript code in this tag is free software: you can +redistribute it and/or modify it under the terms of the GNU +General Public License (GNU GPL) as published by the Free Software +Foundation, either version 3 of the License, or (at your option) +any later version. The code is distributed WITHOUT ANY WARRANTY; +without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. + +As additional permission under GNU GPL version 3 section 7, you +may distribute non-source (e.g., minimized or compacted) forms of +that code without the copy of the GNU GPL normally required by +section 4, provided you include this license notice and a URL +through which recipients can access the Corresponding Source. + + +@licend The above is the entire license notice +for the JavaScript code in this tag. +*/ +<!--/*--><![CDATA[/*><!--*/ + function CodeHighlightOn(elem, id) + { + var target = document.getElementById(id); + if(null != target) { + elem.cacheClassElem = elem.className; + elem.cacheClassTarget = target.className; + target.className = "code-highlighted"; + elem.className = "code-highlighted"; + } + } + function CodeHighlightOff(elem, id) + { + var target = document.getElementById(id); + if(elem.cacheClassElem) + elem.className = elem.cacheClassElem; + if(elem.cacheClassTarget) + target.className = elem.cacheClassTarget; + } +/*]]>*///--> +</script> +</head> +<body> +<div id="content"> +<h1 class="title">Test Suite</h1> +<p> +The wisp test-suite consists of a large number of wisp-snippets and the corresponding scheme-code. +</p> + +<p> +A wisp-implementation may call itself compliant with the wisp test-suite if the code tree parsed from the wisp file is the same as a code tree parsed from the equivalent Scheme file. +</p> + +<p> +A wisp-implementation may call itself a compliant wisp pre-processor if it successfully converts each wisp-snippet into the corresponging scheme-snippet. Blank lines at the end of the file and non-functional white-space in the produced scheme-file do not matter for this purpose. +</p> + +<p> +This test-suite is also available in the <a href="http://draketo.de/proj/wisp">wisp repository</a> along with a script-runner (runtests.sh) which tests the reference wisp-implementation with GNU Guile against this testsuite.<sup><a id="fnr.1" name="fnr.1" class="footref" href="#fn.1">1</a></sup> +</p> + +<div id="outline-container-sec-1" class="outline-2"> +<h2 id="sec-1"><span class="section-number-2">1</span> tests/syntax-underscore.w</h2> +<div class="outline-text-2" id="text-1"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">a</span> b c +<span style="color: #0000ff;">_ d</span> e +<span style="color: #0000ff;">___ f</span> +<span style="color: #0000ff;">___</span> g h +<span style="color: #0000ff;">__</span><span style="color: #a020f0;"> . </span>i + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">_</span> +<span style="color: #0000ff;">_ display</span> <span style="color: #8b2252;">"hello\n"</span> + +<span style="color: #0000ff;">\_</span> +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-2" class="outline-2"> +<h2 id="sec-2"><span class="section-number-2">2</span> tests/syntax-underscore.scm</h2> +<div class="outline-text-2" id="text-2"> +<div class="org-src-container"> + +<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">a</span> b c) + (d e + (f) + (g h) + i)) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">_</span>) + (display <span style="color: #8b2252;">"hello\n"</span>)) + +(_) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-3" class="outline-2"> +<h2 id="sec-3"><span class="section-number-2">3</span> tests/syntax-strings-parens.w</h2> +<div class="outline-text-2" id="text-3"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #b22222;">; </span><span style="color: #b22222;">Test linebreaks in strings and brackets</span> + +<span style="color: #a020f0;">. </span><span style="color: #8b2252;">"flubbub</span> + +<span style="color: #8b2252;">flabbab"</span> + +hrug (<span style="color: #0000ff;">nadda</span> +<span style="color: #0000ff;">madda</span> gadda <span style="color: #8b2252;">"shoktom</span> +<span style="color: #8b2252;"> mee"</span> <span style="color: #8b2252;">" sep </span> +<span style="color: #8b2252;">ka"</span> +<span style="color: #0000ff;"> hadda)</span> +<span style="color: #0000ff;"> gom</span> + +<span style="color: #0000ff;">flu</span> + +<span style="color: #0000ff;">sum</span> [foo +<span style="color: #0000ff;">bar]</span> barz {1 + [* <span style="color: #008b8b;">2</span> <span style="color: #008b8b;">2</span>]} + +<span style="color: #0000ff;">mara</span> { +<span style="color: #0000ff;">li</span> +<span style="color: #0000ff;">+</span> +<span style="color: #0000ff;">lo</span> - (<span style="color: #0000ff;">mabba</span>) +<span style="color: #0000ff;">}</span> +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-4" class="outline-2"> +<h2 id="sec-4"><span class="section-number-2">4</span> tests/syntax-strings-parens.scm</h2> +<div class="outline-text-2" id="text-4"> +<div class="org-src-container"> + +<pre class="src src-scheme"><span style="color: #b22222;">; </span><span style="color: #b22222;">Test linebreaks in strings and brackets</span> + +<span style="color: #8b2252;">"flubbub</span> + +<span style="color: #8b2252;">flabbab"</span> + +(hrug (nadda +madda gadda <span style="color: #8b2252;">"shoktom</span> +<span style="color: #8b2252;"> mee"</span> <span style="color: #8b2252;">" sep </span> +<span style="color: #8b2252;">ka"</span> + hadda) + (gom)) + +(flu) + +(sum [foo +bar] barz {1 + [* 2 2]}) + +(mara { +li ++ +lo - (mabba) +}) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-5" class="outline-2"> +<h2 id="sec-5"><span class="section-number-2">5</span> tests/syntax-indent.w</h2> +<div class="outline-text-2" id="text-5"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #483d8b;">define</span> +<span style="color: #0000ff;"> hello</span> who +<span style="color: #0000ff;"> format</span> <span style="color: #008b8b;">#t</span> <span style="color: #8b2252;">"Hello ~A\n"</span> who + +<span style="color: #483d8b;">define</span> + <span style="color: #483d8b;">let</span> +<span style="color: #a020f0;"> :</span> +<span style="color: #0000ff;"> a</span> <span style="color: #008b8b;">1</span> +<span style="color: #0000ff;"> b</span> <span style="color: #008b8b;">2</span> +<span style="color: #0000ff;"> c</span> <span style="color: #008b8b;">3</span> +<span style="color: #0000ff;"> format</span> <span style="color: #008b8b;">#t</span> <span style="color: #8b2252;">"a: ~A, b: ~A, c: ~A"</span> +<span style="color: #0000ff;"> +</span> a <span style="color: #008b8b;">2</span> +<span style="color: #a020f0;"> . </span> b c +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-6" class="outline-2"> +<h2 id="sec-6"><span class="section-number-2">6</span> tests/syntax-indent.scm</h2> +<div class="outline-text-2" id="text-6"> +<div class="org-src-container"> + +<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> + (hello who) + (format #t <span style="color: #8b2252;">"Hello ~A\n"</span> who)) + +(<span style="color: #a020f0;">define</span> + (<span style="color: #a020f0;">let</span> + ( + (a 1) + (b 2) + (c 3)) + (format #t <span style="color: #8b2252;">"a: ~A, b: ~A, c: ~A"</span> + (+ a 2) + b c))) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-7" class="outline-2"> +<h2 id="sec-7"><span class="section-number-2">7</span> tests/syntax-empty.w</h2> +<div class="outline-text-2" id="text-7"> +<div class="org-src-container"> + +<pre class="src src-wisp"></pre> +</div> +</div> +</div> +<div id="outline-container-sec-8" class="outline-2"> +<h2 id="sec-8"><span class="section-number-2">8</span> tests/syntax-empty.scm</h2> +<div class="outline-text-2" id="text-8"> +<div class="org-src-container"> + +<pre class="src src-scheme"></pre> +</div> +</div> +</div> +<div id="outline-container-sec-9" class="outline-2"> +<h2 id="sec-9"><span class="section-number-2">9</span> tests/syntax-dot.w</h2> +<div class="outline-text-2" id="text-9"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">foo</span> +<span style="color: #a020f0;"> . </span><span style="color: #8b2252;">"bar"</span> + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">bar</span> +<span style="color: #0000ff;"> '</span> <span style="color: #008b8b;">1</span> +<span style="color: #a020f0;"> . . </span><span style="color: #008b8b;">2</span> <span style="color: #b22222;">; </span><span style="color: #b22222;">pair</span> + +<span style="color: #0000ff;">display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">foo</span> +<span style="color: #0000ff;">newline</span> +<span style="color: #0000ff;">display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">bar</span> +<span style="color: #0000ff;">newline</span> +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-10" class="outline-2"> +<h2 id="sec-10"><span class="section-number-2">10</span> tests/syntax-dot.scm</h2> +<div class="outline-text-2" id="text-10"> +<div class="org-src-container"> + +<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">foo</span>) + <span style="color: #8b2252;">"bar"</span>) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">bar</span>) + '(1 + . 2 ))<span style="color: #b22222;">; </span><span style="color: #b22222;">pair</span> + +(display (foo)) +(newline) +(display (bar)) +(newline) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-11" class="outline-2"> +<h2 id="sec-11"><span class="section-number-2">11</span> tests/syntax-colon.w</h2> +<div class="outline-text-2" id="text-11"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #483d8b;">let</span> +<span style="color: #a020f0;"> :</span> +<span style="color: #0000ff;"> a</span> <span style="color: #008b8b;">1</span> +<span style="color: #0000ff;"> b</span> <span style="color: #008b8b;">2</span> + <span style="color: #483d8b;">let</span> +<span style="color: #a020f0;"> :</span> +<span style="color: #a020f0;"> :</span> +<span style="color: #a020f0;"> . </span>c <span style="color: #008b8b;">3</span> +<span style="color: #0000ff;"> format</span> <span style="color: #008b8b;">#t</span> <span style="color: #8b2252;">"a: ~A, b: ~A, c: ~A"</span> +<span style="color: #a020f0;"> . </span> a b c + +<span style="color: #a020f0;">: </span>a + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">hello</span> +<span style="color: #0000ff;"> display</span> <span style="color: #8b2252;">"hello\n"</span> + +<span style="color: #483d8b;">let</span> +<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">a</span> <span style="color: #008b8b;">1</span> +<span style="color: #0000ff;"> b</span> <span style="color: #008b8b;">2</span> +<span style="color: #0000ff;"> format</span> <span style="color: #008b8b;">#t</span> <span style="color: #8b2252;">"a: ~A, b: ~A"</span> +<span style="color: #a020f0;"> . </span> a b + +<span style="color: #483d8b;">let</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">:</span> a ' : + +<span style="color: #483d8b;">let</span> +<span style="color: #a020f0;"> : </span> <span style="color: #b22222;">; </span><span style="color: #b22222;">foo</span> +<span style="color: #0000ff;"> a</span> + ' + +<span style="color: #a020f0;">:</span> + a + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">\:</span> +<span style="color: #0000ff;"> hello</span> + +<span style="color: #0000ff;">\:</span> +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-12" class="outline-2"> +<h2 id="sec-12"><span class="section-number-2">12</span> tests/syntax-colon.scm</h2> +<div class="outline-text-2" id="text-12"> +<div class="org-src-container"> + +<pre class="src src-scheme">(<span style="color: #a020f0;">let</span> + ( + (a 1) + (b 2)) + (<span style="color: #a020f0;">let</span> + ( + ( + c 3)) + (format #t <span style="color: #8b2252;">"a: ~A, b: ~A, c: ~A"</span> + a b c))) + +((a)) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">hello</span>) + (display <span style="color: #8b2252;">"hello\n"</span>)) + +(<span style="color: #a020f0;">let</span> + ((a 1) + (b 2)) + (format #t <span style="color: #8b2252;">"a: ~A, b: ~A"</span> + a b)) + +(<span style="color: #a020f0;">let</span> ((a '()))) + +(<span style="color: #a020f0;">let</span> + ( <span style="color: #b22222;">; </span><span style="color: #b22222;">foo</span> + (a + '()))) + +( + (a)) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">:</span>) + (hello)) + +(:) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-13" class="outline-2"> +<h2 id="sec-13"><span class="section-number-2">13</span> tests/sublist.w</h2> +<div class="outline-text-2" id="text-13"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #b22222;">; </span><span style="color: #b22222;">sublists allow to start single line function calls with a colon ( : ).</span> + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">a</span> b c + <span style="color: #483d8b;">let</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">:</span> e<span style="color: #a020f0;"> . </span>f +<span style="color: #a020f0;"> . </span>g +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-14" class="outline-2"> +<h2 id="sec-14"><span class="section-number-2">14</span> tests/sublist.scm</h2> +<div class="outline-text-2" id="text-14"> +<div class="org-src-container"> + +<pre class="src src-scheme"><span style="color: #b22222;">; </span><span style="color: #b22222;">sublists allow to start single line function calls with a colon ( : ).</span> + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">a</span> b c) + (<span style="color: #a020f0;">let</span> ((e . f)) + g)) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-15" class="outline-2"> +<h2 id="sec-15"><span class="section-number-2">15</span> tests/hashbang.w</h2> +<div class="outline-text-2" id="text-15"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #b22222;">#!/usr/bin/wisp.py # !#</span> +<span style="color: #b22222;">; </span><span style="color: #b22222;">This tests hashbang lines</span> +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-16" class="outline-2"> +<h2 id="sec-16"><span class="section-number-2">16</span> tests/hashbang.scm</h2> +<div class="outline-text-2" id="text-16"> +<div class="org-src-container"> + +<pre class="src src-scheme">#!/usr/bin/wisp.py # !# +<span style="color: #b22222;">; </span><span style="color: #b22222;">This tests hashbang lines</span> +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-17" class="outline-2"> +<h2 id="sec-17"><span class="section-number-2">17</span> tests/readable-tests.w</h2> +<div class="outline-text-2" id="text-17"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">fibfast</span> n + <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;"><</span> n <span style="color: #008b8b;">2</span> +<span style="color: #a020f0;"> . </span>n +<span style="color: #0000ff;"> fibup</span> n <span style="color: #008b8b;">2</span> <span style="color: #008b8b;">1</span> <span style="color: #008b8b;">0</span> + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">fibup</span> maxnum count n-1 n-2 + <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">=</span> maxnum count +<span style="color: #0000ff;"> +</span> n-1 n-2 +<span style="color: #0000ff;"> fibup</span> maxnum +<span style="color: #0000ff;"> +</span> count <span style="color: #008b8b;">1</span> +<span style="color: #0000ff;"> +</span> n-1 n-2 +<span style="color: #a020f0;"> . </span>n-1 + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> n + <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;"><=</span> n <span style="color: #008b8b;">1</span> +<span style="color: #a020f0;"> . </span><span style="color: #008b8b;">1</span> +<span style="color: #0000ff;"> *</span> n +<span style="color: #0000ff;"> factorial</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">-</span> n <span style="color: #008b8b;">1</span> + +<span style="color: #483d8b;">define</span> (<span style="color: #0000ff;">gcd</span> x y) + <span style="color: #483d8b;">if</span> (<span style="color: #0000ff;">=</span> y <span style="color: #008b8b;">0</span>) +<span style="color: #a020f0;"> . </span>x +<span style="color: #0000ff;"> gcd</span> y +<span style="color: #0000ff;"> rem</span> x y + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">add-if-all-numbers</span> lst +<span style="color: #0000ff;"> call/cc</span> +<span style="color: #0000ff;"> lambda</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">exit</span> + <span style="color: #483d8b;">let</span> loop +<span style="color: #a020f0;"> : </span> +<span style="color: #0000ff;"> lst</span> lst +<span style="color: #0000ff;"> sum</span> <span style="color: #008b8b;">0</span> + <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">null?</span> lst +<span style="color: #a020f0;"> . </span>sum + <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #483d8b;">not</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">number?</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">car</span> lst +<span style="color: #0000ff;"> exit</span> <span style="color: #008b8b;">#f</span> +<span style="color: #0000ff;"> +</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">car</span> lst +<span style="color: #0000ff;"> loop</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">cdr</span> lst +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-18" class="outline-2"> +<h2 id="sec-18"><span class="section-number-2">18</span> tests/readable-tests.scm</h2> +<div class="outline-text-2" id="text-18"> +<div class="org-src-container"> + +<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">fibfast</span> n) + (<span style="color: #a020f0;">if</span> (< n 2)) + n + (fibup n 2 1 0 )) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">fibup</span> maxnum count n-1 n-2) + (<span style="color: #a020f0;">if</span> (= maxnum count) + (+ n-1 n-2) + (fibup maxnum + (+ count 1 ) + (+ n-1 n-2 ) + n-1))) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">factorial</span> n) + (<span style="color: #a020f0;">if</span> (<= n 1) + 1 + (* n + (factorial (- n 1))))) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">gcd</span> x y) + (<span style="color: #a020f0;">if</span> (= y 0)) + x + (gcd y + (rem x y))) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">add-if-all-numbers</span> lst) + (<span style="color: #a020f0;">call/cc</span> + (<span style="color: #a020f0;">lambda</span> (exit) + (<span style="color: #a020f0;">let</span> <span style="color: #0000ff;">loop</span> + ( + (lst lst ) + (sum 0)) + (<span style="color: #a020f0;">if</span> (null? lst) + sum + (<span style="color: #a020f0;">if</span> (not (number? (car lst))) + (exit #f) + (+ (car lst) + (loop (cdr lst))))))))) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-19" class="outline-2"> +<h2 id="sec-19"><span class="section-number-2">19</span> tests/quotecolon.w</h2> +<div class="outline-text-2" id="text-19"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #b22222;">#!/home/arne/wisp/wisp-multiline.sh </span> +<span style="color: #b22222;">; </span><span style="color: #b22222;">!#</span> +<span style="color: #483d8b;">define</span> a <span style="color: #008b8b;">1</span> <span style="color: #b22222;">; </span><span style="color: #b22222;">test whether ' : correctly gets turned into '(</span> +<span style="color: #b22222;">; </span><span style="color: #b22222;">and whether brackets in commments are treated correctly.</span> + +<span style="color: #483d8b;">define</span> a '<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">1</span> <span style="color: #008b8b;">2</span> <span style="color: #008b8b;">3</span> + +<span style="color: #483d8b;">define</span> +<span style="color: #0000ff;"> a</span> b +<span style="color: #0000ff;"> c</span> +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-20" class="outline-2"> +<h2 id="sec-20"><span class="section-number-2">20</span> tests/quotecolon.scm</h2> +<div class="outline-text-2" id="text-20"> +<div class="org-src-container"> + +<pre class="src src-scheme">#!/home/arne/wisp/wisp-multiline.sh +<span style="color: #b22222;">; </span><span style="color: #b22222;">!#</span> +(<span style="color: #a020f0;">define</span> <span style="color: #0000ff;">a</span> 1 )<span style="color: #b22222;">; </span><span style="color: #b22222;">test whether ' : correctly gets turned into '(</span> +<span style="color: #b22222;">; </span><span style="color: #b22222;">and whether brackets in commments are treated correctly.</span> + +(<span style="color: #a020f0;">define</span> <span style="color: #0000ff;">a</span> '(1 2 3)) + +(<span style="color: #a020f0;">define</span> + (a b) + (c)) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-21" class="outline-2"> +<h2 id="sec-21"><span class="section-number-2">21</span> tests/namedlet.w</h2> +<div class="outline-text-2" id="text-21"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #b22222;">#!/home/arne/wisp/wisp-multiline.sh </span> +<span style="color: #b22222;">; </span><span style="color: #b22222;">!#</span> +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">hello</span> who +<span style="color: #0000ff;"> display</span> who + +<span style="color: #483d8b;">let</span> hello +<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">who</span> <span style="color: #008b8b;">0</span> + <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">=</span> who <span style="color: #008b8b;">5</span> +<span style="color: #0000ff;"> display</span> who +<span style="color: #0000ff;"> hello</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">+</span> <span style="color: #008b8b;">1</span> who +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-22" class="outline-2"> +<h2 id="sec-22"><span class="section-number-2">22</span> tests/namedlet.scm</h2> +<div class="outline-text-2" id="text-22"> +<div class="org-src-container"> + +<pre class="src src-scheme">#!/home/arne/wisp/wisp-multiline.sh +<span style="color: #b22222;">; </span><span style="color: #b22222;">!#</span> +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">hello</span> who) + (display who)) + +(<span style="color: #a020f0;">let</span> <span style="color: #0000ff;">hello</span> + ((who 0)) + (<span style="color: #a020f0;">if</span> (= who 5) + (display who) + (hello (+ 1 who)))) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-23" class="outline-2"> +<h2 id="sec-23"><span class="section-number-2">23</span> tests/flexible-parameter-list.w</h2> +<div class="outline-text-2" id="text-23"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #b22222;">; </span><span style="color: #b22222;">Test using a . as first parameter on a line by prefixing it with a second .</span> +<span style="color: #483d8b;">define</span> +<span style="color: #0000ff;"> a</span> i +<span style="color: #a020f0;"> . . </span>b +<span style="color: #0000ff;"> unless</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">>=</span> i<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">length</span> b +<span style="color: #0000ff;"> display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">number->string</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">length</span> b +<span style="color: #0000ff;"> display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">list-ref</span> b i +<span style="color: #0000ff;"> newline</span> +<span style="color: #0000ff;"> apply</span> a ( <span style="color: #0000ff;">+</span> i <span style="color: #008b8b;">1</span> ) b + + +<span style="color: #0000ff;">a</span> <span style="color: #008b8b;">0</span> <span style="color: #8b2252;">"123"</span> <span style="color: #8b2252;">"345"</span> <span style="color: #8b2252;">"567"</span> +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-24" class="outline-2"> +<h2 id="sec-24"><span class="section-number-2">24</span> tests/flexible-parameter-list.scm</h2> +<div class="outline-text-2" id="text-24"> +<div class="org-src-container"> + +<pre class="src src-scheme"><span style="color: #b22222;">; </span><span style="color: #b22222;">Test using a . as first parameter on a line by prefixing it with a second .</span> +(<span style="color: #a020f0;">define</span> + (a i + . b) + (unless (>= i (length b)) + (display (number->string (length b ))) + (display (list-ref b i)) + (newline) + (apply a ( + i 1 ) b))) + + +(a 0 <span style="color: #8b2252;">"123"</span> <span style="color: #8b2252;">"345"</span> <span style="color: #8b2252;">"567"</span>) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-25" class="outline-2"> +<h2 id="sec-25"><span class="section-number-2">25</span> tests/factorial.w</h2> +<div class="outline-text-2" id="text-25"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #b22222;">;; </span><span style="color: #b22222;">short version</span> +<span style="color: #b22222;">; </span><span style="color: #b22222;">note: once you use one inline colon, all the following forms on that</span> +<span style="color: #b22222;">; </span><span style="color: #b22222;">line will get closed at the end of the line</span> + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> n + <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">zero?</span> n +<span style="color: #a020f0;"> . </span><span style="color: #008b8b;">1</span> +<span style="color: #0000ff;"> *</span> n<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">-</span> n <span style="color: #008b8b;">1</span> + +<span style="color: #0000ff;">display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> <span style="color: #008b8b;">5</span> + + +<span style="color: #b22222;">;; </span><span style="color: #b22222;">more vertical space, less colons</span> +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> n + <span style="color: #483d8b;">if</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">zero?</span> n +<span style="color: #a020f0;"> . </span><span style="color: #008b8b;">1</span> +<span style="color: #0000ff;"> *</span> n +<span style="color: #0000ff;"> factorial</span> +<span style="color: #0000ff;"> -</span> n <span style="color: #008b8b;">1</span> + +<span style="color: #0000ff;">display</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">factorial</span> <span style="color: #008b8b;">5</span> +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-26" class="outline-2"> +<h2 id="sec-26"><span class="section-number-2">26</span> tests/factorial.scm</h2> +<div class="outline-text-2" id="text-26"> +<div class="org-src-container"> + +<pre class="src src-scheme"><span style="color: #b22222;">;; </span><span style="color: #b22222;">short version</span> +<span style="color: #b22222;">; </span><span style="color: #b22222;">note: once you use one inline colon, all the following forms on that</span> +<span style="color: #b22222;">; </span><span style="color: #b22222;">line will get closed at the end of the line</span> + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">factorial</span> n) + (<span style="color: #a020f0;">if</span> (zero? n) + 1 + (* n (factorial (- n 1))))) + +(display (factorial 5 )) + + +<span style="color: #b22222;">;; </span><span style="color: #b22222;">more vertical space, less colons</span> +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">factorial</span> n) + (<span style="color: #a020f0;">if</span> (zero? n) + 1 + (* n + (factorial + (- n 1))))) + +(display (factorial 5 )) +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-27" class="outline-2"> +<h2 id="sec-27"><span class="section-number-2">27</span> tests/example.w</h2> +<div class="outline-text-2" id="text-27"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #483d8b;">define</span> (<span style="color: #0000ff;">a</span> b c) + <span style="color: #483d8b;">let</span> +<span style="color: #a020f0;"> : </span> +<span style="color: #0000ff;"> d</span> <span style="color: #8b2252;">"i am a string</span> +<span style="color: #8b2252;">do not break me!"</span> +<span style="color: #a020f0;"> : </span> + <span style="color: #b22222;">; </span><span style="color: #b22222;">comment: 0</span> + f +<span style="color: #b22222;">; </span><span style="color: #b22222;">comment : 1</span> +<span style="color: #0000ff;"> `</span> g <span style="color: #b22222;">; </span><span style="color: #b22222;">comment " : " 2</span> +<span style="color: #a020f0;"> : </span> +<span style="color: #0000ff;"> h</span> (<span style="color: #0000ff;">I</span> am in brackets: +<span style="color: #0000ff;"> do</span> <span style="color: #483d8b;">not</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">change</span> <span style="color: #8b2252;">"me"</span>) +<span style="color: #a020f0;"> . </span>i +<span style="color: #0000ff;"> ,</span><span style="color: #008b8b;"> 'j</span> k + +<span style="color: #a020f0;"> . </span>l + +<span style="color: #b22222;">; </span><span style="color: #b22222;">comment</span> + +<span style="color: #0000ff;"> a</span> c + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">b</span> :n o +<span style="color: #a020f0;"> . </span><span style="color: #8b2252;">"second defun : with a docstring!"</span> +<span style="color: #0000ff;"> message</span> <span style="color: #8b2252;">"I am here"</span> +<span style="color: #a020f0;"> . </span>t + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">c</span> e f +<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">g</span> +<span style="color: #a020f0;"> :</span> +<span style="color: #0000ff;"> h</span> +<span style="color: #0000ff;"> i</span> +<span style="color: #0000ff;"> j</span> +<span style="color: #0000ff;"> '</span> : +<span style="color: #0000ff;"> k</span> +<span style="color: #a020f0;"> . </span>l +<span style="color: #a020f0;"> . </span>: <span style="color: #0000ff;">m</span> + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">_</span> \: +<span style="color: #0000ff;">__</span> +<span style="color: #0000ff;">__</span><span style="color: #a020f0;"> . </span>\: + +<span style="color: #0000ff;">\_</span> b + +<span style="color: #483d8b;">define</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">d</span> + <span style="color: #483d8b;">let</span> +<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">a</span> b +<span style="color: #0000ff;"> c</span> d + +<span style="color: #0000ff;">a</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">:</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">c</span> + +<span style="color: #483d8b;">let</span> +<span style="color: #a020f0;"> : </span><span style="color: #0000ff;">a</span> b + c + +<span style="color: #483d8b;">let</span><span style="color: #a020f0;"> : </span><span style="color: #0000ff;">:</span> a b + +<span style="color: #a020f0;">. </span>a +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-28" class="outline-2"> +<h2 id="sec-28"><span class="section-number-2">28</span> tests/example.scm</h2> +<div class="outline-text-2" id="text-28"> +<div class="org-src-container"> + +<pre class="src src-scheme">(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">a</span> b c) + (<span style="color: #a020f0;">let</span> + ( + (d <span style="color: #8b2252;">"i am a string</span> +<span style="color: #8b2252;">do not break me!"</span>) + ( + <span style="color: #b22222;">; </span><span style="color: #b22222;">comment: 0</span> + (f) +<span style="color: #b22222;">; </span><span style="color: #b22222;">comment : 1</span> + `(g ))<span style="color: #b22222;">; </span><span style="color: #b22222;">comment " : " 2</span> + ( + (h (I am in brackets: + do not : change <span style="color: #8b2252;">"me"</span>)) + i))) + ,('j k) + + l + +<span style="color: #b22222;">; </span><span style="color: #b22222;">comment</span> + + (a c)) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">b</span> <span style="color: #483d8b;">:n</span> o) + <span style="color: #8b2252;">"second defun : with a docstring!"</span> + (message <span style="color: #8b2252;">"I am here"</span>) + t) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">c</span> e f) + ((g)) + ( + (h + (i)) + (j)) + '(()) + (k) + l + (m)) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">_</span> :) + + :) + +(_ b) + +(<span style="color: #a020f0;">define</span> (<span style="color: #0000ff;">d</span>) + (<span style="color: #a020f0;">let</span> + ((a b) + (c d)))) + +(a (((c)))) + +(<span style="color: #a020f0;">let</span> + ((a b) + (c))) + +(<span style="color: #a020f0;">let</span> ((a b))) + +a +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-29" class="outline-2"> +<h2 id="sec-29"><span class="section-number-2">29</span> tests/continuation.w</h2> +<div class="outline-text-2" id="text-29"> +<div class="org-src-container"> + +<pre class="src src-wisp"><span style="color: #0000ff;">a</span> b c d e +<span style="color: #a020f0;"> . </span>f g h +<span style="color: #a020f0;"> . </span>i j k + +<span style="color: #0000ff;">concat</span> <span style="color: #8b2252;">"I want "</span> +<span style="color: #0000ff;"> getwish</span> from me +<span style="color: #a020f0;"> . </span><span style="color: #8b2252;">" - "</span> username +</pre> +</div> +</div> +</div> +<div id="outline-container-sec-30" class="outline-2"> +<h2 id="sec-30"><span class="section-number-2">30</span> tests/continuation.scm</h2> +<div class="outline-text-2" id="text-30"> +<div class="org-src-container"> + +<pre class="src src-scheme">(a b c d e + f g h + i j k) + +(concat <span style="color: #8b2252;">"I want "</span> + (getwish from me) + <span style="color: #8b2252;">" - "</span> username) +</pre> +</div> +</div> +</div> +<div id="footnotes"> +<h2 class="footnotes">Footnotes: </h2> +<div id="text-footnotes"> + +<div class="footdef"><sup><a id="fn.1" name="fn.1" class="footnum" href="#fnr.1">1</a></sup> <p> +To run the tests in the wisp testsuite with a separately built GNU Guile, you can use any given guile interpreter by adjusting the following command: <code>PATH=~/guile-2.0.11/meta:${PATH} ./runtests.sh</code> +</p></div> + + +</div> +</div></div> +<div id="postamble" class="status"> +<p class="author">Author: Arne Babenhauserheide</p> +<p class="date">Created: 2014-12-23 Di 22:50</p> +<p class="creator"><a href="http://www.gnu.org/software/emacs/">Emacs</a> 24.3.1 (<a href="http://orgmode.org">Org</a> mode 8.2.6)</p> +<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p> +</div> +</body> +</html> diff --git a/wisp-scheme.w b/wisp-scheme.w --- a/wisp-scheme.w +++ b/wisp-scheme.w @@ -3,7 +3,7 @@ exec guile -L . --language=wisp -s "$0" ; !# ;; Scheme-only implementation of a wisp-preprocessor which output a -;; scheme Tree IL to feed to a scheme interpreter instead of a +;; scheme code tree to feed to a scheme interpreter instead of a ;; preprocessed file. ;; Plan: