X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=lispstrack.lisp;h=46c07c63d8fb3c586c8db0fe794e349587846346;hb=4f17b56fa136f97d11975d081a861351eb64db76;hp=3b76ca44e09dc514a62ebeabff24e6ea3e1d4cb8;hpb=303e467bad4e9f81e33fd5199356caeeae94191d;p=jscl.git diff --git a/lispstrack.lisp b/lispstrack.lisp index 3b76ca4..46c07c6 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -120,13 +120,15 @@ (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 @@ -136,8 +138,10 @@ (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))) @@ -425,8 +429,8 @@ (define-transformation let (bindings &rest body) (let ((bindings (mapcar #'ensure-list bindings))) - `((lambda ,(mapcar 'car bindings) ,@body) - ,@(mapcar 'cadr bindings)))) + `((lambda ,(mapcar #'car bindings) ,@body) + ,@(mapcar #'cadr bindings)))) ;;; A little backquote implementation without optimizations of any ;;; kind for lispstrack. @@ -500,7 +504,7 @@ (compile-bool (concat "(" (ls-compile x env fenv) "===" (ls-compile nil env fenv) ")"))) (define-compilation cons (x y) - (concat "{car: " (ls-compile x env fenv) ", cdr: " (ls-compile y env fenv) "}")) + (concat "({car: " (ls-compile x env fenv) ", cdr: " (ls-compile y env fenv) "})")) (define-compilation consp (x) (compile-bool @@ -604,8 +608,7 @@ "})()" *newline*)))) (define-compilation js-eval (string) - (concat "eval(" (ls-compile string env fenv) ")")) - + (concat "eval.apply(window, [" (ls-compile string env fenv) "])")) (define-compilation error (string) (concat "(function (){ throw " (ls-compile string env fenv) ";" "return 0;})()"))