noprompt / meander

Tools for transparent data transformation
MIT License
921 stars 55 forks source link

Add interpreter namespace #128

Closed noprompt closed 3 years ago

noprompt commented 4 years ago

This patch creates a new namespace which exposes a basic API for constructing a search interpreter, a function. The role of this function is to accept some value target and optionally a map bindings which maps variables and other special runtime objects to values.

(require '[meander.epsilon :as m])
(require '[meander.interpreter.epsilon :as m.interpreter])

(let [search-fn (m.interpreter/make-search-fn '(m/re #"a(bc)" (m/scan ?x)))]
  (search-fn "abc"))
;; =>
({?x "abc"} {?x "bc"})