Engelberg / instaparse

Eclipse Public License 1.0
2.74k stars 149 forks source link

specify transformation with multimethod #198

Open saitouena opened 4 years ago

saitouena commented 4 years ago

I don't like constructing a map for transform. I want to write like this.

(defmulti trans (fn [tag & _] tag))

(defmethod trans :a
  [tag & xs]
  ;; body
  )

(defmethod trans :b
  [tag & xs]
  ;; body
  )

(defmethod trans :default
  [tag & xs]
  ;; body
  )

(insta/transform' trans parsed)

Currently hiccup tag is not passed to transform function. I'm thinking about adding transform' and hiccup-transform' to transform.cljc. Any ideas?