projects
/
clnl
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prims - Implement colors, nobody
[clnl]
/
src
/
main
/
transpile.lisp
diff --git
a/src/main/transpile.lisp
b/src/main/transpile.lisp
index 9b4b5ee4f499d44d179f78a46954eb2f04817f22..a45183b921ee018f9b65263548aafaf5256a83c2 100644
(file)
--- 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)
(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
; 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 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*))
(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)
(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)
(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)