+(defun transpile-commands-inner (parsed-ast)
+ (cond
+ ((not parsed-ast) nil)
+ ((and (listp (car parsed-ast)) (eql :let (caar parsed-ast))) (list (handle-let parsed-ast)))
+ (t
+ (cons
+ (transpile-command (car parsed-ast))
+ (transpile-commands-inner (cdr parsed-ast))))))
+
+(defun handle-let (parsed-ast &optional vars)
+ (if
+ (and (listp (car parsed-ast)) (eql :let (caar parsed-ast)))
+ (let
+ ((*local-variables* (cons (second (car parsed-ast)) *local-variables*)))
+ (handle-let
+ (cdr parsed-ast)
+ (cons
+ (list
+ (transpile-reporter (second (car parsed-ast)))
+ (transpile-reporter (third (car parsed-ast))))
+ vars)))
+ `(let*
+ ,vars
+ ,@(transpile-commands-inner parsed-ast))))
+
+(defun transpile-command (command)
+ (cond
+ ((not (listp command)) (error "Expected a statement of some sort"))
+ ((not (find-prim (car command))) (error "Couldn't find the command for ~S" (car command)))
+ ((not (prim-command-p (find-prim (car command)))) (error "Expected command, got ~S" (car command)))
+ (t (apply (prim-func (find-prim (car command))) (mapcar #'transpile-reporter (cdr command))))))
+
+(defun transpile-reporter (reporter)