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)
|
||||
(let lp ((res '()))
|
||||
(skip-whitespace in)
|
||||
(case (peek-char in)
|
||||
((#\))
|
||||
(read-char in)
|
||||
(reverse res))
|
||||
((#\.)
|
||||
(read-char in)
|
||||
(cond
|
||||
((memv (peek-char in) delimiters)
|
||||
(let ((tail (read-one)))
|
||||
(skip-whitespace in)
|
||||
(if (eqv? #\) (peek-char in))
|
||||
(begin (read-char in) (append (reverse res) tail))
|
||||
(error "expected end of list after dot"))))
|
||||
((char-numeric? (peek-char in)) (read-float-tail in))
|
||||
(else (string->symbol (read-name #\. in)))))
|
||||
(else
|
||||
(lp (cons (read-one) res))))))
|
||||
(let ((c (peek-char in)))
|
||||
(case c
|
||||
((#\))
|
||||
(read-char in)
|
||||
(reverse res))
|
||||
((#\.)
|
||||
(read-char in)
|
||||
(cond
|
||||
((memv (peek-char in) delimiters)
|
||||
(let ((tail (read-one)))
|
||||
(skip-whitespace in)
|
||||
(if (eqv? #\) (peek-char in))
|
||||
(begin (read-char in) (append (reverse res) tail))
|
||||
(error "expected end of list after dot"))))
|
||||
((char-numeric? (peek-char in)) (read-float-tail in))
|
||||
(else (string->symbol (read-name #\. in)))))
|
||||
(else
|
||||
(if (eof-object? c)
|
||||
(error "unterminated list")
|
||||
(lp (cons (read-one) res))))))))
|
||||
((#\') (read-char in) (list 'quote (read-one)))
|
||||
((#\`) (read-char in) (list 'quasiquote (read-one)))
|
||||
((#\,)
|
||||
|
|
Loading…
Add table
Reference in a new issue