removed unused function and added detection for multiple objects following a dot...
authorAndrea Griffini <agriff@tin.it>
Sat, 4 May 2013 07:52:58 +0000 (09:52 +0200)
committerAndrea Griffini <agriff@tin.it>
Sat, 4 May 2013 07:52:58 +0000 (09:52 +0200)
src/read.lisp

index 4116bb6..0cfe563 100644 (file)
   (skip-whitespaces-and-comments stream)
   (let ((ch (%peek-char stream)))
     (cond
-      ((null ch)
-       (error "Unspected EOF"))
-      ((char= ch #\))
-       (discard-char stream #\))
-       nil)
-      (t
-       (let* ((eof (gensym))
-              (next (ls-read stream nil eof)))
-         (skip-whitespaces-and-comments stream)
-         (cond
-           ((eq next eof)
-            (discard-char stream #\)))
-           (t
-            (cons next
-                  (if (char= (%peek-char stream) #\.)
-                      (progn
-                        (discard-char stream #\.)
-                        (if (terminalp (%peek-char stream))
-                            (prog1 (ls-read stream) ; Dotted pair notation
-                              (discard-char stream #\)))
-                            (let ((token (concat "." (read-escaped-until stream #'terminalp))))
-                              (cons (interpret-token token)
-                                    (%read-list stream)))))
-                      (%read-list stream))))))))))
+     ((null ch)
+      (error "Unspected EOF"))
+     ((char= ch #\))
+      (discard-char stream #\))
+      nil)
+     (t
+      (let* ((eof (gensym))
+             (next (ls-read stream nil eof)))
+        (skip-whitespaces-and-comments stream)
+        (cond
+         ((eq next eof)
+          (discard-char stream #\)))
+         (t
+          (cons next
+                (if (char= (%peek-char stream) #\.)
+                    (progn
+                      (discard-char stream #\.)
+                      (if (terminalp (%peek-char stream))
+                          (prog1 (ls-read stream) ; Dotted pair notation
+                            (skip-whitespaces-and-comments stream)
+                            (if (char= (%peek-char stream) #\) )
+                                (discard-char stream #\))
+                                (error "More than one object follows . in list")))
+                          (let ((token (concat "." (read-escaped-until stream #'terminalp))))
+                            (cons (interpret-token token)
+                                  (%read-list stream)))))
+                    (%read-list stream))))))))))
 
 (defun read-string (stream)
   (let ((string "")
         (setq result (concat result (string (char x i))))))
     result))
 
-(defun escape-all (x)
-  (let ((result ""))
-    (dotimes (i (length x))
-      (setq result (concat result "\\"))
-      (setq result (concat result (string (char x i)))))
-    result))
-
 (defun string-upcase-noescaped (s)
   (let ((result "")
         (last-escape nil))