Skip to content

Commit 868daed

Browse files
committed
Treats # as a delimited in R6RS mode when reading numbers (fixes #687)
1 parent beca0d1 commit 868daed

File tree

3 files changed

+27
-16
lines changed

3 files changed

+27
-16
lines changed

mats/6.ms

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
;;; 6.ms
22
;;; Copyright 1984-2017 Cisco Systems, Inc.
3-
;;;
3+
;;;
44
;;; Licensed under the Apache License, Version 2.0 (the "License");
55
;;; you may not use this file except in compliance with the License.
66
;;; You may obtain a copy of the License at
7-
;;;
7+
;;;
88
;;; http://www.apache.org/licenses/LICENSE-2.0
9-
;;;
9+
;;;
1010
;;; Unless required by applicable law or agreed to in writing, software
1111
;;; distributed under the License is distributed on an "AS IS" BASIS,
1212
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -78,7 +78,7 @@
7878
; and write-char---and builds testfile.ss for the next test
7979
(equal? (call-with-values
8080
(lambda ()
81-
(with-output-to-file "testfile.ss"
81+
(with-output-to-file "testfile.ss"
8282
(lambda ()
8383
(for-each (lambda (c) (write-char c))
8484
(string->list "a b c d e"))
@@ -103,7 +103,7 @@
103103
; and write-char---and builds testfile.ss for the next test
104104
(equal? (call-with-values
105105
(lambda ()
106-
(call-with-output-file "testfile.ss"
106+
(call-with-output-file "testfile.ss"
107107
(lambda (p)
108108
(for-each (lambda (c) (write-char c p))
109109
(string->list "a b c d e"))
@@ -1016,7 +1016,7 @@
10161016
(error? (fasl-write 'any (let-values ([(o get) (open-bytevector-output-port)]) o) 10))
10171017
(error? (fasl-read (open-bytevector-input-port #vu8()) 'load #f))
10181018
(error? (fasl-read (open-bytevector-input-port #vu8()) 'load 10))
1019-
1019+
10201020
(let-values ([(o get) (open-bytevector-output-port)])
10211021
(fasl-write '(apple (banana cream pie) (vector coconut banana cream)) o (lambda (v)
10221022
(or (eq? v 'banana)
@@ -1719,6 +1719,11 @@
17191719
(equal? (format "~s" "\bab\nc\f\rd\t\v\a") "\"\\bab\\nc\\f\\rd\\t\\v\\a\"")
17201720
)
17211721
1722+
(mat r6rs
1723+
(equal? '(3 #f) (let ([ip (open-input-string "#!r6rs 3#f")])
1724+
(let* ([x (read ip)] [y (read ip)])
1725+
(list x y)))))
1726+
17221727
(mat read-token
17231728
(let ([ip (open-input-string "(cons 33 #;hello \"rot\")")])
17241729
(and (let-values ([vals (read-token ip)])
@@ -2816,12 +2821,12 @@
28162821
(load "fatfib.ss" compile))
28172822
(procedure? fatfib))
28182823
(equal? ((inspect/object fatfib) 'type) 'procedure)
2819-
(equal?
2824+
(equal?
28202825
(call-with-values
28212826
(lambda () (((inspect/object fatfib) 'code) 'source-path))
28222827
list)
28232828
(list (format "../examples~afatfib.ss" (directory-separator)) 16 4))
2824-
(equal?
2829+
(equal?
28252830
(parameterize ([source-directories '("." "../examples")])
28262831
(call-with-values
28272832
(lambda () (((inspect/object fatfib) 'code) 'source-path))

mats/root-experr-compile-0-f-f-f

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4881,7 +4881,7 @@ cp0.mo:Expected error in mat expand/optimize-output: "expand/optimize-output: #<
48814881
6.mo:Expected error in mat read-test: "read: |...| symbol escape syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
48824882
6.mo:Expected error in mat read-test: "read: @abc symbol syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
48834883
6.mo:Expected error in mat read-test: "read: 123a symbol syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
4884-
6.mo:Expected error in mat read-test: "read: 123# number syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
4884+
6.mo:Expected error in mat read-test: "read: invalid sharp-sign prefix #
48854885
6.mo:Expected error in mat read-test: "read: 1/2e2 number syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
48864886
6.mo:Expected error in mat read-test: "read: #x.3 number syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
48874887
6.mo:Expected error in mat read-test: "read: alternative boolean syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
@@ -5710,7 +5710,7 @@ cp0.mo:Expected error in mat expand/optimize-output: "expand/optimize-output: #<
57105710
6.mo:Expected error in mat load-test: "read: |...| symbol escape syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
57115711
6.mo:Expected error in mat load-test: "read: @abc symbol syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
57125712
6.mo:Expected error in mat load-test: "read: 123a symbol syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
5713-
6.mo:Expected error in mat load-test: "read: 123# number syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
5713+
6.mo:Expected error in mat load-test: "read: invalid sharp-sign prefix #
57145714
6.mo:Expected error in mat load-test: "read: 1/2e2 number syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
57155715
6.mo:Expected error in mat load-test: "read: #x.3 number syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
57165716
6.mo:Expected error in mat load-test: "read: alternative boolean syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
@@ -6539,7 +6539,7 @@ cp0.mo:Expected error in mat expand/optimize-output: "expand/optimize-output: #<
65396539
6.mo:Expected error in mat compile-test: "read: |...| symbol escape syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
65406540
6.mo:Expected error in mat compile-test: "read: @abc symbol syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
65416541
6.mo:Expected error in mat compile-test: "read: 123a symbol syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
6542-
6.mo:Expected error in mat compile-test: "read: 123# number syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
6542+
6.mo:Expected error in mat compile-test: "read: invalid sharp-sign prefix #
65436543
6.mo:Expected error in mat compile-test: "read: 1/2e2 number syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
65446544
6.mo:Expected error in mat compile-test: "read: #x.3 number syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".
65456545
6.mo:Expected error in mat compile-test: "read: alternative boolean syntax is not allowed in #!r6rs mode at line 3, char 8 of testfile.ss".

s/read.ss

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
;;; read.ss
22
;;; Copyright 1984-2017 Cisco Systems, Inc.
3-
;;;
3+
;;;
44
;;; Licensed under the Apache License, Version 2.0 (the "License");
55
;;; you may not use this file except in compliance with the License.
66
;;; You may obtain a copy of the License at
7-
;;;
7+
;;;
88
;;; http://www.apache.org/licenses/LICENSE-2.0
9-
;;;
9+
;;;
1010
;;; Unless required by applicable law or agreed to in writing, software
1111
;;; distributed under the License is distributed on an "AS IS" BASIS,
1212
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -932,13 +932,19 @@
932932
(state-case c
933933
[eof (with-unread-char c
934934
(state-return atomic (xcall rd-make-number-or-symbol i)))]
935-
[((#\0 - #\9) (#\a - #\z) #\- #\+ #\. #\/ #\@ #\# #\|)
935+
[((#\0 - #\9) (#\a - #\z) #\- #\+ #\. #\/ #\@ #\|)
936936
(with-stretch-buffer i c
937937
(*state rd-token-number-or-symbol (fx+ i 1)))]
938938
[((#\A - #\Z))
939939
(with-stretch-buffer i c
940940
(*state rd-token-number-or-symbol (fx+ i 1)))]
941-
[(#\space #\( #\) #\[ #\] #\" #\; #\#)
941+
[(#\#)
942+
(if ($port-flags-set? (rcb-ip rcb) (constant port-flag-r6rs))
943+
(with-unread-char c
944+
(state-return atomic (xcall rd-make-number-or-symbol i)))
945+
(with-stretch-buffer i c
946+
(*state rd-token-number-or-symbol (fx+ i 1))))]
947+
[(#\space #\( #\) #\[ #\] #\" #\;)
942948
(with-unread-char c
943949
(state-return atomic (xcall rd-make-number-or-symbol i)))]
944950
[char-whitespace?

0 commit comments

Comments
 (0)