X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fread.lisp;h=3c352b33184e451b4470c6e81384ed69284914d4;hb=4989cbba70f7b820baef37d4f4f04e8546c5fd76;hp=05074a45dcd530f8725d8eeaa87a36476f55bb2f;hpb=93b2f887ce00e313dee9eccf3fb852f219361c72;p=jscl.git diff --git a/src/read.lisp b/src/read.lisp index 05074a4..3c352b3 100644 --- a/src/read.lisp +++ b/src/read.lisp @@ -118,7 +118,11 @@ (discard-char stream #\.) (if (terminalp (%peek-char stream)) (prog1 (ls-read stream) ; Dotted pair notation - (discard-char stream #\))) + (skip-whitespaces-and-comments stream) + (let ((ch (%peek-char stream))) + (if (or (null ch) (char= #\) ch)) + (discard-char stream #\)) + (error "Multiple objects following . in a list")))) (let ((token (concat "." (read-escaped-until stream #'terminalp)))) (cons (interpret-token token) (%read-list stream))))) @@ -144,7 +148,7 @@ (list 'function (ls-read stream))) (#\( (list-to-vector (%read-list stream))) (#\: (make-symbol - (unescape + (unescape-token (string-upcase-noescaped (read-escaped-until stream #'terminalp))))) (#\\ @@ -166,22 +170,18 @@ (ls-read stream) (ls-read stream eof-error-p eof-value)) (:jscl + (ls-read stream eof-error-p eof-value)) + (:nil + (ls-read stream) (ls-read stream eof-error-p eof-value))))))) -(defun unescape (x) +(defun unescape-token (x) (let ((result "")) (dotimes (i (length x)) (unless (char= (char x i) #\\) (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)) @@ -227,7 +227,7 @@ (setq name (subseq string index)))) ;; Canonalize symbol name and package (setq name (if (equal package "JS") - (setq name (unescape name)) + (setq name (unescape-token name)) (setq name (string-upcase-noescaped name)))) (setq package (find-package package)) (if (or internalp @@ -304,8 +304,7 @@ ;; Optional exponent part (when (< index size) ;; Exponent-marker - (unless (member (string-upcase (string (char string index))) - '("E" "S" "F" "D" "L")) + (unless (find (char-upcase (char string index)) "ESFDL") (return)) (incf index) (unless (< index size) (return)) @@ -325,7 +324,7 @@ (unless (= index size) (return)) ;; Everything went ok, we have a float ;; XXX: Use FLOAT when implemented. - (/ (* sign (expt 10.0 (* exponent-sign exponent)) number) divisor)))) + (/ (* sign (expt 10.0 (* exponent-sign exponent)) number) divisor 1.0)))) (defun !parse-integer (string junk-allow) (block nil