mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 22:59:16 +02:00
checking for eof when reading a list
This commit is contained in:
parent
c163599685
commit
0ecb8ea665
1 changed files with 20 additions and 17 deletions
|
@ -203,23 +203,26 @@
|
||||||
(read-char in)
|
(read-char in)
|
||||||
(let lp ((res '()))
|
(let lp ((res '()))
|
||||||
(skip-whitespace in)
|
(skip-whitespace in)
|
||||||
(case (peek-char in)
|
(let ((c (peek-char in)))
|
||||||
((#\))
|
(case c
|
||||||
(read-char in)
|
((#\))
|
||||||
(reverse res))
|
(read-char in)
|
||||||
((#\.)
|
(reverse res))
|
||||||
(read-char in)
|
((#\.)
|
||||||
(cond
|
(read-char in)
|
||||||
((memv (peek-char in) delimiters)
|
(cond
|
||||||
(let ((tail (read-one)))
|
((memv (peek-char in) delimiters)
|
||||||
(skip-whitespace in)
|
(let ((tail (read-one)))
|
||||||
(if (eqv? #\) (peek-char in))
|
(skip-whitespace in)
|
||||||
(begin (read-char in) (append (reverse res) tail))
|
(if (eqv? #\) (peek-char in))
|
||||||
(error "expected end of list after dot"))))
|
(begin (read-char in) (append (reverse res) tail))
|
||||||
((char-numeric? (peek-char in)) (read-float-tail in))
|
(error "expected end of list after dot"))))
|
||||||
(else (string->symbol (read-name #\. in)))))
|
((char-numeric? (peek-char in)) (read-float-tail in))
|
||||||
(else
|
(else (string->symbol (read-name #\. in)))))
|
||||||
(lp (cons (read-one) res))))))
|
(else
|
||||||
|
(if (eof-object? c)
|
||||||
|
(error "unterminated list")
|
||||||
|
(lp (cons (read-one) res))))))))
|
||||||
((#\') (read-char in) (list 'quote (read-one)))
|
((#\') (read-char in) (list 'quote (read-one)))
|
||||||
((#\`) (read-char in) (list 'quasiquote (read-one)))
|
((#\`) (read-char in) (list 'quasiquote (read-one)))
|
||||||
((#\,)
|
((#\,)
|
||||||
|
|
Loading…
Add table
Reference in a new issue