X-Git-Url: https://code.consxy.com/gitweb/gitweb.cgi?p=clnl;a=blobdiff_plain;f=src%2Fmain%2Ftranspile.lisp;h=a45183b921ee018f9b65263548aafaf5256a83c2;hp=9b4b5ee4f499d44d179f78a46954eb2f04817f22;hb=399b297b01fe363c6ea8c2108de5df82c2ba3921;hpb=d546c89b00227003c843793bdb32324fad60b260 diff --git a/src/main/transpile.lisp b/src/main/transpile.lisp index 9b4b5ee..a45183b 100644 --- a/src/main/transpile.lisp +++ b/src/main/transpile.lisp @@ -10,9 +10,10 @@ (defun is-command (prim) (eql :command (getf prim :type))) (defun find-prim (symb) - (or - (find symb *prims* :key #'prim-name) - (find-prim (getf (find symb *prim-aliases* :key #'prim-name) :real-symb)))) + (when symb + (or + (find symb *prims* :key #'prim-name) + (find-prim (getf (find symb *prim-aliases* :key #'prim-name) :real-symb))))) ; Let this grow, slowly but surely, eventually taking on calling context, etc. ; For now, it's just a @@ -82,6 +83,9 @@ DESCRIPTION: (defmacro defsimpleprim (name type simple-func) `(defprim ,name ,type (lambda (&rest args) `(,',simple-func ,@args)))) +(defmacro defkeywordprim (name) + `(defprim ,name :reporter (lambda () ',name))) + (defmacro defprim-alias (name real-symb) `(push (list :name ,name :real-symb ,real-symb) *prim-aliases*)) @@ -108,7 +112,16 @@ DESCRIPTION: (defprim-alias :if-else :ifelse) (defsimpleprim :lt :command clnl-nvm:turn-left) +(defkeywordprim :nobody) (defsimpleprim :random-float :reporter clnl-nvm:random-float) (defsimpleprim :rt :command clnl-nvm:turn-right) (defsimpleprim :show :command clnl-nvm:show) (defsimpleprim :turtles :reporter clnl-nvm:turtles) + +; Colors +(defmacro defcolorprim (color) `(defprim ,color :reporter (lambda () `(clnl-nvm:lookup-color ,,color)))) +(defcolorprim :black) +(defcolorprim :blue) +(defcolorprim :brown) +(defcolorprim :green) +(defcolorprim :white)