Welcome! Please see the About page for a little more info on how this works.

0 votes
in tools.reader by

I was wondering if there is a possibility to read arbitrary clojure code but sort of ignore the read-eval feature. So instead of throwing an error when *read-eval* is false, it just ignores it. Something along the lines of

(require '[clojure.tools.reader :as r])
(require '[clojure.tools.reader.reader-types :as t])
(binding [r/*ignore-read-eval* true]
  (r/read (t/source-logging-push-back-reader "#=(+ 3 4)")))
=> (read-eval (+ 3 4))

I am mainly interested in the column/line info of the metadata, so if this is out of scope for the library or there is a better way to this feel free to point me somewhere else. Also happy to do a pull request if that is wanted.

1 Answer

+1 vote
by

Doesn't sound like a good idea to me. There are some other Clojure parsers out there that might better suit your needs like https://github.com/borkdude/edamame.

...