- Calling eval on that code should work correctly as long as you have a
- running engine. This is the entry point for reporters, so it does
- extra checking to ensure that the reporter is actually in the REPORTER.
+; Let this grow, slowly but surely, eventually taking on calling context, etc.
+; For now, it's just a
+(defun transpile-commands (parsed-ast)
+ `(progn
+ ,@(transpile-commands-inner parsed-ast)))
+
+(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))))