diff --git a/module/mes/read-0.mes b/module/mes/read-0.mes index d1279cae..eebedd2b 100644 --- a/module/mes/read-0.mes +++ b/module/mes/read-0.mes @@ -133,30 +133,31 @@ (cons (quote cond) (cdr clauses)))))) (define (eat-whitespace) - (cond - ((eq? (peek-byte) 9) (read-byte) (eat-whitespace)) - ((eq? (peek-byte) 10) (read-byte) (eat-whitespace)) - ((eq? (peek-byte) 12) (read-byte) (eat-whitespace)) - ((eq? (peek-byte) 13) (read-byte) (eat-whitespace)) - ((eq? (peek-byte) 32) (read-byte) (eat-whitespace)) - ((eq? (peek-byte) 59) (begin (read-line-comment (read-byte)) - (eat-whitespace))) - ((eq? (peek-byte) 35) (begin (read-byte) - (cond ((eq? (peek-byte) 33) - (read-byte) - (read-block-comment 33 (read-byte)) - (eat-whitespace)) - ((eq? (peek-byte) 59) - (read-byte) - (read-word (read-byte) (list) (list)) - (eat-whitespace)) - ((eq? (peek-byte) 124) - (read-byte) - (read-block-comment 124 (read-byte)) - (eat-whitespace)) - (#t (unread-byte 35))) -)))) - + ((lambda (c) + (cond + ((eq? c 32) (read-byte) (eat-whitespace)) + ((eq? c 10) (read-byte) (eat-whitespace)) + ((eq? c 9) (read-byte) (eat-whitespace)) + ((eq? c 12) (read-byte) (eat-whitespace)) + ((eq? c 13) (read-byte) (eat-whitespace)) + ((eq? c 59) (begin (read-line-comment (read-byte)) + (eat-whitespace))) + ((eq? c 35) (begin (read-byte) + (cond ((eq? (peek-byte) 33) + (read-byte) + (read-block-comment 33 (read-byte)) + (eat-whitespace)) + ((eq? (peek-byte) 59) + (read-byte) + (read-word (read-byte) (list) (list)) + (eat-whitespace)) + ((eq? (peek-byte) 124) + (read-byte) + (read-block-comment 124 (read-byte)) + (eat-whitespace)) + (#t (unread-byte 35))))))) + (peek-byte))) + (define (read-block-comment s c) (if (eq? c s) (if (eq? (peek-byte) 35) (read-byte) (read-block-comment s (read-byte))) @@ -185,11 +186,11 @@ (define (read-word c w a) (cond - ((eq? c -1) (list)) - ((eq? c 10) (if (null? w) (read-word (read-byte) (list) a) + ((eq? c 32) (if (null? w) (read-word (read-byte) (list) a) (lookup w a))) - ((eq? c 12) (read-word 10 w a)) - ((eq? c 32) (read-word 10 w a)) + ((eq? c 10) (read-word 32 w a)) + ((eq? c 9) (read-word 32 w a)) + ((eq? c 12) (read-word 32 w a)) ((eq? c 34) (if (null? w) (read-string) (begin (unread-byte c) (lookup w a)))) ((eq? c 35) (cond @@ -238,6 +239,7 @@ (list)))))) ((eq? c 96) (cons (lookup-char c a) (cons (read-word (read-byte) w a) (list)))) ((eq? c 59) (read-line-comment c) (read-word 10 w a)) + ((eq? c -1) (list)) (#t (read-word (read-byte) (append2 w (cons (integer->char c) (list))) a)))) ((lambda (p) diff --git a/tests/read.test b/tests/read.test index c29e53d4..38c6e16d 100755 --- a/tests/read.test +++ b/tests/read.test @@ -46,6 +46,10 @@ barf burp |# #;(bla) (display "must see!\n") +(display + (lambda (x) + #;()#t) + ) (display #(0 1 2)) (newline) (display (list '(foo #! boo !# @@ -53,5 +57,4 @@ burp ) )) (newline) - ;; TODO: syntax, unsyntax, unsyntax-splicing