+(define-compilation cdr (x)
+ (concat "(" (ls-compile x env fenv) ").cdr"))
+
+(defmacro with-eval-when-compilation (&body body)
+ `(setq *eval-when-compilations*
+ (concat *eval-when-compilations* (progn ,@body))))
+
+(defun %compile-defvar (name)
+ (push (make-var-binding name) *env*)
+ (with-eval-when-compilation
+ (format nil "var ~a" (lookup-variable name *env*))))
+
+(defun %compile-defun (name)
+ (push (make-func-binding name) *fenv*)
+ (with-eval-when-compilation
+ (format nil "var ~a" (lookup-variable name *fenv*))))
+
+(defun %compile-defmacro (name lambda)
+ (push (cons name (cons 'macro lambda)) *fenv*))
+
+(defun compile-funcall (name args env fenv)
+ (format nil "~a(~{~a~^, ~})"
+ (lookup-function name fenv)
+ (mapcar (lambda (x) (ls-compile x env fenv)) args)))
+
+(defun ls-macroexpand-1 (form &optional env fenv)
+ (let ((function (cdr (assoc (car form) *fenv*))))
+ (if (and (listp function) (eq (car function) 'macro))
+ (apply (eval (cdr function)) (cdr form))
+ form)))
+
+(defun ls-compile (sexp &optional env fenv)