guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] add language/wisp to Guile?


From: Dr. Arne Babenhauserheide
Subject: Re: [PATCH] add language/wisp to Guile?
Date: Thu, 16 Feb 2023 22:35:36 +0100
User-agent: mu4e 1.8.13; emacs 28.1

Maxime Devos <maximedevos@telenet.be> writes:
> On 16-02-2023 09:03, Dr. Arne Babenhauserheide wrote:
>> Do you mean using it similar to this test?
>>    (pass-if "R6RS/SRFI-30 block comment syntax overridden"
>>      ;; To be compatible with 1.8 and earlier, we should be able to override
>>      ;; this syntax.
>>      (with-fluids ((%read-hash-procedures (fluid-ref %read-hash-procedures)))
>>        (read-hash-extend #\| (lambda args 'not))
>>        (fold (lambda (x y result)
>>                (and result (eq? x y)))
>>              #t
>>              (read-string "(this is #| a comment)")
>>              `(this is not a comment))))
>
> That appears to me a valid (and slightly simpler and more robust) way
> of doing things, yes.

I finally got it working with passing tests — thank you!

The reason that it did not work was that in the wisp repo there are
tests that use wisp.scm directly without going through spec.scm.

From 12aa7314ad85f442f8bfe85839127bf1929be2ba Mon Sep 17 00:00:00 2001
From: Arne Babenhauserheide <arne_bab@web.de>
Date: Thu, 16 Feb 2023 22:34:00 +0100
Subject: [PATCH] Only extend the reader while reading wisp. Thanks to Maxime
 Devos!

* module/language/wisp/spec.scm (read-one-wisp-sexp): extend hash only in fluid
* module/language/wisp.scm (wisp-scheme-read-chunk): extend hash in fluid
---
 module/language/wisp.scm      | 18 ++++++++++--------
 module/language/wisp/spec.scm |  8 ++------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/module/language/wisp.scm b/module/language/wisp.scm
index 65ef8e65a..7a12e126a 100644
--- a/module/language/wisp.scm
+++ b/module/language/wisp.scm
@@ -725,14 +725,16 @@ Match is awesome!"
                  a))))))
 
 (define (wisp-scheme-read-chunk port)
-         "Read and parse one chunk of wisp-code"
-         (let (( lines (wisp-scheme-read-chunk-lines port)))
-              (wisp-make-improper
-                (wisp-replace-empty-eof
-                  (wisp-unescape-underscore-and-colon
-                    (wisp-replace-paren-quotation-repr
-                      (wisp-propagate-source-properties
-                        (wisp-scheme-indentation-to-parens lines))))))))
+    "Read and parse one chunk of wisp-code"
+    (with-fluids ((%read-hash-procedures (fluid-ref %read-hash-procedures)))
+      (read-hash-extend #\# (lambda args #\#))
+      (let ((lines (wisp-scheme-read-chunk-lines port)))
+           (wisp-make-improper
+             (wisp-replace-empty-eof
+               (wisp-unescape-underscore-and-colon
+                 (wisp-replace-paren-quotation-repr
+                   (wisp-propagate-source-properties
+                     (wisp-scheme-indentation-to-parens lines)))))))))
 
 (define (wisp-scheme-read-all port)
          "Read all chunks from the given port"
diff --git a/module/language/wisp/spec.scm b/module/language/wisp/spec.scm
index 3ba248aa9..477036c71 100644
--- a/module/language/wisp/spec.scm
+++ b/module/language/wisp/spec.scm
@@ -45,12 +45,8 @@
   ;; Don't use the globally-acting read-hash-extend, because this
   ;; doesn't make much sense in parenthese-y (non-Wisp) Scheme.
   ;; Instead, use fluids to temporarily add the extension.
-  (read-hash-extend #\# (λ (chr port) #\#))
-  (define %read-hash-procedures/parameter
-    (fluid->parameter %read-hash-procedures))
-  (parameterize ((%read-hash-procedures/parameter
-                   `((#\# ,(λ (chr port) #\#))
-                     ,@(%read-hash-procedures/parameter))))
+  (with-fluids ((%read-hash-procedures (fluid-ref %read-hash-procedures)))
+    (read-hash-extend #\# (lambda args #\# ))
     ;; Read Wisp files as UTF-8, to support non-ASCII characters.
     ;; TODO: would be nice to support ';; coding: whatever' lines
     ;; like in parenthese-y Scheme.
-- 
2.39.1

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein,
ohne es zu merken.
draketo.de

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]