From 732605b576b40189613f98c10cb29f08d3d96c81 Mon Sep 17 00:00:00 2001 From: Raimon Grau Date: Wed, 12 Dec 2012 00:44:40 +0100 Subject: [PATCH] lambda (sort of) --- lispstrack.lisp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) 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* '()) -- 1.7.10.4