3 ;;; simplify me, please
4 (defun concat (&rest strs)
5 (reduce (lambda (s1 s2) (concatenate 'string s1 s2))
11 (defvar *compilations* nil)
13 (defmacro define-compilation (name args &body body)
14 `(push (list ',name (lambda (env ,@args) ,@body))
17 (define-compilation if (condition true false)
18 (format nil "((~a)? (~a) : (~a))"
19 (ls-compile condition env)
21 (ls-compile false env)))
23 (define-compilation lambda (args &rest body)
25 (format nil "~{V_~a~^, ~}" args)
27 (ls-compile-block body env)
31 (defparameter *env* '())
32 (defparameter *env-fun* '())
34 (defun ls-compile (sexp &optional env)
36 ((symbolp sexp) (format nil "V_~a" sexp))
37 ((integerp sexp) (format nil " ~a " sexp))
38 ((stringp sexp) (format nil " \"~a\" " sexp))
41 (let ((compiler-func (second (assoc (car sexp) *compilations*))))
43 (apply compiler-func env (cdr sexp))
47 (defun ls-compile-block (sexps env)
49 "~{~#[~; return ~a;~:;~a;~%~]~}"