improve (fix) read EOF error case
This commit is contained in:
parent
ca1f63c993
commit
057f106167
|
@ -34,9 +34,10 @@
|
||||||
(define-values (n-line n-col n-pos) (port-next-location port))
|
(define-values (n-line n-col n-pos) (port-next-location port))
|
||||||
(define (loop ch cur-balance-level ch-so-far)
|
(define (loop ch cur-balance-level ch-so-far)
|
||||||
(cond [(equal? eof ch)
|
(cond [(equal? eof ch)
|
||||||
(error 'string-reader
|
(raise-read-error
|
||||||
"unexpected eof, expected ~n more ~a characters"
|
(format "unexpected eof, expected ~a more closing delimiter ~a~n"
|
||||||
cur-balance-level r-paren)]
|
cur-balance-level r-paren)
|
||||||
|
src line col pos #f)]
|
||||||
[(equal? ch l-paren) (loop (read-char port)
|
[(equal? ch l-paren) (loop (read-char port)
|
||||||
(add1 cur-balance-level)
|
(add1 cur-balance-level)
|
||||||
(cons ch ch-so-far))]
|
(cons ch ch-so-far))]
|
||||||
|
@ -46,6 +47,7 @@
|
||||||
[(> cur-balance-level 1) (loop (read-char port)
|
[(> cur-balance-level 1) (loop (read-char port)
|
||||||
(sub1 cur-balance-level)
|
(sub1 cur-balance-level)
|
||||||
(cons ch ch-so-far))]
|
(cons ch ch-so-far))]
|
||||||
|
;; this shouldn't be possible... but I'll leave it here anyway.
|
||||||
[(< cur-balance-level 1)
|
[(< cur-balance-level 1)
|
||||||
((make-raise-balance-error l-paren r-paren)
|
((make-raise-balance-error l-paren r-paren)
|
||||||
src line col pos)]
|
src line col pos)]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user