mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-11 23:17:34 +02:00
Fixing srfi-38 parsing non-decimal numbers followed by EOF or containing the #\f digit.
Added related tests.
This commit is contained in:
parent
edb73cf250
commit
0d5ac322fd
2 changed files with 15 additions and 7 deletions
|
@ -145,15 +145,18 @@
|
|||
(let ((in (if (pair? o) (car o) (current-input-port)))
|
||||
(shared '()))
|
||||
(define (read-label res)
|
||||
(let ((c (char-downcase (peek-char in))))
|
||||
(if (if (char-numeric? c) #t (memv c '(#\a #\b #\c #\d #\e)))
|
||||
(read-label (cons (read-char in) res))
|
||||
(list->string (reverse res)))))
|
||||
(let ((c (peek-char in)))
|
||||
(if (and (not (eof-object? c))
|
||||
(or (char-numeric? c)
|
||||
(memv (char-downcase c) '(#\a #\b #\c #\d #\e #\f))))
|
||||
(read-label (cons (read-char in) res))
|
||||
(list->string (reverse res)))))
|
||||
(define (read-number base)
|
||||
(let* ((str (read-label '()))
|
||||
(n (string->number str base)))
|
||||
(if (or (not n) (not (memv (peek-char in) delimiters)))
|
||||
(error "read error: invalid number syntax" str (peek-char in))
|
||||
(n (string->number str base))
|
||||
(c (peek-char in)))
|
||||
(if (or (not n) (not (or (eof-object? c) (memv c delimiters))))
|
||||
(error "read error: invalid number syntax" str c)
|
||||
n)))
|
||||
(define (read-float-tail in) ;; called only after a leading period
|
||||
(let lp ((res 0.0) (k 0.1))
|
||||
|
|
|
@ -59,6 +59,11 @@
|
|||
(vector-set! x 2 x)
|
||||
x))
|
||||
|
||||
(test 255 (read-from-string "#xff"))
|
||||
(test 99 (read-from-string "#d99"))
|
||||
(test 63 (read-from-string "#o77"))
|
||||
(test 3 (read-from-string "#b11"))
|
||||
|
||||
(cond-expand
|
||||
(chicken
|
||||
(test-io "(#0=\"abc\" #0# #0#)"
|
||||
|
|
Loading…
Add table
Reference in a new issue