Compare commits
4 Commits
46817bd4e5
...
8375e19f1e
Author | SHA1 | Date | |
---|---|---|---|
8375e19f1e | |||
|
7a2c404daf | ||
|
7541d2499d | ||
|
a6d64ff827 |
|
@ -229,7 +229,7 @@
|
||||||
(defp loop-expr group order-1 [(quiet :loop) tuple (quiet :with)
|
(defp loop-expr group order-1 [(quiet :loop) tuple (quiet :with)
|
||||||
(flat (choice :loop-body [fn-clause compound-loop]))])
|
(flat (choice :loop-body [fn-clause compound-loop]))])
|
||||||
|
|
||||||
(defp repeat-expr group order-1 [(quiet :repeat) (choice :times [:word :number]) block])
|
(defp repeat-expr group order-1 [(quiet :repeat) (choice :times [:word :number]) non-binding])
|
||||||
|
|
||||||
(defp collection flat choice [;struct-literal
|
(defp collection flat choice [;struct-literal
|
||||||
dict list-literal set-literal tuple])
|
dict list-literal set-literal tuple])
|
||||||
|
|
|
@ -811,9 +811,9 @@
|
||||||
times (if (= :word (:type times-expr))
|
times (if (= :word (:type times-expr))
|
||||||
(resolve-word times-expr ctx)
|
(resolve-word times-expr ctx)
|
||||||
(-> times-expr :data first))
|
(-> times-expr :data first))
|
||||||
block (second data)]
|
expr (second data)]
|
||||||
(if (not (number? times)) (throw (ex-info (str "Repeat needs a number, not a " (base/get-type times)) {})))
|
(if (not (number? times)) (throw (ex-info (str "Repeat needs a number, not a " (base/get-type times)) {})))
|
||||||
(dotimes [_ times] (interpret-ast block ctx))))
|
(dotimes [_ times] (interpret-ast expr ctx))))
|
||||||
|
|
||||||
(defn- interpret-literal [ast] (-> ast :data first))
|
(defn- interpret-literal [ast] (-> ast :data first))
|
||||||
|
|
||||||
|
|
|
@ -60,8 +60,8 @@
|
||||||
|
|
||||||
(comment
|
(comment
|
||||||
(def source "
|
(def source "
|
||||||
|
let times = 4
|
||||||
:a (_)
|
repeat times print! (:foo)
|
||||||
|
|
||||||
")
|
")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user