separator
(join (cdr list) separator)))))
-
;;; Compiler
(defvar *compilations* nil)
(define-compilation quote (sexp)
(lisp->js sexp))
+(define-compilation while (pred &rest body)
+ (format nil "(function(){while(~a){~{~a~}}})()"
+ (ls-compile pred env)
+ (mapcar (lambda (x) (ls-compile x env)) body)))
+
(defparameter *env* '())
(defparameter *env-fun* '())
;; funcall
)))))
-(defun ls-compile-block (sexps env)
+(defun ls-compile-sexps (sexps env)
(concat (join (mapcar (lambda (x)
(ls-compile x env))
- (butlast sexps))
+ sexps)
";
-")
+")))
+
+(defun ls-compile-block (sexps env)
+ (concat (ls-compile-sexps (butlast sexps env) env)
";
return " (ls-compile (car (last sexps)) env) ";"))