(defn parse-if
[[_ test then else :as form] env]
(let [formc (count form)]
(when-not (or (= formc 3) (= formc 4))
(throw (ex-info (str "Wrong number of args to if, had: " (dec (count form)))
(merge {:form form}
(-source-info form env))))))
(let [test-expr (analyze-form test (ctx env :ctx/expr))
then-expr (analyze-form then env)
else-expr (analyze-form else env)]
{:op :if
:form form
:env env
:test test-expr
:then then-expr
:else else-expr
:children [:test :then :else]}))