Code reformat - Macro for functions implement commands to return :undefined
[clnl] / src / main / main.lisp
index 0997963960d63dff7d1b8d51ec73ea96b118ed2d..a226642c8e702b63cbabb49321e7108aed1cd6af 100644 (file)
@@ -24,11 +24,12 @@ ARGUMENTS AND VALUES:
 DESCRIPTION:
 
   RUN starts up the CLNL system."
-
  (boot)
  (sb-thread:make-thread #'clnl-cli:run)
  (clnl-interface:run))
 
+(defvar *callback* nil)
+
 (defun boot (&optional file headless-mode)
  "BOOT &optional FILE HEADLESS-MODE => RESULT
 
@@ -51,7 +52,8 @@ DESCRIPTION:
   ((netlogoed-lisp
     (model->single-form-lisp
      (if file (with-open-file (str file) (clnl-model:read-from-nlogo str)) (clnl-model:default-model))
-     :initialize-interface (not headless-mode)))
+     :initialize-interface (not headless-mode)
+     :netlogo-callback (lambda (f) (setf *callback* f))))
    (*package* *model-package*))
   (eval netlogoed-lisp)))
 
@@ -67,7 +69,8 @@ DESCRIPTION:
 
   RUN-COMMANDS will take NetLogo commands, put them through the various
   stages need to turn them into Common Lisp code, and run it."
- (clnl-nvm:with-stop-handler (eval (clnl-transpiler:transpile (clnl-parser:parse (clnl-lexer:lex cmds))))))
+ (clnl-nvm:with-stop-handler
+  (funcall *callback* cmds)))
 
 (defun run-reporter (reporter)
  "RUN-REPORTER REPORTER => RESULT
@@ -123,7 +126,8 @@ DESCRIPTION:
           (if (getf prim :macro) ; The reason we do this is because with macros, we want to evaluate them in
                                  ; this scope while preserving them for the generational purposes below
            (append (list :macro (eval (getf prim :macro))) prim)
-           prim)) prims))))))
+           prim)) prims)))
+    :undefined)))
 
 (defun model->single-form-lisp (model &key (seed 15) initialize-interface netlogo-callback)
  (multiple-value-bind