Start adding repeat form.

This commit is contained in:
Scott Richmond 2023-12-07 12:28:30 -05:00
parent 53c4433d2a
commit c88a06d447
3 changed files with 10 additions and 4 deletions

View File

@ -228,11 +228,13 @@
(defp loop-expr group order-1 [(quiet :loop) tuple (quiet :with)
(flat (choice :loop-body [fn-clause compound-loop]))])
(defp repeat-expr group order-1 [(quiet :repeat) (choice :word :number) block])
(defp collection flat choice [struct-literal dict list-literal set-literal tuple])
(defp simple flat choice [literal collection synthetic recur-call lambda])
(defp compound flat choice [match loop-expr if-expr when-expr do-expr block])
(defp compound flat choice [match loop-expr if-expr when-expr do-expr block repeat-expr])
(defp binding-expr flat choice [fn-named let-expr ref-expr])

View File

@ -674,6 +674,8 @@
(vswap! ctx update-ctx {name ref})
ref)))
(defn- interpret-repeat [ast ctx] :TODO)
(defn- interpret-loop [ast ctx]
(let [data (:data ast)
tuple (interpret-ast (first data) ctx)
@ -841,6 +843,8 @@
:loop-expr (interpret-loop ast ctx)
:repeat-expr (interpret-repeat ast ctx)
:block
(let [exprs (:data ast)
inner (pop exprs)

View File

@ -30,15 +30,15 @@
"when" :when ;; impl, replaces cond
;; actor model/concurrency
"receive" :receive
;"receive" :receive
;;"self" :self ;; maybe not necessary?: self() is a function
;;"send" :send ;; not necessary: send(pid, message) is a function
"spawn" :spawn
;"spawn" :spawn
;;"to" :to ;; not necessary if send is a function
;; type system
;; "data" :data ;; we are going to tear out datatypes for now: see if dynamism works for us
;; others
;;"repeat" :repeat ;; syntax sugar over "loop": still unclear what this syntax could be
"repeat" :repeat ;; syntax sugar over "loop": still unclear what this syntax could be
"test" :test
;; "module" :module ;; not necessary if we don't have datatypes
})