Report unexpected errors in the reader
[jscl.git] / lispstrack.lisp
index 0cd2d69..46c07c6 100644 (file)
   (skip-whitespaces-and-comments stream)
   (let ((ch (%peek-char stream)))
     (cond
+      ((null ch)
+       (error "Unspected EOF"))
       ((char= ch #\))
        (%read-char stream)
        nil)
       ((char= ch #\.)
        (%read-char stream)
-       (skip-whitespaces-and-comments stream)
        (prog1 (ls-read stream)
+         (skip-whitespaces-and-comments stream)
          (unless (char= (%read-char stream) #\))
            (error "')' was expected."))))
       (t
   (let ((string "")
         (ch nil))
     (setq ch (%read-char stream))
-    (while (not (char= ch #\"))
-      (when (char= ch #\\)
+    (while (not (eql ch #\"))
+      (when (null ch)
+        (error "Unexpected EOF"))
+      (when (eql ch #\\)
         (setq ch (%read-char stream)))
       (setq string (concat string (string ch)))
       (setq ch (%read-char stream)))