'read' and 'read-string' are what you're looking for. They each read a
single Clojure object from an input source (PushbackReader for read,
String for read-string).

Alternatively, something like this can read all top-level forms from a
file:

(defn read-all
  "Reads all top-level forms from f, which will be coerced by
  clojure.java.io/reader into a suitable input source. Not lazy."
  [f]
  (with-open [pbr (java.io.PushbackReader. (clojure.java.io/reader
f))]
    (doall
     (take-while
      #(not= ::eof %)
      (repeatedly #(read pbr false ::eof))))))

(read-all "/some/clojure/file.clj")
=> ((foo :bar) (baz))

Justin

On May 9, 11:36 pm, Bill Robertson <billrobertso...@gmail.com> wrote:
> How do I actually manipulate it?  I have some complicated logic that I
> would like to transform into html (or maybe xml) for display
> purposes.
>
> I'm generating the Clojure code by parsing some nasty Java and
> outputting s-expressions.  The Java is basic, but quite deeply
> nested.  I want to generate working Clojure to demonstrate what that
> can do for us, and get this nastiness documented of course.
>
> Other than going into the source files and transforming it by hand
> into a series of defs and quoted lists e.g.  (def my_func '(+ 1 2))
> How do I actually just load code w/o evaluating it?
>
> I've found the pretty printer macros, seems like that might be useful
> if I wanted to statically transform the code.  I found the walker,
> that looks like it might be useful in actually generating the output
> (e.g. visit things, spit out (x|ht)ml.
>
> I looked at the various load functions in clojure.core.  With the
> exception of load (http://clojure.github.com/clojure/clojure.core-
> api.html#clojure.core/load) they all seem to load and evaluate.  Is
> load the answer or is it something I haven't found yet?
>
> Once I get the code loaded, I don't think I need anything out of the
> ordinary like macros or multi-methods.  I think I can just manipulate
> the lists.  Does that sound correct?
>
> I'm sorry if this are a stupid questions, but I've never done anything
> in Clojure of any significance, and any helpful answers you provide
> would could save me days of stumbling about.
>
> Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to