:arg-countdown (when arg-countdown (1- arg-countdown))))
((eql (intern "(" (find-package :keyword)) (car lexed-ast)) (parse-parened-expr (cdr lexed-ast) arg-countdown))
((eql (intern ")" (find-package :keyword)) (car lexed-ast)) (error "Closing parens has no opening parens"))
+ ((eql :let (car lexed-ast)) (parse-let (cdr lexed-ast) arg-countdown))
((eql :[ (car lexed-ast)) (parse-block (cdr lexed-ast) arg-countdown))
(prim
(when (prim-structure-prim prim)
(parse-prim prim lexed-ast nil arg-countdown))
(t (error "Couldn't parse ~S" lexed-ast))))))))
+(defun parse-let (lexed-ast arg-countdown)
+ (when (not (keywordp (car lexed-ast))) (error "Needed a keyword for let"))
+ (let*
+ ((half-parsed-remainder (parse-internal (cdr lexed-ast) :arg-countdown 1)))
+ (let
+ ((*dynamic-prims* (cons (list :name (car lexed-ast)) *dynamic-prims*)))
+ (parse-internal
+ (cdr half-parsed-remainder)
+ :arg-countdown (when arg-countdown (1- arg-countdown))
+ :prev-item (list :let (car lexed-ast) (car half-parsed-remainder))))))
+
(defun parse-prim (prim lexed-ast prev-item arg-countdown)
(let*
((num-args (- (prim-num-args prim) (if (prim-is-infix prim) 1 0)))
(defprim :with (:reporter-block))
(defprim :fd (:number))
(defprim :hatch (:number :command-block))
-(defprim :let (t t))
+; (defprim :let (t t)) ; keeping this here, commented out, to note that it has special processing
(defprim :if (:boolean :command-block))
(defprim :if-else (:boolean :command-block :command-block))
(defprim :ifelse (:boolean :command-block :command-block))
(defprim :display-labels ())
; Generated by a let
-(defprim :prey ())
+;(defprim :prey ())
; Generated by breeds
(defprim :sheep ())