Skip to content

Commit

Permalink
Add while
Browse files Browse the repository at this point in the history
  • Loading branch information
arohner committed Jun 7, 2010
1 parent e76ebfe commit 50472a6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/com/reasonr/scriptjure.clj
Expand Up @@ -68,7 +68,7 @@
(defmethod emit :default [expr]
(str expr))

(def special-forms (set ['var '. 'if 'funcall 'fn 'set! 'return 'delete 'new 'do 'aget 'for 'doseq 'str 'inc! 'dec!]))
(def special-forms (set ['var '. 'if 'funcall 'fn 'set! 'return 'delete 'new 'do 'aget 'for 'while 'doseq 'str 'inc! 'dec!]))

(def infix-operators (set ['+ '- '/ '* '% '== '=== '< '> '<= '>= '!= '<< '>> '<<< '>>> '!== '& '| '&& '||]))

Expand Down Expand Up @@ -138,9 +138,10 @@
(defmethod emit-special 'do [type [ do & exprs]]
(emit-do exprs))

(defmethod emit-special 'for [type [for [start test post] & body]]
(str "for (" (emit start) ";" (emit test) ";" (emit post) ") { \n"
(emit-do body)))
(defmethod emit-special 'while [type [while test & body]]
(str "while (" (emit test) ") { \n"
(emit-do body)
"\n }"))

(defmethod emit-special 'doseq [type [doseq bindings & body]]
(str "for (" (emit (first bindings)) " in " (second bindings) ") { \n"
Expand Down

0 comments on commit 50472a6

Please sign in to comment.