      :repl-sources list-of-source-names-required-on-repl-init
      :repl-actions list-of-repl-actions-and-the-input-that-created-them}))
 
+(defn repl-state? [x]
+  (and (map? x) (::repl-state x)))
+
 (defn setup [state]
   {:pre [(cljs/compiler-state? state)]}
   (let [cljs-user-requires

        (readers/input-stream-reader input-stream)

        {:keys [eof?] :as read-result}
        (read-one repl-state reader)]
    (if eof?
      state
      (process-read-result state read-result))))

            )))))

(defn read-one
  [repl-state reader {:keys [filename] :or {filename "repl-input.cljs"} :as opts}]
  {:pre [(repl-state? repl-state)]}
  (let [eof-sentinel
        (Object.)

        opts
        {:eof eof-sentinel
         :read-cond :allow
         :features #{:cljs}}

        in
        (readers/source-logging-push-back-reader
          reader ;; (PushbackReader. reader (object-array buf-len) buf-len buf-len)
          1
          filename)

        {:keys [ns ns-info] :as repl-rc}
        (:current repl-state)

        _ (assert (symbol? ns))

        form
        (binding [*ns*
                  (create-ns ns)

                  ana/*cljs-ns*
                  ns

                  ana/*cljs-file*
                  name

                  reader/*data-readers*
                  tags/*cljs-data-readers*

                  reader/*alias-map*
                  (merge reader/*alias-map*
                    (:requires ns-info)
                    (:require-macros ns-info))]

          (reader/read opts in))

        eof?
        (identical? form eof-sentinel)]

    (-> {:eof? eof?}
        (cond->
          (not eof?)
          (assoc :form form
                 :source
                 ;; FIXME: poking at the internals of SourceLoggingPushbackReader
                 ;; not using (-> form meta :source) which log-source provides
                 ;; since there are things that do not support IMeta, still want the source though
                 (-> @(.-source-log-frames in)
                     (:buffer)
                     (str)))))
    ))

(defn process-input
  "processes a string of forms, may read multiple forms"
