From: Raimon Grau Date: Tue, 11 Dec 2012 23:44:40 +0000 (+0100) Subject: lambda (sort of) X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=732605b576b40189613f98c10cb29f08d3d96c81;p=jscl.git lambda (sort of) --- diff --git a/lispstrack.lisp b/lispstrack.lisp index aba12cb..a0fb23b 100644 --- a/lispstrack.lisp +++ b/lispstrack.lisp @@ -1,6 +1,6 @@ -(defun ls-compile (sexp) +(defun ls-compile (sexp &optional env) (cond - ((symbolp sexp) nil) + ((symbolp sexp) (format nil "V_~a" sexp)) ((integerp sexp) (format nil " ~a " sexp)) ((stringp sexp) (format nil " \"~a\" " sexp)) ; list @@ -9,8 +9,28 @@ (ls-compile (second sexp)) (ls-compile (third sexp)) (ls-compile (fourth sexp)))) - (lambda nil) + (lambda (concat "(function (" + (format nil "~{V_~a~^, ~}" (second sexp)) + "){ " + (ls-compile-block (cddr sexp) env) + "}) +")) ; (function (params) { body }) (t nil))))) -(defparameter *env-var* '()) +;;; simplify me, please +(defun concat (&rest strs) + (reduce (lambda (s1 s2) (concatenate 'string s1 s2)) + strs + :initial-value "")) + +(defun ls-compile-block (sexps env) + (format nil + "~{~#[~; return ~a;~:;~a;~%~]~}" + (mapcar #'(lambda (x) + (ls-compile x env)) + sexps))) + +(defparameter *env* '()) + + (defparameter *env-fun* '())