HomeAboutCodePastes
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordieggsy <dieggsy@protonmail.com>2019-10-29 13:46:02 -0400
committerdieggsy <dieggsy@protonmail.com>2019-10-29 13:46:02 -0400
commitd291ed96a76fb985cc9efb40da80034b18ce050e (patch)
treee57582b16080140e14a976b2c8defb7e35efdcc6
parent5dfee839cf57b6605cbbaa1d2e254d746a069bb9 (diff)
downloadsrfi-105-0.1.5.tar.gz
Rewrite curly expression reader more in accordance with reference0.1.5
-rw-r--r--srfi-105.release-info1
-rw-r--r--srfi-105.scm68
-rw-r--r--srfi-105.svnwiki1
3 files changed, 47 insertions, 23 deletions
diff --git a/srfi-105.release-info b/srfi-105.release-info
index c59c6ad..f5a66a6 100644
--- a/srfi-105.release-info
+++ b/srfi-105.release-info
@@ -3,4 +3,5 @@
(release "0.1.2")
(release "0.1.3")
(release "0.1.4")
+(release "0.1.5")
diff --git a/srfi-105.scm b/srfi-105.scm
index cd6311a..08bd4f6 100644
--- a/srfi-105.scm
+++ b/srfi-105.scm
@@ -7,7 +7,8 @@
chicken.irregex
chicken.string
chicken.condition
- srfi-13)
+ srfi-13
+ srfi-14)
(include "srfi-105-core.scm")
@@ -75,28 +76,49 @@
;; (substring str (add1 close-index)))))))))
;; str))
- (define (read-curly-string port)
- (let* ((stack 0)
- (str (read-token
- (lambda (c)
- (cond ((char=? c #\{)
- (set! stack (add1 stack))
- #t)
- ((and (char=? c #\})
- (> stack 0))
- (set! stack (sub1 stack))
- #t)
- ((char=? c #\})
- #f)))
- port)))
- (read-char port)
- str))
+ (define (read-curly port)
+ (let* ((stop-char #\})
+ (c (peek-char port)))
+ (cond
+ ((eof-object? c) (error "unterminated list"))
+ ((char-whitespace? c)
+ (read-token char-whitespace? port)
+ (read-curly port))
+ ((char=? c stop-char)
+ (read-char port)
+ '())
+ ((or (eq? c #\)) (eq? c #\]) (eq? c #\}))
+ (read-char port)
+ (error "list-terminator mismatch" c stop-char))
+ (#t
+ (let ((datum (read port)))
+ (cons datum (read-curly port)))))))
- (define (read-curly port #!optional (stop-char #\}))
- (let ((str ;; (replace-neoteric
- ;; (read-curly-string port))
- (read-curly-string port)
- ))
- (call-with-input-string str (cut read-list <>))))
+ ;; (define (read-curly-string port)
+ ;; (let* ((stack 0)
+ ;; (str (read-token
+ ;; (lambda (c)
+ ;; (cond ((char=? c #\{)
+ ;; (set! stack (add1 stack))
+ ;; #t)
+ ;; ((and (char=? c #\})
+ ;; (> stack 0))
+ ;; (set! stack (sub1 stack))
+ ;; #t)
+ ;; ((char=? c #\})
+ ;; #f)))
+ ;; port)))
+ ;; (read-char port)
+ ;; str)
+ ;; )
+
+ ;; (define (read-curly port #!optional (stop-char #\}))
+ ;; ;; (let ((str ;; (replace-neoteric
+ ;; ;; ;; (read-curly-string port))
+ ;; ;; (read-curly-string port)
+ ;; ;; ))
+ ;; ;; (call-with-input-string str (cut read-list <>)))
+ ;; (read-curly read #\} port)
+ ;; )
(set-read-syntax! #\{ (lambda (p) (process-curly (read-curly p)))))
diff --git a/srfi-105.svnwiki b/srfi-105.svnwiki
index 391878b..7780c12 100644
--- a/srfi-105.svnwiki
+++ b/srfi-105.svnwiki
@@ -194,6 +194,7 @@ SOFTWARE.
=== Version History
+; 0.1.5 : Rewrite curly expression reader more in accordance with reference
; 0.1.4 : Temporarily drop neoteric expression support
; 0.1.3 : Rename extras module to srfi-105.extra
; 0.1.2 : Use standard keyword syntax, properly check for (#:other) group