initial commit
This commit is contained in:
Executable
+965
@@ -0,0 +1,965 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns ^{:doc "A clojure reader in clojure"
|
||||
:author "Bronsa"}
|
||||
cljs.tools.reader
|
||||
(:refer-clojure :exclude [read read-line read-string char read+string
|
||||
default-data-readers *default-data-reader-fn*
|
||||
*data-readers* *suppress-read*])
|
||||
(:require-macros [cljs.tools.reader.reader-types :refer [log-source]])
|
||||
(:require [cljs.tools.reader.reader-types :refer
|
||||
[read-char unread peek-char indexing-reader?
|
||||
get-line-number get-column-number get-file-name
|
||||
string-push-back-reader]]
|
||||
[cljs.tools.reader.impl.utils :refer
|
||||
[char ex-info? whitespace? numeric? desugar-meta next-id namespace-keys second'
|
||||
ReaderConditional reader-conditional reader-conditional? char-code]]
|
||||
[cljs.tools.reader.impl.commons :refer
|
||||
[number-literal? read-past match-number parse-symbol read-comment throwing-reader]]
|
||||
[cljs.tools.reader.impl.errors :as err]
|
||||
[goog.array :as garray]
|
||||
[goog.string :as gstring])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare ^:private read*
|
||||
macros dispatch-macros
|
||||
^:dynamic *data-readers*
|
||||
^:dynamic *default-data-reader-fn*
|
||||
^:dynamic *suppress-read*
|
||||
default-data-readers)
|
||||
|
||||
(defn- ^boolean macro-terminating? [ch]
|
||||
(case ch
|
||||
(\" \; \@ \^ \` \~ \( \) \[ \] \{ \} \\) true
|
||||
false))
|
||||
|
||||
(def sb (StringBuffer.))
|
||||
|
||||
(defn- read-token
|
||||
"Read in a single logical token from the reader"
|
||||
[^not-native rdr kind initch]
|
||||
(if (nil? initch)
|
||||
(err/throw-eof-at-start rdr kind)
|
||||
(do
|
||||
(.clear sb)
|
||||
(loop [ch initch]
|
||||
(if (or (whitespace? ch)
|
||||
(macro-terminating? ch)
|
||||
(nil? ch))
|
||||
(do
|
||||
(when-not (nil? ch)
|
||||
(unread rdr ch))
|
||||
(.toString sb))
|
||||
(do
|
||||
(.append sb ch)
|
||||
(recur (read-char rdr))))))))
|
||||
|
||||
(declare read-tagged)
|
||||
|
||||
(defn- read-dispatch
|
||||
[^not-native rdr _ opts pending-forms]
|
||||
(if-let [ch (read-char rdr)]
|
||||
(if-let [dm (dispatch-macros ch)]
|
||||
(dm rdr ch opts pending-forms)
|
||||
(read-tagged (doto rdr (unread ch)) ch opts pending-forms)) ;; ctor reader is implemented as a tagged literal
|
||||
(err/throw-eof-at-dispatch rdr)))
|
||||
|
||||
(defn- read-unmatched-delimiter
|
||||
[rdr ch opts pending-forms]
|
||||
(err/throw-unmatch-delimiter rdr ch))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read-regex
|
||||
[^not-native rdr ch opts pending-forms]
|
||||
(let [sb (StringBuffer.)]
|
||||
(loop [ch (read-char rdr)]
|
||||
(if (identical? \" ch)
|
||||
(re-pattern (str sb))
|
||||
(if (nil? ch)
|
||||
(err/throw-eof-reading rdr :regex sb)
|
||||
(do
|
||||
(.append sb ch )
|
||||
(when (identical? \\ ch)
|
||||
(let [ch (read-char rdr)]
|
||||
(if (nil? ch)
|
||||
(err/throw-eof-reading rdr :regex sb))
|
||||
(.append sb ch)))
|
||||
(recur (read-char rdr))))))))
|
||||
|
||||
(defn- read-unicode-char
|
||||
([token offset length base]
|
||||
(let [l (+ offset length)]
|
||||
(when-not (== (count token) l)
|
||||
(err/throw-invalid-unicode-literal nil token))
|
||||
(loop [i offset uc 0]
|
||||
(if (== i l)
|
||||
(js/String.fromCharCode uc)
|
||||
(let [d (char-code (nth token i) base)]
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit-in-token nil (nth token i) token)
|
||||
(recur (inc i) (+ d (* uc base)))))))))
|
||||
|
||||
([^not-native rdr initch base length exact?]
|
||||
(loop [i 1 uc (char-code initch base)]
|
||||
(if (== uc -1)
|
||||
(err/throw-invalid-unicode-digit rdr initch)
|
||||
(if-not (== i length)
|
||||
(let [ch (peek-char rdr)]
|
||||
(if (or (whitespace? ch)
|
||||
(macros ch)
|
||||
(nil? ch))
|
||||
(if exact?
|
||||
(err/throw-invalid-unicode-len rdr i length)
|
||||
(js/String.fromCharCode uc))
|
||||
(let [d (char-code ch base)]
|
||||
(read-char rdr)
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit rdr ch)
|
||||
(recur (inc i) (+ d (* uc base)))))))
|
||||
(js/String.fromCharCode uc))))))
|
||||
|
||||
(def ^:private ^:const upper-limit (.charCodeAt \uD7ff 0))
|
||||
(def ^:private ^:const lower-limit (.charCodeAt \uE000 0))
|
||||
|
||||
(defn- valid-octal? [token base]
|
||||
(<= (js/parseInt token base) 0377))
|
||||
|
||||
(defn- read-char*
|
||||
"Read in a character literal"
|
||||
[^not-native rdr backslash opts pending-forms]
|
||||
(let [ch (read-char rdr)]
|
||||
(if-not (nil? ch)
|
||||
(let [token (if (or (macro-terminating? ch)
|
||||
(whitespace? ch))
|
||||
(str ch)
|
||||
(read-token rdr :character ch))
|
||||
token-len (. token -length)]
|
||||
(cond
|
||||
|
||||
(== 1 token-len) (.charAt token 0) ;;; no char type - so can't ensure/cache char
|
||||
|
||||
(= token "newline") \newline
|
||||
(= token "space") \space
|
||||
(= token "tab") \tab
|
||||
(= token "backspace") \backspace
|
||||
(= token "formfeed") \formfeed
|
||||
(= token "return") \return
|
||||
|
||||
(gstring/startsWith token "u")
|
||||
(let [c (read-unicode-char token 1 4 16)
|
||||
ic (.charCodeAt c 0)]
|
||||
(if (and (> ic upper-limit)
|
||||
(< ic lower-limit))
|
||||
(err/throw-invalid-character-literal rdr (.toString ic 16))
|
||||
c))
|
||||
|
||||
(gstring/startsWith token "o")
|
||||
(let [len (dec token-len)]
|
||||
(if (> len 3)
|
||||
(err/throw-invalid-octal-len rdr token)
|
||||
(let [offset 1
|
||||
base 8
|
||||
uc (read-unicode-char token offset len base)]
|
||||
(if-not (valid-octal? (subs token offset) base)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
uc))))
|
||||
|
||||
:else (err/throw-unsupported-character rdr token)))
|
||||
(err/throw-eof-in-character rdr))))
|
||||
|
||||
(defn- starting-line-col-info [^not-native rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
[(get-line-number rdr) (int (dec (get-column-number rdr)))]))
|
||||
|
||||
(defn- ending-line-col-info [^not-native rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
[(get-line-number rdr) (get-column-number rdr)]))
|
||||
|
||||
(defonce ^:private READ_EOF (js/Object.))
|
||||
(defonce ^:private READ_FINISHED (js/Object.))
|
||||
|
||||
(def ^:dynamic *read-delim* false)
|
||||
|
||||
(defn- read-delimited-internal [kind delim rdr opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
delim (char delim)]
|
||||
(loop [a (transient [])]
|
||||
(let [form (read* rdr false READ_EOF delim opts pending-forms)]
|
||||
(if (identical? form READ_FINISHED)
|
||||
(persistent! a)
|
||||
(if (identical? form READ_EOF)
|
||||
(err/throw-eof-delimited rdr kind start-line start-column (count a))
|
||||
(recur (conj! a form))))))))
|
||||
|
||||
(defn- read-delimited
|
||||
"Reads and returns a collection ended with delim"
|
||||
[kind delim rdr opts pending-forms]
|
||||
(binding [*read-delim* true]
|
||||
(read-delimited-internal kind delim rdr opts pending-forms)))
|
||||
|
||||
(defn- read-list
|
||||
"Read in a list, including its location if the reader is an indexing reader"
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-list (read-delimited :list \) rdr opts pending-forms)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(with-meta (if (empty? the-list)
|
||||
'()
|
||||
(apply list the-list))
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-vector
|
||||
"Read in a vector, including its location if the reader is an indexing reader"
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-vector (read-delimited :vector \] rdr opts pending-forms)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(with-meta the-vector
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-map
|
||||
"Read in a map, including its location if the reader is an indexing reader"
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-map (read-delimited :map \} rdr opts pending-forms)
|
||||
map-count (count the-map)
|
||||
ks (take-nth 2 the-map)
|
||||
key-set (set ks)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(when (odd? map-count)
|
||||
(err/throw-odd-map rdr start-line start-column the-map))
|
||||
(when-not (= (count key-set) (count ks))
|
||||
(err/throw-dup-keys rdr :map ks))
|
||||
(with-meta
|
||||
(if (<= map-count (* 2 (.-HASHMAP-THRESHOLD cljs.core/PersistentArrayMap)))
|
||||
(.fromArray cljs.core/PersistentArrayMap (to-array the-map) true true)
|
||||
(.fromArray cljs.core/PersistentHashMap (to-array the-map) true))
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-number
|
||||
[^not-native rdr initch]
|
||||
(loop [sb (doto (StringBuffer.) (.append initch))
|
||||
ch (read-char rdr)]
|
||||
(if (or (whitespace? ch) (macros ch) (nil? ch))
|
||||
(let [s (str sb)]
|
||||
(unread rdr ch)
|
||||
(or (match-number s)
|
||||
(err/throw-invalid-number rdr s)))
|
||||
(recur (doto sb (.append ch)) (read-char rdr)))))
|
||||
|
||||
(defn- escape-char [sb ^not-native rdr]
|
||||
(let [ch (read-char rdr)]
|
||||
(case ch
|
||||
\t "\t"
|
||||
\r "\r"
|
||||
\n "\n"
|
||||
\\ "\\"
|
||||
\" "\""
|
||||
\b "\b"
|
||||
\f "\f"
|
||||
\u (let [ch (read-char rdr)]
|
||||
(if (== -1 (js/parseInt (int ch) 16))
|
||||
(err/throw-invalid-unicode-escape rdr ch)
|
||||
(read-unicode-char rdr ch 16 4 true)))
|
||||
(if (numeric? ch)
|
||||
(let [ch (read-unicode-char rdr ch 8 3 false)]
|
||||
(if (> (int ch) 0377)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
ch))
|
||||
(err/throw-bad-escape-char rdr ch)))))
|
||||
|
||||
(defn- read-string*
|
||||
[^not-native reader _ opts pending-forms]
|
||||
(loop [sb (StringBuffer.)
|
||||
ch (read-char reader)]
|
||||
(if (nil? ch)
|
||||
(err/throw-eof-reading reader :string \" sb)
|
||||
(case ch
|
||||
\\ (recur (doto sb (.append (escape-char sb reader)))
|
||||
(read-char reader))
|
||||
\" (str sb)
|
||||
(recur (doto sb (.append ch)) (read-char reader))))))
|
||||
|
||||
(defn- loc-info [rdr line column]
|
||||
(when-not (nil? line)
|
||||
(let [file (get-file-name rdr)
|
||||
filem (when-not (nil? file) {:file file})
|
||||
[end-line end-column] (ending-line-col-info rdr)
|
||||
lcm {:line line
|
||||
:column column
|
||||
:end-line end-line
|
||||
:end-column end-column}]
|
||||
(merge filem lcm))))
|
||||
|
||||
(defn- read-symbol
|
||||
[rdr initch]
|
||||
(let [[line column] (starting-line-col-info rdr)
|
||||
token (read-token rdr :symbol initch)]
|
||||
(when-not (nil? token)
|
||||
(case token
|
||||
|
||||
;; special symbols
|
||||
"nil" nil
|
||||
"true" true
|
||||
"false" false
|
||||
"/" '/
|
||||
|
||||
(let [^not-native p (parse-symbol token)]
|
||||
(if-not (nil? p)
|
||||
(let [^not-native sym (symbol (-nth p 0) (-nth p 1))]
|
||||
(-with-meta sym (loc-info rdr line column)))
|
||||
(err/throw-invalid rdr :symbol token)))))))
|
||||
|
||||
(def ^:dynamic *alias-map*
|
||||
"Map from ns alias to ns, if non-nil, it will be used to resolve read-time
|
||||
ns aliases.
|
||||
|
||||
Defaults to nil"
|
||||
nil)
|
||||
|
||||
(defn- resolve-alias [sym]
|
||||
(get *alias-map* sym))
|
||||
|
||||
(defn- resolve-ns [sym]
|
||||
(or (resolve-alias sym)
|
||||
(when-let [ns (find-ns sym)]
|
||||
(symbol (ns-name ns)))))
|
||||
|
||||
(defn- read-keyword
|
||||
[^not-native reader initch opts pending-forms]
|
||||
(let [ch (read-char reader)]
|
||||
(if-not (whitespace? ch)
|
||||
(let [token (read-token reader :keyword ch)
|
||||
^not-native s (parse-symbol token)]
|
||||
(if-not (nil? s)
|
||||
(let [ns (-nth s 0)
|
||||
name (-nth s 1)]
|
||||
(if (identical? \: (.charAt token 0))
|
||||
(if-not (nil? ns)
|
||||
(if-let [ns (resolve-alias (symbol (subs ns 1)))]
|
||||
(keyword (str ns) name)
|
||||
(err/throw-invalid reader :keyword (str \: token)))
|
||||
(if-let [ns *ns*]
|
||||
(keyword (str ns) (subs name 1))
|
||||
(err/reader-error reader "Invalid token: :" token)))
|
||||
(keyword ns name)))
|
||||
(err/throw-invalid reader :keyword (str \: token))))
|
||||
(err/throw-single-colon reader))))
|
||||
|
||||
(defn- wrapping-reader
|
||||
"Returns a function which wraps a reader in a call to sym"
|
||||
[sym]
|
||||
(fn [rdr _ opts pending-forms]
|
||||
(list sym (read* rdr true nil opts pending-forms))))
|
||||
|
||||
(defn- read-meta
|
||||
"Read metadata and return the following object with the metadata applied"
|
||||
[rdr _ opts pending-forms]
|
||||
(log-source rdr
|
||||
(let [[line column] (starting-line-col-info rdr)
|
||||
m (desugar-meta (read* rdr true nil opts pending-forms))]
|
||||
(when-not (map? m)
|
||||
(err/throw-bad-metadata rdr m))
|
||||
(let [o (read* rdr true nil opts pending-forms)]
|
||||
(if (implements? IMeta o)
|
||||
(let [m (if (and line (seq? o))
|
||||
(assoc m :line line :column column)
|
||||
m)]
|
||||
(if (implements? IWithMeta o)
|
||||
(with-meta o (merge (meta o) m))
|
||||
(reset-meta! o m)))
|
||||
(err/throw-bad-metadata-target rdr o))))))
|
||||
|
||||
(defn- read-set
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
;; subtract 1 from start-column so it includes the # in the leading #{
|
||||
start-column (if start-column (int (dec start-column)))
|
||||
coll (read-delimited :set \} rdr opts pending-forms)
|
||||
the-set (set coll)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(when-not (= (count coll) (count the-set))
|
||||
(err/reader-error rdr (err/throw-dup-keys rdr :set coll)))
|
||||
(with-meta the-set
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
|
||||
(defn- read-discard
|
||||
"Read and discard the first object from rdr"
|
||||
[rdr _ opts pending-forms]
|
||||
(doto rdr
|
||||
(read* true nil opts pending-forms)))
|
||||
|
||||
(defn- read-symbolic-value
|
||||
[rdr _ opts pending-forms]
|
||||
(let [sym (read* rdr true nil opts pending-forms)]
|
||||
(case sym
|
||||
|
||||
NaN js/Number.NaN
|
||||
-Inf js/Number.NEGATIVE_INFINITY
|
||||
Inf js/Number.POSITIVE_INFINITY
|
||||
|
||||
(err/reader-error rdr (str "Invalid token: ##" sym)))))
|
||||
|
||||
(def ^:private RESERVED_FEATURES #{:else :none})
|
||||
|
||||
(defn- has-feature?
|
||||
[rdr feature opts]
|
||||
(if (keyword? feature)
|
||||
(or (= :default feature) (contains? (get opts :features) feature))
|
||||
(err/reader-error rdr "Feature should be a keyword: " feature)))
|
||||
|
||||
(defn- check-eof-error
|
||||
[form rdr first-line]
|
||||
(when (identical? form READ_EOF)
|
||||
(err/throw-eof-error rdr (and (< first-line 0) first-line))))
|
||||
|
||||
(defn- check-reserved-features
|
||||
[rdr form]
|
||||
(when (get RESERVED_FEATURES form)
|
||||
(err/reader-error rdr "Feature name " form " is reserved")))
|
||||
|
||||
(defn- check-invalid-read-cond
|
||||
[form rdr first-line]
|
||||
(when (identical? form READ_FINISHED)
|
||||
(if (< first-line 0)
|
||||
(err/reader-error rdr "read-cond requires an even number of forms")
|
||||
(err/reader-error rdr "read-cond starting on line " first-line " requires an even number of forms"))))
|
||||
|
||||
(defn- read-suppress
|
||||
"Read next form and suppress. Return nil or READ_FINISHED."
|
||||
[first-line rdr opts pending-forms]
|
||||
(binding [*suppress-read* true]
|
||||
(let [form (read* rdr false READ_EOF \) opts pending-forms)]
|
||||
(check-eof-error form rdr first-line)
|
||||
(when (identical? form READ_FINISHED)
|
||||
READ_FINISHED))))
|
||||
|
||||
(defonce ^:private NO_MATCH (js/Object.))
|
||||
|
||||
(defn- match-feature
|
||||
"Read next feature. If matched, read next form and return.
|
||||
Otherwise, read and skip next form, returning READ_FINISHED or nil."
|
||||
[first-line rdr opts pending-forms]
|
||||
(let [feature (read* rdr false READ_EOF \) opts pending-forms)]
|
||||
(check-eof-error feature rdr first-line)
|
||||
(if (= feature READ_FINISHED)
|
||||
READ_FINISHED
|
||||
(do
|
||||
(check-reserved-features rdr feature)
|
||||
(if (has-feature? rdr feature opts)
|
||||
;; feature matched, read selected form
|
||||
(doto (read* rdr false READ_EOF \) opts pending-forms)
|
||||
(check-eof-error rdr first-line)
|
||||
(check-invalid-read-cond rdr first-line))
|
||||
;; feature not matched, ignore next form
|
||||
(or (read-suppress first-line rdr opts pending-forms)
|
||||
NO_MATCH))))))
|
||||
|
||||
(defn- read-cond-delimited
|
||||
[rdr splicing opts pending-forms]
|
||||
(let [first-line (if (indexing-reader? rdr) (get-line-number rdr) -1)
|
||||
result (loop [matched NO_MATCH
|
||||
finished nil]
|
||||
(cond
|
||||
;; still looking for match, read feature+form
|
||||
(identical? matched NO_MATCH)
|
||||
(let [match (match-feature first-line rdr opts pending-forms)]
|
||||
(if (identical? match READ_FINISHED)
|
||||
READ_FINISHED
|
||||
(recur match nil)))
|
||||
|
||||
;; found match, just read and ignore the rest
|
||||
(not (identical? finished READ_FINISHED))
|
||||
(recur matched (read-suppress first-line rdr opts pending-forms))
|
||||
|
||||
:else
|
||||
matched))]
|
||||
(if (identical? result READ_FINISHED)
|
||||
rdr
|
||||
(if splicing
|
||||
(do
|
||||
(if (implements? ISequential result)
|
||||
(do
|
||||
(garray/insertArrayAt pending-forms (to-array result) 0)
|
||||
rdr)
|
||||
(err/reader-error rdr "Spliced form list in read-cond-splicing must implement ISequential")))
|
||||
result))))
|
||||
|
||||
(defn- read-cond
|
||||
[^not-native rdr _ opts pending-forms]
|
||||
(when (not (and opts (#{:allow :preserve} (:read-cond opts))))
|
||||
(throw (ex-info "Conditional read not allowed"
|
||||
{:type :runtime-exception})))
|
||||
(if-let [ch (read-char rdr)]
|
||||
(let [splicing (= ch \@)
|
||||
ch (if splicing (read-char rdr) ch)]
|
||||
(when splicing
|
||||
(when-not *read-delim*
|
||||
(err/reader-error rdr "cond-splice not in list")))
|
||||
(if-let [ch (if (whitespace? ch) (read-past whitespace? rdr) ch)]
|
||||
(if (not= ch \()
|
||||
(throw (ex-info "read-cond body must be a list"
|
||||
{:type :runtime-exception}))
|
||||
(binding [*suppress-read* (or *suppress-read* (= :preserve (:read-cond opts)))]
|
||||
(if *suppress-read*
|
||||
(reader-conditional (read-list rdr ch opts pending-forms) splicing)
|
||||
(read-cond-delimited rdr splicing opts pending-forms))))
|
||||
(err/throw-eof-in-character rdr)))
|
||||
(err/throw-eof-in-character rdr)))
|
||||
|
||||
(def ^:private ^:dynamic arg-env nil)
|
||||
|
||||
(defn- garg
|
||||
"Get a symbol for an anonymous ?argument?"
|
||||
[n]
|
||||
(symbol (str (if (== -1 n) "rest" (str "p" n))
|
||||
"__" (next-id) "#")))
|
||||
|
||||
(defn- read-fn
|
||||
[rdr _ opts pending-forms]
|
||||
(if arg-env
|
||||
(throw (ex-info "Nested #()s are not allowed" {:type :illegal-state})))
|
||||
(binding [arg-env (sorted-map)]
|
||||
(let [form (read* (doto rdr (unread \()) true nil opts pending-forms) ;; this sets bindings
|
||||
rargs (rseq arg-env)
|
||||
args (if rargs
|
||||
(let [higharg (key (first rargs))]
|
||||
(let [args (loop [i 1 args (transient [])]
|
||||
(if (> i higharg)
|
||||
(persistent! args)
|
||||
(recur (inc i) (conj! args (or (get arg-env i)
|
||||
(garg i))))))
|
||||
args (if (arg-env -1)
|
||||
(conj args '& (arg-env -1))
|
||||
args)]
|
||||
args))
|
||||
[])]
|
||||
(list 'fn* args form))))
|
||||
|
||||
(defn- register-arg
|
||||
"Registers an argument to the arg-env"
|
||||
[n]
|
||||
(if arg-env
|
||||
(if-let [ret (arg-env n)]
|
||||
ret
|
||||
(let [g (garg n)]
|
||||
(set! arg-env (assoc arg-env n g))
|
||||
g))
|
||||
(throw (ex-info "Arg literal not in #()"
|
||||
{:type :illegal-state})))) ;; should never hit this
|
||||
|
||||
(declare read-symbol)
|
||||
|
||||
(defn- read-arg
|
||||
[^not-native rdr pct opts pending-forms]
|
||||
(if (nil? arg-env)
|
||||
(read-symbol rdr pct)
|
||||
(let [ch (peek-char rdr)]
|
||||
(cond
|
||||
(or (whitespace? ch)
|
||||
(macro-terminating? ch)
|
||||
(nil? ch))
|
||||
(register-arg 1)
|
||||
|
||||
(= ch \&)
|
||||
(do (read-char rdr)
|
||||
(register-arg -1))
|
||||
|
||||
:else
|
||||
(let [n (read* rdr true nil opts pending-forms)]
|
||||
(if-not (integer? n)
|
||||
(throw (ex-info "Arg literal must be %, %& or %integer"
|
||||
{:type :illegal-state}))
|
||||
(register-arg n)))))))
|
||||
|
||||
(def ^:private ^:dynamic gensym-env nil)
|
||||
|
||||
(defn- read-unquote
|
||||
[^not-native rdr comma opts pending-forms]
|
||||
(if-let [ch (peek-char rdr)]
|
||||
(if (= \@ ch)
|
||||
((wrapping-reader 'clojure.core/unquote-splicing) (doto rdr read-char) \@ opts pending-forms)
|
||||
((wrapping-reader 'clojure.core/unquote) rdr \~ opts pending-forms))))
|
||||
|
||||
(declare syntax-quote*)
|
||||
|
||||
(defn- unquote-splicing? [form]
|
||||
(and (seq? form)
|
||||
(= (first form) 'clojure.core/unquote-splicing)))
|
||||
|
||||
(defn- unquote? [form]
|
||||
(and (seq? form)
|
||||
(= (first form) 'clojure.core/unquote)))
|
||||
|
||||
(defn- expand-list
|
||||
"Expand a list by resolving its syntax quotes and unquotes"
|
||||
[s]
|
||||
(loop [s (seq s) r (transient [])]
|
||||
(if s
|
||||
(let [item (first s)
|
||||
ret (conj! r
|
||||
(cond
|
||||
(unquote? item) (list 'clojure.core/list (second item))
|
||||
(unquote-splicing? item) (second item)
|
||||
:else (list 'clojure.core/list (syntax-quote* item))))]
|
||||
(recur (next s) ret))
|
||||
(seq (persistent! r)))))
|
||||
|
||||
(defn- flatten-map
|
||||
"Flatten a map into a seq of alternate keys and values"
|
||||
[form]
|
||||
(loop [s (seq form) key-vals (transient [])]
|
||||
(if s
|
||||
(let [e (first s)]
|
||||
(recur (next s) (-> key-vals
|
||||
(conj! (key e))
|
||||
(conj! (val e)))))
|
||||
(seq (persistent! key-vals)))))
|
||||
|
||||
(defn- register-gensym [sym]
|
||||
(if-not gensym-env
|
||||
(throw (ex-info "Gensym literal not in syntax-quote"
|
||||
{:type :illegal-state})))
|
||||
(or (get gensym-env sym)
|
||||
(let [gs (symbol (str (subs (name sym)
|
||||
0 (dec (count (name sym))))
|
||||
"__" (next-id) "__auto__"))]
|
||||
(set! gensym-env (assoc gensym-env sym gs))
|
||||
gs)))
|
||||
|
||||
(defn- add-meta [form ret]
|
||||
(if (and (implements? IWithMeta form)
|
||||
(seq (dissoc (meta form) :line :column :end-line :end-column :file :source)))
|
||||
(list 'cljs.core/with-meta ret (syntax-quote* (meta form)))
|
||||
ret))
|
||||
|
||||
(defn- syntax-quote-coll [type coll]
|
||||
(let [res (list 'cljs.core/sequence
|
||||
(cons 'cljs.core/concat
|
||||
(expand-list coll)))]
|
||||
(if type
|
||||
(list 'cljs.core/apply type res)
|
||||
res)))
|
||||
|
||||
(defn map-func
|
||||
"Decide which map type to use, array-map if less than 16 elements"
|
||||
[coll]
|
||||
(if (>= (count coll) 16)
|
||||
'cljs.core/hash-map
|
||||
'cljs.core/array-map))
|
||||
|
||||
(defn bool? [x]
|
||||
(or (instance? js/Boolean x)
|
||||
(true? x)
|
||||
(false? x)))
|
||||
|
||||
(defn ^:dynamic resolve-symbol
|
||||
"Resolve a symbol s into its fully qualified namespace version"
|
||||
[s]
|
||||
(throw (ex-info "resolve-symbol is not implemented" {:sym s})))
|
||||
|
||||
(defn- syntax-quote* [form]
|
||||
(->>
|
||||
(cond
|
||||
(special-symbol? form) (list 'quote form)
|
||||
|
||||
(symbol? form)
|
||||
(list 'quote
|
||||
(if (and (not (namespace form))
|
||||
(gstring/endsWith (name form) "#"))
|
||||
(register-gensym form)
|
||||
(let [sym (str form)]
|
||||
(if (gstring/endsWith sym ".")
|
||||
(let [csym (symbol (subs sym 0 (dec (count sym))))]
|
||||
(symbol (str (resolve-symbol csym) ".")))
|
||||
(resolve-symbol form)))))
|
||||
|
||||
(unquote? form) (second form)
|
||||
(unquote-splicing? form) (throw (ex-info "unquote-splice not in list"
|
||||
{:type :illegal-state}))
|
||||
|
||||
(coll? form)
|
||||
(cond
|
||||
|
||||
(implements? IRecord form) form
|
||||
(map? form) (syntax-quote-coll (map-func form) (flatten-map form))
|
||||
(vector? form) (list 'cljs.core/vec (syntax-quote-coll nil form))
|
||||
(set? form) (syntax-quote-coll 'cljs.core/hash-set form)
|
||||
(or (seq? form) (list? form))
|
||||
(let [seq (seq form)]
|
||||
(if seq
|
||||
(syntax-quote-coll nil seq)
|
||||
'(cljs.core/list)))
|
||||
|
||||
:else (throw (ex-info "Unknown Collection type"
|
||||
{:type :unsupported-operation})))
|
||||
|
||||
(or (keyword? form)
|
||||
(number? form)
|
||||
(string? form)
|
||||
(nil? form)
|
||||
(bool? form)
|
||||
(instance? js/RegExp form))
|
||||
form
|
||||
|
||||
:else (list 'quote form))
|
||||
(add-meta form)))
|
||||
|
||||
(defn- read-syntax-quote
|
||||
[rdr backquote opts pending-forms]
|
||||
(binding [gensym-env {}]
|
||||
(-> (read* rdr true nil opts pending-forms)
|
||||
syntax-quote*)))
|
||||
|
||||
(defn- read-namespaced-map
|
||||
[rdr _ opts pending-forms]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
token (read-token rdr :namespaced-map (read-char rdr))]
|
||||
(if-let [ns (cond
|
||||
(= token ":")
|
||||
(ns-name *ns*)
|
||||
|
||||
(= \: (first token))
|
||||
(some-> token (subs 1) parse-symbol second' symbol resolve-ns)
|
||||
|
||||
:else
|
||||
(some-> token parse-symbol second'))]
|
||||
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(if (identical? ch \{)
|
||||
(let [items (read-delimited :namespaced-map \} rdr opts pending-forms)
|
||||
[end-line end-column] (ending-line-col-info rdr)]
|
||||
(when (odd? (count items))
|
||||
(err/throw-odd-map rdr nil nil items))
|
||||
(let [keys (namespace-keys (str ns) (take-nth 2 items))
|
||||
vals (take-nth 2 (rest items))]
|
||||
(when-not (= (count (set keys)) (count keys))
|
||||
(err/throw-dup-keys rdr :namespaced-map keys))
|
||||
(with-meta (zipmap keys vals)
|
||||
(when start-line
|
||||
(merge
|
||||
(when-let [file (get-file-name rdr)]
|
||||
{:file file})
|
||||
{:line start-line
|
||||
:column start-column
|
||||
:end-line end-line
|
||||
:end-column end-column})))))
|
||||
(err/throw-ns-map-no-map rdr token)))
|
||||
(err/throw-bad-ns rdr token))))
|
||||
|
||||
(defn- macros [ch]
|
||||
(case ch
|
||||
\" read-string*
|
||||
\: read-keyword
|
||||
\; read-comment
|
||||
\' (wrapping-reader 'quote)
|
||||
\@ (wrapping-reader 'clojure.core/deref)
|
||||
\^ read-meta
|
||||
\` read-syntax-quote
|
||||
\~ read-unquote
|
||||
\( read-list
|
||||
\) read-unmatched-delimiter
|
||||
\[ read-vector
|
||||
\] read-unmatched-delimiter
|
||||
\{ read-map
|
||||
\} read-unmatched-delimiter
|
||||
\\ read-char*
|
||||
\% read-arg
|
||||
\# read-dispatch
|
||||
nil))
|
||||
|
||||
(defn- dispatch-macros [ch]
|
||||
(case ch
|
||||
\^ read-meta ;; deprecated
|
||||
\' (wrapping-reader 'var)
|
||||
\( read-fn
|
||||
\{ read-set
|
||||
\< (throwing-reader "Unreadable form")
|
||||
\= (throwing-reader "read-eval not supported")
|
||||
\" read-regex
|
||||
\! read-comment
|
||||
\_ read-discard
|
||||
\? read-cond
|
||||
\: read-namespaced-map
|
||||
\# read-symbolic-value
|
||||
nil))
|
||||
|
||||
(defn- read-tagged [^not-native rdr initch opts pending-forms]
|
||||
(let [tag (read* rdr true nil opts pending-forms)]
|
||||
(if-not (symbol? tag)
|
||||
(err/throw-bad-reader-tag rdr tag))
|
||||
(if *suppress-read*
|
||||
(tagged-literal tag (read* rdr true nil opts pending-forms))
|
||||
(if-let [f (or (*data-readers* tag)
|
||||
(default-data-readers tag))]
|
||||
(f (read* rdr true nil opts pending-forms))
|
||||
(if-let [f *default-data-reader-fn*]
|
||||
(f tag (read* rdr true nil opts pending-forms))
|
||||
(err/throw-unknown-reader-tag rdr tag))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(def ^:dynamic *data-readers*
|
||||
"Map from reader tag symbols to data reader Vars.
|
||||
Reader tags without namespace qualifiers are reserved for Clojure.
|
||||
This light version of tools.reader has no implementation for default
|
||||
reader tags such as #inst and #uuid."
|
||||
{})
|
||||
|
||||
(def ^:dynamic *default-data-reader-fn*
|
||||
"When no data reader is found for a tag and *default-data-reader-fn*
|
||||
is non-nil, it will be called with two arguments, the tag and the value.
|
||||
If *default-data-reader-fn* is nil (the default value), an exception
|
||||
will be thrown for the unknown tag."
|
||||
nil)
|
||||
|
||||
(def ^:dynamic *suppress-read* false)
|
||||
|
||||
(def default-data-readers
|
||||
"Default map of data reader functions provided by Clojure.
|
||||
May be overridden by binding *data-readers*"
|
||||
{})
|
||||
|
||||
(defn- read*-internal
|
||||
[^not-native reader ^boolean eof-error? sentinel return-on opts pending-forms]
|
||||
(loop []
|
||||
(log-source reader
|
||||
(if-not ^boolean (garray/isEmpty pending-forms)
|
||||
(let [form (aget pending-forms 0)]
|
||||
(garray/removeAt pending-forms 0)
|
||||
form)
|
||||
(let [ch (read-char reader)]
|
||||
(cond
|
||||
(whitespace? ch) (recur)
|
||||
(nil? ch) (if eof-error? (err/throw-eof-error reader nil) sentinel)
|
||||
(identical? ch return-on) READ_FINISHED
|
||||
(number-literal? reader ch) (read-number reader ch)
|
||||
:else (let [f (macros ch)]
|
||||
(if-not (nil? f)
|
||||
(let [res (f reader ch opts pending-forms)]
|
||||
(if (identical? res reader)
|
||||
(recur)
|
||||
res))
|
||||
(read-symbol reader ch)))))))))
|
||||
|
||||
(defn- read*
|
||||
([reader eof-error? sentinel opts pending-forms]
|
||||
(read* reader eof-error? sentinel nil opts pending-forms))
|
||||
([^not-native reader eof-error? sentinel return-on opts pending-forms]
|
||||
(try
|
||||
(read*-internal reader eof-error? sentinel return-on opts pending-forms)
|
||||
(catch js/Error e
|
||||
(if (ex-info? e)
|
||||
(let [d (ex-data e)]
|
||||
(if (= :reader-exception (:type d))
|
||||
(throw e)
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
d
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e))))
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e)))))))
|
||||
|
||||
(defn read
|
||||
"Reads the first object from an IPushbackReader.
|
||||
Returns the object read. If EOF, throws if eof-error? is true.
|
||||
Otherwise returns sentinel. If no stream is provided, *in* will be used.
|
||||
|
||||
Opts is a persistent map with valid keys:
|
||||
:read-cond - :allow to process reader conditionals, or
|
||||
:preserve to keep all branches
|
||||
:features - persistent set of feature keywords for reader conditionals
|
||||
:eof - on eof, return value unless :eofthrow, then throw.
|
||||
if not specified, will throw
|
||||
|
||||
To read data structures only, use cljs.tools.reader.edn/read
|
||||
|
||||
Note that the function signature of cljs.tools.reader/read and
|
||||
cljs.tools.reader.edn/read is not the same for eof-handling"
|
||||
{:arglists '([reader] [opts reader] [reader eof-error? eof-value])}
|
||||
([reader] (read reader true nil))
|
||||
([{eof :eof :as opts :or {eof :eofthrow}} reader] (read* reader (= eof :eofthrow) eof nil opts (to-array [])))
|
||||
([reader eof-error? sentinel] (read* reader eof-error? sentinel nil {} (to-array []))))
|
||||
|
||||
(defn read-string
|
||||
"Reads one object from the string s.
|
||||
Returns nil when s is nil or empty.
|
||||
|
||||
To read data structures only, use cljs.tools.reader.edn/read-string
|
||||
|
||||
Note that the function signature of cljs.tools.reader/read-string and
|
||||
cljs.tools.reader.edn/read-string is not the same for eof-handling"
|
||||
([s]
|
||||
(read-string {} s))
|
||||
([opts s]
|
||||
(when (and s (not (identical? s "")))
|
||||
(read opts (string-push-back-reader s)))))
|
||||
|
||||
(defn read+string
|
||||
"Like read, and taking the same args. reader must be a SourceLoggingPushbackReader.
|
||||
Returns a vector containing the object read and the (whitespace-trimmed) string read."
|
||||
([stream] (read+string stream true nil))
|
||||
([stream eof-error? eof-value]
|
||||
(let [buf (fn [stream] (str (:buffer @(.-frames stream))))
|
||||
offset (count (buf stream))
|
||||
o (log-source stream (read stream eof-error? eof-value))
|
||||
s (.trim (subs (buf stream) offset))]
|
||||
[o s]))
|
||||
([opts stream]
|
||||
(let [buf (fn [stream] (str (:buffer @(.-frames stream))))
|
||||
offset (count (buf stream))
|
||||
o (log-source stream (read opts stream))
|
||||
s (.trim (subs (buf stream) offset))]
|
||||
[o s])))
|
||||
Executable
+1816
File diff suppressed because it is too large
Load Diff
Executable
+446
@@ -0,0 +1,446 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns ^{:doc "An EDN reader in clojure"
|
||||
:author "Bronsa"}
|
||||
cljs.tools.reader.edn
|
||||
(:refer-clojure :exclude [read read-string char default-data-readers])
|
||||
(:require [cljs.tools.reader.impl.errors :as err]
|
||||
[cljs.tools.reader.reader-types :refer
|
||||
[read-char unread peek-char indexing-reader?
|
||||
get-line-number get-column-number get-file-name string-push-back-reader]]
|
||||
[cljs.tools.reader.impl.utils :refer
|
||||
[char ex-info? whitespace? numeric? desugar-meta namespace-keys second' char-code]]
|
||||
[cljs.tools.reader.impl.commons :refer
|
||||
[number-literal? read-past match-number parse-symbol read-comment throwing-reader]]
|
||||
[cljs.tools.reader :refer [default-data-readers]]
|
||||
[goog.string :as gstring])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(declare read macros dispatch-macros)
|
||||
|
||||
(defn- ^boolean macro-terminating? [ch]
|
||||
(and (not (identical? \# ch))
|
||||
(not (identical? \' ch))
|
||||
(not (identical? \: ch))
|
||||
(macros ch)))
|
||||
|
||||
(defn- ^boolean not-constituent? [ch]
|
||||
(or (identical? \@ ch)
|
||||
(identical? \` ch)
|
||||
(identical? \~ ch)))
|
||||
|
||||
(defn- read-token
|
||||
([rdr kind initch]
|
||||
(read-token rdr kind initch true))
|
||||
([rdr kind initch validate-leading?]
|
||||
(cond
|
||||
(not initch)
|
||||
(err/throw-eof-at-start rdr kind)
|
||||
|
||||
(and validate-leading?
|
||||
(not-constituent? initch))
|
||||
(err/throw-bad-char rdr kind initch)
|
||||
|
||||
:else
|
||||
(loop [sb (StringBuffer.)
|
||||
ch (do (unread rdr initch) initch)]
|
||||
(if (or (whitespace? ch)
|
||||
(macro-terminating? ch)
|
||||
(nil? ch))
|
||||
(str sb)
|
||||
(if (not-constituent? ch)
|
||||
(err/throw-bad-char rdr kind ch)
|
||||
(recur (doto sb (.append (read-char rdr))) (peek-char rdr))))))))
|
||||
|
||||
(declare read-tagged)
|
||||
|
||||
(defn- read-dispatch
|
||||
[rdr _ opts]
|
||||
(if-let [ch (read-char rdr)]
|
||||
(if-let [dm (dispatch-macros ch)]
|
||||
(dm rdr ch opts)
|
||||
(read-tagged (doto rdr (unread ch)) ch opts))
|
||||
(err/throw-eof-at-dispatch rdr)))
|
||||
|
||||
(defn- read-unmatched-delimiter
|
||||
[rdr ch opts]
|
||||
(err/throw-unmatch-delimiter rdr ch))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn- read-unicode-char
|
||||
([token offset length base]
|
||||
(let [l (+ offset length)]
|
||||
(when-not (== (count token) l)
|
||||
(err/throw-invalid-unicode-literal nil token))
|
||||
(loop [i offset uc 0]
|
||||
(if (== i l)
|
||||
(js/String.fromCharCode uc)
|
||||
(let [d (char-code (nth token i) base)]
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit-in-token nil (nth token i) token)
|
||||
(recur (inc i) (+ d (* uc base)))))))))
|
||||
|
||||
([rdr initch base length exact?]
|
||||
(loop [i 1 uc (char-code initch base)]
|
||||
(if (== uc -1)
|
||||
(err/throw-invalid-unicode-digit rdr initch)
|
||||
(if-not (== i length)
|
||||
(let [ch (peek-char rdr)]
|
||||
(if (or (whitespace? ch)
|
||||
(macros ch)
|
||||
(nil? ch))
|
||||
(if exact?
|
||||
(err/throw-invalid-unicode-len rdr i length)
|
||||
(js/String.fromCharCode uc))
|
||||
(let [d (char-code ch base)]
|
||||
(read-char rdr)
|
||||
(if (== d -1)
|
||||
(err/throw-invalid-unicode-digit rdr ch)
|
||||
(recur (inc i) (+ d (* uc base)))))))
|
||||
(js/String.fromCharCode uc))))))
|
||||
|
||||
(def ^:private ^:const upper-limit (.charCodeAt \uD7ff 0))
|
||||
(def ^:private ^:const lower-limit (.charCodeAt \uE000 0))
|
||||
|
||||
(defn- read-char*
|
||||
[rdr backslash opts]
|
||||
(let [ch (read-char rdr)]
|
||||
(if-not (nil? ch)
|
||||
(let [token (if (or (macro-terminating? ch)
|
||||
(not-constituent? ch)
|
||||
(whitespace? ch))
|
||||
(str ch)
|
||||
(read-token rdr :character ch false))
|
||||
token-len (count token)]
|
||||
(cond
|
||||
|
||||
(== 1 token-len) (nth token 0)
|
||||
|
||||
(identical? token "newline") \newline
|
||||
(identical? token "space") \space
|
||||
(identical? token "tab") \tab
|
||||
(identical? token "backspace") \backspace
|
||||
(identical? token "formfeed") \formfeed
|
||||
(identical? token "return") \return
|
||||
|
||||
(gstring/startsWith token "u")
|
||||
(let [c (read-unicode-char token 1 4 16)
|
||||
ic (.charCodeAt c)]
|
||||
(if (and (> ic upper-limit)
|
||||
(< ic lower-limit))
|
||||
(err/throw-invalid-character-literal rdr (.toString ic 16))
|
||||
c))
|
||||
|
||||
(gstring/startsWith token "o")
|
||||
(let [len (dec token-len)]
|
||||
(if (> len 3)
|
||||
(err/throw-invalid-octal-len rdr token)
|
||||
(let [uc (read-unicode-char token 1 len 8)]
|
||||
(if (> (int uc) 0377)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
uc))))
|
||||
|
||||
:else (err/throw-unsupported-character rdr token)))
|
||||
(err/throw-eof-in-character rdr))))
|
||||
|
||||
(defn ^:private starting-line-col-info [rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
[(get-line-number rdr) (int (dec (int (get-column-number rdr))))]))
|
||||
|
||||
(defn- read-delimited
|
||||
[kind delim rdr opts]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
delim (char delim)]
|
||||
(loop [a (transient [])]
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(when-not ch
|
||||
(err/throw-eof-delimited rdr kind start-line start-column (count a)))
|
||||
(if (= delim (char ch))
|
||||
(persistent! a)
|
||||
(if-let [macrofn (macros ch)]
|
||||
(let [mret (macrofn rdr ch opts)]
|
||||
(recur (if-not (identical? mret rdr) (conj! a mret) a)))
|
||||
(let [o (read (doto rdr (unread ch)) true nil opts)]
|
||||
(recur (if-not (identical? o rdr) (conj! a o) a)))))))))
|
||||
|
||||
(defn- read-list
|
||||
[rdr _ opts]
|
||||
(let [the-list (read-delimited :list \) rdr opts)]
|
||||
(if (empty? the-list)
|
||||
'()
|
||||
(apply list the-list))))
|
||||
|
||||
(defn- read-vector
|
||||
[rdr _ opts]
|
||||
(read-delimited :vector \] rdr opts))
|
||||
|
||||
|
||||
(defn- read-map
|
||||
[rdr _ opts]
|
||||
(let [[start-line start-column] (starting-line-col-info rdr)
|
||||
the-map (read-delimited :map \} rdr opts)
|
||||
map-count (count the-map)
|
||||
ks (take-nth 2 the-map)
|
||||
key-set (set ks)]
|
||||
(when (odd? map-count)
|
||||
(err/throw-odd-map rdr start-line start-column the-map))
|
||||
(when-not (= (count key-set) (count ks))
|
||||
(err/throw-dup-keys rdr :map ks))
|
||||
(if (<= map-count (* 2 (.-HASHMAP-THRESHOLD cljs.core/PersistentArrayMap)))
|
||||
(.fromArray cljs.core/PersistentArrayMap (to-array the-map) true true)
|
||||
(.fromArray cljs.core/PersistentHashMap (to-array the-map) true))))
|
||||
|
||||
(defn- read-number
|
||||
[rdr initch opts]
|
||||
(loop [sb (doto (StringBuffer.) (.append initch))
|
||||
ch (read-char rdr)]
|
||||
(if (or (whitespace? ch) (macros ch) (nil? ch))
|
||||
(let [s (str sb)]
|
||||
(unread rdr ch)
|
||||
(or (match-number s)
|
||||
(err/throw-invalid-number rdr s)))
|
||||
(recur (doto sb (.append ch)) (read-char rdr)))))
|
||||
|
||||
(defn- escape-char [sb rdr]
|
||||
(let [ch (read-char rdr)]
|
||||
(case ch
|
||||
\t "\t"
|
||||
\r "\r"
|
||||
\n "\n"
|
||||
\\ "\\"
|
||||
\" "\""
|
||||
\b "\b"
|
||||
\f "\f"
|
||||
\u (let [ch (read-char rdr)]
|
||||
(if (== -1 (js/parseInt (int ch) 16))
|
||||
(err/throw-invalid-unicode-escape rdr ch)
|
||||
(read-unicode-char rdr ch 16 4 true)))
|
||||
(if (numeric? ch)
|
||||
(let [ch (read-unicode-char rdr ch 8 3 false)]
|
||||
(if (> (int ch) 0377)
|
||||
(err/throw-bad-octal-number rdr)
|
||||
ch))
|
||||
(err/throw-bad-escape-char rdr ch)))))
|
||||
|
||||
(defn- read-string*
|
||||
[rdr _ opts]
|
||||
(loop [sb (StringBuffer.)
|
||||
ch (read-char rdr)]
|
||||
(case ch
|
||||
nil (err/throw-eof-reading rdr :string \" sb)
|
||||
\\ (recur (doto sb (.append (escape-char sb rdr)))
|
||||
(read-char rdr))
|
||||
\" (str sb)
|
||||
(recur (doto sb (.append ch)) (read-char rdr)))))
|
||||
|
||||
(defn- read-symbol
|
||||
[rdr initch]
|
||||
(when-let [token (read-token rdr :symbol initch)]
|
||||
(case token
|
||||
|
||||
;; special symbols
|
||||
"nil" nil
|
||||
"true" true
|
||||
"false" false
|
||||
"/" '/
|
||||
|
||||
(or (when-let [p (parse-symbol token)]
|
||||
(symbol (p 0) (p 1)))
|
||||
(err/throw-invalid rdr :symbol token)))))
|
||||
|
||||
(defn- read-keyword
|
||||
[reader initch opts]
|
||||
(let [ch (read-char reader)]
|
||||
(if-not (whitespace? ch)
|
||||
(let [token (read-token reader :keyword ch)
|
||||
s (parse-symbol token)]
|
||||
(if (and s (== -1 (.indexOf token "::")))
|
||||
(let [ns (s 0)
|
||||
name (s 1)]
|
||||
(if (identical? \: (nth token 0))
|
||||
(err/throw-invalid reader :keyword (str \: token)) ;; no ::keyword in edn
|
||||
(keyword ns name)))
|
||||
(err/throw-invalid reader :keyword (str \: token))))
|
||||
(err/throw-single-colon reader))))
|
||||
|
||||
(defn- wrapping-reader
|
||||
[sym]
|
||||
(fn [rdr _ opts]
|
||||
(list sym (read rdr true nil opts))))
|
||||
|
||||
(defn- read-meta
|
||||
[rdr _ opts]
|
||||
(let [m (desugar-meta (read rdr true nil opts))]
|
||||
(when-not (map? m)
|
||||
(err/throw-bad-metadata rdr m))
|
||||
(let [o (read rdr true nil opts)]
|
||||
(if (implements? IMeta o)
|
||||
(with-meta o (merge (meta o) m))
|
||||
(err/throw-bad-metadata-target rdr o)))))
|
||||
|
||||
(defn- read-set
|
||||
[rdr _ opts]
|
||||
(let [coll (read-delimited :set \} rdr opts)
|
||||
the-set (set coll)]
|
||||
(when-not (= (count coll) (count the-set))
|
||||
(err/throw-dup-keys rdr :set coll))
|
||||
the-set))
|
||||
|
||||
(defn- read-discard
|
||||
[rdr _ opts]
|
||||
(doto rdr
|
||||
(read true nil true)))
|
||||
|
||||
(defn- read-namespaced-map
|
||||
[rdr _ opts]
|
||||
(let [token (read-token rdr :namespaced-map (read-char rdr))]
|
||||
(if-let [ns (some-> token parse-symbol second')]
|
||||
(let [ch (read-past whitespace? rdr)]
|
||||
(if (identical? ch \{)
|
||||
(let [items (read-delimited :namespaced-map \} rdr opts)]
|
||||
(when (odd? (count items))
|
||||
(err/throw-odd-map rdr nil nil items))
|
||||
(let [keys (namespace-keys (str ns) (take-nth 2 items))
|
||||
vals (take-nth 2 (rest items))]
|
||||
(when-not (= (count (set keys)) (count keys))
|
||||
(err/throw-dup-keys rdr :namespaced-map keys))
|
||||
(zipmap keys vals)))
|
||||
(err/throw-ns-map-no-map rdr token)))
|
||||
(err/throw-bad-ns rdr token))))
|
||||
|
||||
(defn- read-symbolic-value
|
||||
[rdr _ opts]
|
||||
(let [sym (read rdr true nil opts)]
|
||||
(case sym
|
||||
|
||||
NaN js/Number.NaN
|
||||
-Inf js/Number.NEGATIVE_INFINITY
|
||||
Inf js/Number.POSITIVE_INFINITY
|
||||
|
||||
(err/reader-error rdr (str "Invalid token: ##" sym)))))
|
||||
|
||||
(defn- macros [ch]
|
||||
(case ch
|
||||
\" read-string*
|
||||
\: read-keyword
|
||||
\; read-comment
|
||||
\^ read-meta
|
||||
\( read-list
|
||||
\) read-unmatched-delimiter
|
||||
\[ read-vector
|
||||
\] read-unmatched-delimiter
|
||||
\{ read-map
|
||||
\} read-unmatched-delimiter
|
||||
\\ read-char*
|
||||
\# read-dispatch
|
||||
nil))
|
||||
|
||||
(defn- dispatch-macros [ch]
|
||||
(case ch
|
||||
\^ read-meta ;deprecated
|
||||
\{ read-set
|
||||
\< (throwing-reader "Unreadable form")
|
||||
\! read-comment
|
||||
\_ read-discard
|
||||
\: read-namespaced-map
|
||||
\# read-symbolic-value
|
||||
nil))
|
||||
|
||||
(defn- read-tagged [rdr initch opts]
|
||||
(let [tag (read rdr true nil opts)
|
||||
object (read rdr true nil opts)]
|
||||
(if-not (symbol? tag)
|
||||
(err/throw-bad-reader-tag rdr "Reader tag must be a symbol"))
|
||||
(if-let [f (or (get (:readers opts) tag)
|
||||
(default-data-readers tag))]
|
||||
(f object)
|
||||
(if-let [d (:default opts)]
|
||||
(d tag object)
|
||||
(err/throw-unknown-reader-tag rdr tag)))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read
|
||||
"Reads the first object from an IPushbackReader.
|
||||
Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
If no reader is provided, *in* will be used.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
is done by passing an opt map.
|
||||
|
||||
opts is a map that can include the following keys:
|
||||
:eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
:readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
When not supplied, only the default-data-readers will be used.
|
||||
:default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
be called with the tag and the value."
|
||||
([reader] (read {} reader))
|
||||
([{:keys [eof] :as opts} reader]
|
||||
(let [eof-error? (not (contains? opts :eof))]
|
||||
(read reader eof-error? eof opts)))
|
||||
([reader eof-error? eof opts]
|
||||
(try
|
||||
(loop []
|
||||
(let [ch (read-char reader)]
|
||||
(cond
|
||||
(whitespace? ch) (recur)
|
||||
(nil? ch) (if eof-error? (err/throw-eof-error reader nil) eof)
|
||||
(number-literal? reader ch) (read-number reader ch opts)
|
||||
:else (let [f (macros ch)]
|
||||
(if f
|
||||
(let [res (f reader ch opts)]
|
||||
(if (identical? res reader)
|
||||
(recur)
|
||||
res))
|
||||
(read-symbol reader ch))))))
|
||||
(catch js/Error e
|
||||
(if (ex-info? e)
|
||||
(let [d (ex-data e)]
|
||||
(if (= :reader-exception (:type d))
|
||||
(throw e)
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
d
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e))))
|
||||
(throw (ex-info (.-message e)
|
||||
(merge {:type :reader-exception}
|
||||
(if (indexing-reader? reader)
|
||||
{:line (get-line-number reader)
|
||||
:column (get-column-number reader)
|
||||
:file (get-file-name reader)}))
|
||||
e)))))))
|
||||
|
||||
(defn read-string
|
||||
"Reads one object from the string s.
|
||||
Returns nil when s is nil or empty.
|
||||
|
||||
Reads data in the edn format (subset of Clojure data):
|
||||
http://edn-format.org
|
||||
|
||||
opts is a map as per cljs.tools.reader.edn/read"
|
||||
([s] (read-string {:eof nil} s))
|
||||
([opts s]
|
||||
(when (and s (not= s ""))
|
||||
(read opts (string-push-back-reader s)))))
|
||||
Executable
+934
@@ -0,0 +1,934 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.edn');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('cljs.tools.reader.impl.errors');
|
||||
goog.require('cljs.tools.reader.reader_types');
|
||||
goog.require('cljs.tools.reader.impl.utils');
|
||||
goog.require('cljs.tools.reader.impl.commons');
|
||||
goog.require('cljs.tools.reader');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
|
||||
|
||||
cljs.tools.reader.edn.macro_terminating_QMARK_ = (function cljs$tools$reader$edn$macro_terminating_QMARK_(ch){
|
||||
var and__5043__auto__ = (!(("#" === ch)));
|
||||
if(and__5043__auto__){
|
||||
var and__5043__auto____$1 = (!(("'" === ch)));
|
||||
if(and__5043__auto____$1){
|
||||
var and__5043__auto____$2 = (!((":" === ch)));
|
||||
if(and__5043__auto____$2){
|
||||
return (cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.macros.call(null,ch));
|
||||
} else {
|
||||
return and__5043__auto____$2;
|
||||
}
|
||||
} else {
|
||||
return and__5043__auto____$1;
|
||||
}
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.not_constituent_QMARK_ = (function cljs$tools$reader$edn$not_constituent_QMARK_(ch){
|
||||
return ((("@" === ch)) || (((("`" === ch)) || (("~" === ch)))));
|
||||
});
|
||||
cljs.tools.reader.edn.read_token = (function cljs$tools$reader$edn$read_token(var_args){
|
||||
var G__5893 = arguments.length;
|
||||
switch (G__5893) {
|
||||
case 3:
|
||||
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3 = (function (rdr,kind,initch){
|
||||
return cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4(rdr,kind,initch,true);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4 = (function (rdr,kind,initch,validate_leading_QMARK_){
|
||||
if(cljs.core.not(initch)){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_at_start(rdr,kind);
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = validate_leading_QMARK_;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return cljs.tools.reader.edn.not_constituent_QMARK_(initch);
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_char(rdr,kind,initch);
|
||||
} else {
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var ch = (function (){
|
||||
cljs.tools.reader.reader_types.unread(rdr,initch);
|
||||
|
||||
return initch;
|
||||
})()
|
||||
;
|
||||
while(true){
|
||||
if(((cljs.tools.reader.impl.utils.whitespace_QMARK_(ch)) || (((cljs.tools.reader.edn.macro_terminating_QMARK_(ch)) || ((ch == null)))))){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
|
||||
} else {
|
||||
if(cljs.tools.reader.edn.not_constituent_QMARK_(ch)){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_char(rdr,kind,ch);
|
||||
} else {
|
||||
var G__5896 = (function (){var G__5894 = sb;
|
||||
G__5894.append(cljs.tools.reader.reader_types.read_char(rdr));
|
||||
|
||||
return G__5894;
|
||||
})();
|
||||
var G__5897 = cljs.tools.reader.reader_types.peek_char(rdr);
|
||||
sb = G__5896;
|
||||
ch = G__5897;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_token.cljs$lang$maxFixedArity = 4);
|
||||
|
||||
cljs.tools.reader.edn.read_dispatch = (function cljs$tools$reader$edn$read_dispatch(rdr,_,opts){
|
||||
var temp__4655__auto__ = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var ch = temp__4655__auto__;
|
||||
var temp__4655__auto____$1 = (cljs.tools.reader.edn.dispatch_macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.dispatch_macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.dispatch_macros.call(null,ch));
|
||||
if(cljs.core.truth_(temp__4655__auto____$1)){
|
||||
var dm = temp__4655__auto____$1;
|
||||
return (dm.cljs$core$IFn$_invoke$arity$3 ? dm.cljs$core$IFn$_invoke$arity$3(rdr,ch,opts) : dm.call(null,rdr,ch,opts));
|
||||
} else {
|
||||
var G__5898 = (function (){var G__5901 = rdr;
|
||||
cljs.tools.reader.reader_types.unread(G__5901,ch);
|
||||
|
||||
return G__5901;
|
||||
})();
|
||||
var G__5899 = ch;
|
||||
var G__5900 = opts;
|
||||
return (cljs.tools.reader.edn.read_tagged.cljs$core$IFn$_invoke$arity$3 ? cljs.tools.reader.edn.read_tagged.cljs$core$IFn$_invoke$arity$3(G__5898,G__5899,G__5900) : cljs.tools.reader.edn.read_tagged.call(null,G__5898,G__5899,G__5900));
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_eof_at_dispatch(rdr);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_unmatched_delimiter = (function cljs$tools$reader$edn$read_unmatched_delimiter(rdr,ch,opts){
|
||||
return cljs.tools.reader.impl.errors.throw_unmatch_delimiter(rdr,ch);
|
||||
});
|
||||
cljs.tools.reader.edn.read_unicode_char = (function cljs$tools$reader$edn$read_unicode_char(var_args){
|
||||
var G__5903 = arguments.length;
|
||||
switch (G__5903) {
|
||||
case 4:
|
||||
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
case 5:
|
||||
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4 = (function (token,offset,length,base){
|
||||
var l = (offset + length);
|
||||
if((cljs.core.count(token) === l)){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_literal(null,token);
|
||||
}
|
||||
|
||||
var i = offset;
|
||||
var uc = (0);
|
||||
while(true){
|
||||
if((i === l)){
|
||||
return String.fromCharCode(uc);
|
||||
} else {
|
||||
var d = cljs.tools.reader.impl.utils.char_code(cljs.core.nth.cljs$core$IFn$_invoke$arity$2(token,i),base);
|
||||
if((d === (-1))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit_in_token(null,cljs.core.nth.cljs$core$IFn$_invoke$arity$2(token,i),token);
|
||||
} else {
|
||||
var G__5905 = (i + (1));
|
||||
var G__5906 = (d + (uc * base));
|
||||
i = G__5905;
|
||||
uc = G__5906;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5 = (function (rdr,initch,base,length,exact_QMARK_){
|
||||
var i = (1);
|
||||
var uc = cljs.tools.reader.impl.utils.char_code(initch,base);
|
||||
while(true){
|
||||
if((uc === (-1))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit(rdr,initch);
|
||||
} else {
|
||||
if((!((i === length)))){
|
||||
var ch = cljs.tools.reader.reader_types.peek_char(rdr);
|
||||
if(cljs.core.truth_((function (){var or__5045__auto__ = cljs.tools.reader.impl.utils.whitespace_QMARK_(ch);
|
||||
if(or__5045__auto__){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
var or__5045__auto____$1 = (cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.macros.call(null,ch));
|
||||
if(cljs.core.truth_(or__5045__auto____$1)){
|
||||
return or__5045__auto____$1;
|
||||
} else {
|
||||
return (ch == null);
|
||||
}
|
||||
}
|
||||
})())){
|
||||
if(cljs.core.truth_(exact_QMARK_)){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_len(rdr,i,length);
|
||||
} else {
|
||||
return String.fromCharCode(uc);
|
||||
}
|
||||
} else {
|
||||
var d = cljs.tools.reader.impl.utils.char_code(ch,base);
|
||||
cljs.tools.reader.reader_types.read_char(rdr);
|
||||
|
||||
if((d === (-1))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_digit(rdr,ch);
|
||||
} else {
|
||||
var G__5907 = (i + (1));
|
||||
var G__5908 = (d + (uc * base));
|
||||
i = G__5907;
|
||||
uc = G__5908;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return String.fromCharCode(uc);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_unicode_char.cljs$lang$maxFixedArity = 5);
|
||||
|
||||
cljs.tools.reader.edn.upper_limit = "\uD7FF".charCodeAt((0));
|
||||
cljs.tools.reader.edn.lower_limit = "\uE000".charCodeAt((0));
|
||||
cljs.tools.reader.edn.read_char_STAR_ = (function cljs$tools$reader$edn$read_char_STAR_(rdr,backslash,opts){
|
||||
var ch = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
if((!((ch == null)))){
|
||||
var token = ((((cljs.tools.reader.edn.macro_terminating_QMARK_(ch)) || (((cljs.tools.reader.edn.not_constituent_QMARK_(ch)) || (cljs.tools.reader.impl.utils.whitespace_QMARK_(ch))))))?cljs.core.str.cljs$core$IFn$_invoke$arity$1(ch):cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$4(rdr,cljs.core.cst$kw$character,ch,false));
|
||||
var token_len = ((token).length);
|
||||
if(((1) === token_len)){
|
||||
return cljs.core.nth.cljs$core$IFn$_invoke$arity$2(token,(0));
|
||||
} else {
|
||||
if((token === "newline")){
|
||||
return "\n";
|
||||
} else {
|
||||
if((token === "space")){
|
||||
return " ";
|
||||
} else {
|
||||
if((token === "tab")){
|
||||
return "\t";
|
||||
} else {
|
||||
if((token === "backspace")){
|
||||
return "\b";
|
||||
} else {
|
||||
if((token === "formfeed")){
|
||||
return "\f";
|
||||
} else {
|
||||
if((token === "return")){
|
||||
return "\r";
|
||||
} else {
|
||||
if(goog.string.startsWith(token,"u")){
|
||||
var c = cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4(token,(1),(4),(16));
|
||||
var ic = c.charCodeAt();
|
||||
if((((ic > cljs.tools.reader.edn.upper_limit)) && ((ic < cljs.tools.reader.edn.lower_limit)))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_character_literal(rdr,ic.toString((16)));
|
||||
} else {
|
||||
return c;
|
||||
}
|
||||
} else {
|
||||
if(goog.string.startsWith(token,"o")){
|
||||
var len = (token_len - (1));
|
||||
if((len > (3))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_octal_len(rdr,token);
|
||||
} else {
|
||||
var uc = cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$4(token,(1),len,(8));
|
||||
if(((uc | (0)) > (255))){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_octal_number(rdr);
|
||||
} else {
|
||||
return uc;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_unsupported_character(rdr,token);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_eof_in_character(rdr);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.starting_line_col_info = (function cljs$tools$reader$edn$starting_line_col_info(rdr){
|
||||
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_(rdr)){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.tools.reader.reader_types.get_line_number(rdr),(((cljs.tools.reader.reader_types.get_column_number(rdr) | (0)) - (1)) | (0))], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_delimited = (function cljs$tools$reader$edn$read_delimited(kind,delim,rdr,opts){
|
||||
var vec__5909 = cljs.tools.reader.edn.starting_line_col_info(rdr);
|
||||
var start_line = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5909,(0),null);
|
||||
var start_column = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5909,(1),null);
|
||||
var delim__$1 = cljs.tools.reader.impl.utils.char$(delim);
|
||||
var a = cljs.core.transient$(cljs.core.PersistentVector.EMPTY);
|
||||
while(true){
|
||||
var ch = cljs.tools.reader.impl.commons.read_past(cljs.tools.reader.impl.utils.whitespace_QMARK_,rdr);
|
||||
if(cljs.core.truth_(ch)){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5(rdr,kind,start_line,start_column,cljs.core.count(a));
|
||||
}
|
||||
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(delim__$1,cljs.tools.reader.impl.utils.char$(ch))){
|
||||
return cljs.core.persistent_BANG_(a);
|
||||
} else {
|
||||
var temp__4655__auto__ = (cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.macros.call(null,ch));
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var macrofn = temp__4655__auto__;
|
||||
var mret = (macrofn.cljs$core$IFn$_invoke$arity$3 ? macrofn.cljs$core$IFn$_invoke$arity$3(rdr,ch,opts) : macrofn.call(null,rdr,ch,opts));
|
||||
var G__5917 = (((!((mret === rdr))))?cljs.core.conj_BANG_.cljs$core$IFn$_invoke$arity$2(a,mret):a);
|
||||
a = G__5917;
|
||||
continue;
|
||||
} else {
|
||||
var o = (function (){var G__5912 = (function (){var G__5916 = rdr;
|
||||
cljs.tools.reader.reader_types.unread(G__5916,ch);
|
||||
|
||||
return G__5916;
|
||||
})();
|
||||
var G__5913 = true;
|
||||
var G__5914 = null;
|
||||
var G__5915 = opts;
|
||||
return (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(G__5912,G__5913,G__5914,G__5915) : cljs.tools.reader.edn.read.call(null,G__5912,G__5913,G__5914,G__5915));
|
||||
})();
|
||||
var G__5918 = (((!((o === rdr))))?cljs.core.conj_BANG_.cljs$core$IFn$_invoke$arity$2(a,o):a);
|
||||
a = G__5918;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_list = (function cljs$tools$reader$edn$read_list(rdr,_,opts){
|
||||
var the_list = cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$list,")",rdr,opts);
|
||||
if(cljs.core.empty_QMARK_(the_list)){
|
||||
return cljs.core.List.EMPTY;
|
||||
} else {
|
||||
return cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.list,the_list);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_vector = (function cljs$tools$reader$edn$read_vector(rdr,_,opts){
|
||||
return cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$vector,"]",rdr,opts);
|
||||
});
|
||||
cljs.tools.reader.edn.read_map = (function cljs$tools$reader$edn$read_map(rdr,_,opts){
|
||||
var vec__5919 = cljs.tools.reader.edn.starting_line_col_info(rdr);
|
||||
var start_line = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5919,(0),null);
|
||||
var start_column = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5919,(1),null);
|
||||
var the_map = cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$map,"}",rdr,opts);
|
||||
var map_count = cljs.core.count(the_map);
|
||||
var ks = cljs.core.take_nth.cljs$core$IFn$_invoke$arity$2((2),the_map);
|
||||
var key_set = cljs.core.set(ks);
|
||||
if(cljs.core.odd_QMARK_(map_count)){
|
||||
cljs.tools.reader.impl.errors.throw_odd_map(rdr,start_line,start_column,the_map);
|
||||
} else {
|
||||
}
|
||||
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.count(key_set),cljs.core.count(ks))){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys(rdr,cljs.core.cst$kw$map,ks);
|
||||
}
|
||||
|
||||
if((map_count <= ((2) * cljs.core.PersistentArrayMap.HASHMAP_THRESHOLD))){
|
||||
return cljs.core.PersistentArrayMap.fromArray(cljs.core.to_array(the_map),true,true);
|
||||
} else {
|
||||
return cljs.core.PersistentHashMap.fromArray(cljs.core.to_array(the_map),true);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_number = (function cljs$tools$reader$edn$read_number(rdr,initch,opts){
|
||||
var sb = (function (){var G__5922 = (new goog.string.StringBuffer());
|
||||
G__5922.append(initch);
|
||||
|
||||
return G__5922;
|
||||
})();
|
||||
var ch = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
while(true){
|
||||
if(cljs.core.truth_((function (){var or__5045__auto__ = cljs.tools.reader.impl.utils.whitespace_QMARK_(ch);
|
||||
if(or__5045__auto__){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
var or__5045__auto____$1 = (cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.edn.macros.cljs$core$IFn$_invoke$arity$1(ch) : cljs.tools.reader.edn.macros.call(null,ch));
|
||||
if(cljs.core.truth_(or__5045__auto____$1)){
|
||||
return or__5045__auto____$1;
|
||||
} else {
|
||||
return (ch == null);
|
||||
}
|
||||
}
|
||||
})())){
|
||||
var s = cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
|
||||
cljs.tools.reader.reader_types.unread(rdr,ch);
|
||||
|
||||
var or__5045__auto__ = cljs.tools.reader.impl.commons.match_number(s);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_number(rdr,s);
|
||||
}
|
||||
} else {
|
||||
var G__5924 = (function (){var G__5923 = sb;
|
||||
G__5923.append(ch);
|
||||
|
||||
return G__5923;
|
||||
})();
|
||||
var G__5925 = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
sb = G__5924;
|
||||
ch = G__5925;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.escape_char = (function cljs$tools$reader$edn$escape_char(sb,rdr){
|
||||
var ch = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
var G__5926 = ch;
|
||||
switch (G__5926) {
|
||||
case "t":
|
||||
return "\t";
|
||||
|
||||
break;
|
||||
case "r":
|
||||
return "\r";
|
||||
|
||||
break;
|
||||
case "n":
|
||||
return "\n";
|
||||
|
||||
break;
|
||||
case "\\":
|
||||
return "\\";
|
||||
|
||||
break;
|
||||
case "\"":
|
||||
return "\"";
|
||||
|
||||
break;
|
||||
case "b":
|
||||
return "\b";
|
||||
|
||||
break;
|
||||
case "f":
|
||||
return "\f";
|
||||
|
||||
break;
|
||||
case "u":
|
||||
var ch__$1 = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
if(((-1) === parseInt((ch__$1 | (0)),(16)))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid_unicode_escape(rdr,ch__$1);
|
||||
} else {
|
||||
return cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5(rdr,ch__$1,(16),(4),true);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
if(cljs.tools.reader.impl.utils.numeric_QMARK_(ch)){
|
||||
var ch__$1 = cljs.tools.reader.edn.read_unicode_char.cljs$core$IFn$_invoke$arity$5(rdr,ch,(8),(3),false);
|
||||
if(((ch__$1 | (0)) > (255))){
|
||||
return cljs.tools.reader.impl.errors.throw_bad_octal_number(rdr);
|
||||
} else {
|
||||
return ch__$1;
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_bad_escape_char(rdr,ch);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_string_STAR_ = (function cljs$tools$reader$edn$read_string_STAR_(rdr,_,opts){
|
||||
var sb = (new goog.string.StringBuffer());
|
||||
var ch = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
while(true){
|
||||
var G__5928 = ch;
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(null,G__5928)){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_reading.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.cst$kw$string,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["\"",sb], 0));
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("\\",G__5928)){
|
||||
var G__5931 = (function (){var G__5929 = sb;
|
||||
G__5929.append(cljs.tools.reader.edn.escape_char(sb,rdr));
|
||||
|
||||
return G__5929;
|
||||
})();
|
||||
var G__5932 = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
sb = G__5931;
|
||||
ch = G__5932;
|
||||
continue;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("\"",G__5928)){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(sb);
|
||||
} else {
|
||||
var G__5933 = (function (){var G__5930 = sb;
|
||||
G__5930.append(ch);
|
||||
|
||||
return G__5930;
|
||||
})();
|
||||
var G__5934 = cljs.tools.reader.reader_types.read_char(rdr);
|
||||
sb = G__5933;
|
||||
ch = G__5934;
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_symbol = (function cljs$tools$reader$edn$read_symbol(rdr,initch){
|
||||
var temp__4657__auto__ = cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3(rdr,cljs.core.cst$kw$symbol,initch);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var token = temp__4657__auto__;
|
||||
var G__5935 = token;
|
||||
switch (G__5935) {
|
||||
case "nil":
|
||||
return null;
|
||||
|
||||
break;
|
||||
case "true":
|
||||
return true;
|
||||
|
||||
break;
|
||||
case "false":
|
||||
return false;
|
||||
|
||||
break;
|
||||
case "/":
|
||||
return cljs.core.cst$sym$_SLASH_;
|
||||
|
||||
break;
|
||||
default:
|
||||
var or__5045__auto__ = (function (){var temp__4657__auto____$1 = cljs.tools.reader.impl.commons.parse_symbol(token);
|
||||
if(cljs.core.truth_(temp__4657__auto____$1)){
|
||||
var p = temp__4657__auto____$1;
|
||||
return cljs.core.symbol.cljs$core$IFn$_invoke$arity$2((p.cljs$core$IFn$_invoke$arity$1 ? p.cljs$core$IFn$_invoke$arity$1((0)) : p.call(null,(0))),(p.cljs$core$IFn$_invoke$arity$1 ? p.cljs$core$IFn$_invoke$arity$1((1)) : p.call(null,(1))));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_invalid(rdr,cljs.core.cst$kw$symbol,token);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_keyword = (function cljs$tools$reader$edn$read_keyword(reader,initch,opts){
|
||||
var ch = cljs.tools.reader.reader_types.read_char(reader);
|
||||
if((!(cljs.tools.reader.impl.utils.whitespace_QMARK_(ch)))){
|
||||
var token = cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3(reader,cljs.core.cst$kw$keyword,ch);
|
||||
var s = cljs.tools.reader.impl.commons.parse_symbol(token);
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = s;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return ((-1) === token.indexOf("::"));
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
var ns = (s.cljs$core$IFn$_invoke$arity$1 ? s.cljs$core$IFn$_invoke$arity$1((0)) : s.call(null,(0)));
|
||||
var name = (s.cljs$core$IFn$_invoke$arity$1 ? s.cljs$core$IFn$_invoke$arity$1((1)) : s.call(null,(1)));
|
||||
if((":" === cljs.core.nth.cljs$core$IFn$_invoke$arity$2(token,(0)))){
|
||||
return cljs.tools.reader.impl.errors.throw_invalid(reader,cljs.core.cst$kw$keyword,[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(token)].join(''));
|
||||
} else {
|
||||
return cljs.core.keyword.cljs$core$IFn$_invoke$arity$2(ns,name);
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_invalid(reader,cljs.core.cst$kw$keyword,[":",cljs.core.str.cljs$core$IFn$_invoke$arity$1(token)].join(''));
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_single_colon(reader);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.wrapping_reader = (function cljs$tools$reader$edn$wrapping_reader(sym){
|
||||
return (function (rdr,_,opts){
|
||||
return (new cljs.core.List(null,sym,(new cljs.core.List(null,(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts)),null,(1),null)),(2),null));
|
||||
});
|
||||
});
|
||||
cljs.tools.reader.edn.read_meta = (function cljs$tools$reader$edn$read_meta(rdr,_,opts){
|
||||
var m = cljs.tools.reader.impl.utils.desugar_meta((cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts)));
|
||||
if(cljs.core.map_QMARK_(m)){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_bad_metadata(rdr,m);
|
||||
}
|
||||
|
||||
var o = (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
|
||||
if((((!((o == null))))?(((((o.cljs$lang$protocol_mask$partition0$ & (131072))) || ((cljs.core.PROTOCOL_SENTINEL === o.cljs$core$IMeta$))))?true:false):false)){
|
||||
return cljs.core.with_meta(o,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.meta(o),m], 0)));
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_bad_metadata_target(rdr,o);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_set = (function cljs$tools$reader$edn$read_set(rdr,_,opts){
|
||||
var coll = cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$set,"}",rdr,opts);
|
||||
var the_set = cljs.core.set(coll);
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.count(coll),cljs.core.count(the_set))){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys(rdr,cljs.core.cst$kw$set,coll);
|
||||
}
|
||||
|
||||
return the_set;
|
||||
});
|
||||
cljs.tools.reader.edn.read_discard = (function cljs$tools$reader$edn$read_discard(rdr,_,opts){
|
||||
var G__5938 = rdr;
|
||||
(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(G__5938,true,null,true) : cljs.tools.reader.edn.read.call(null,G__5938,true,null,true));
|
||||
|
||||
return G__5938;
|
||||
});
|
||||
cljs.tools.reader.edn.read_namespaced_map = (function cljs$tools$reader$edn$read_namespaced_map(rdr,_,opts){
|
||||
var token = cljs.tools.reader.edn.read_token.cljs$core$IFn$_invoke$arity$3(rdr,cljs.core.cst$kw$namespaced_DASH_map,cljs.tools.reader.reader_types.read_char(rdr));
|
||||
var temp__4655__auto__ = (function (){var G__5939 = token;
|
||||
var G__5939__$1 = (((G__5939 == null))?null:cljs.tools.reader.impl.commons.parse_symbol(G__5939));
|
||||
if((G__5939__$1 == null)){
|
||||
return null;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.utils.second_SINGLEQUOTE_(G__5939__$1);
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var ns = temp__4655__auto__;
|
||||
var ch = cljs.tools.reader.impl.commons.read_past(cljs.tools.reader.impl.utils.whitespace_QMARK_,rdr);
|
||||
if((ch === "{")){
|
||||
var items = cljs.tools.reader.edn.read_delimited(cljs.core.cst$kw$namespaced_DASH_map,"}",rdr,opts);
|
||||
if(cljs.core.odd_QMARK_(cljs.core.count(items))){
|
||||
cljs.tools.reader.impl.errors.throw_odd_map(rdr,null,null,items);
|
||||
} else {
|
||||
}
|
||||
|
||||
var keys = cljs.tools.reader.impl.utils.namespace_keys(cljs.core.str.cljs$core$IFn$_invoke$arity$1(ns),cljs.core.take_nth.cljs$core$IFn$_invoke$arity$2((2),items));
|
||||
var vals = cljs.core.take_nth.cljs$core$IFn$_invoke$arity$2((2),cljs.core.rest(items));
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.count(cljs.core.set(keys)),cljs.core.count(keys))){
|
||||
} else {
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys(rdr,cljs.core.cst$kw$namespaced_DASH_map,keys);
|
||||
}
|
||||
|
||||
return cljs.core.zipmap(keys,vals);
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_ns_map_no_map(rdr,token);
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_bad_ns(rdr,token);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_symbolic_value = (function cljs$tools$reader$edn$read_symbolic_value(rdr,_,opts){
|
||||
var sym = (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
|
||||
var G__5940 = sym;
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$sym$NaN,G__5940)){
|
||||
return Number.NaN;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$sym$_DASH_Inf,G__5940)){
|
||||
return Number.NEGATIVE_INFINITY;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$sym$Inf,G__5940)){
|
||||
return Number.POSITIVE_INFINITY;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([["Invalid token: ##",cljs.core.str.cljs$core$IFn$_invoke$arity$1(sym)].join('')], 0));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.macros = (function cljs$tools$reader$edn$macros(ch){
|
||||
var G__5941 = ch;
|
||||
switch (G__5941) {
|
||||
case "\"":
|
||||
return cljs.tools.reader.edn.read_string_STAR_;
|
||||
|
||||
break;
|
||||
case ":":
|
||||
return cljs.tools.reader.edn.read_keyword;
|
||||
|
||||
break;
|
||||
case ";":
|
||||
return cljs.tools.reader.impl.commons.read_comment;
|
||||
|
||||
break;
|
||||
case "^":
|
||||
return cljs.tools.reader.edn.read_meta;
|
||||
|
||||
break;
|
||||
case "(":
|
||||
return cljs.tools.reader.edn.read_list;
|
||||
|
||||
break;
|
||||
case ")":
|
||||
return cljs.tools.reader.edn.read_unmatched_delimiter;
|
||||
|
||||
break;
|
||||
case "[":
|
||||
return cljs.tools.reader.edn.read_vector;
|
||||
|
||||
break;
|
||||
case "]":
|
||||
return cljs.tools.reader.edn.read_unmatched_delimiter;
|
||||
|
||||
break;
|
||||
case "{":
|
||||
return cljs.tools.reader.edn.read_map;
|
||||
|
||||
break;
|
||||
case "}":
|
||||
return cljs.tools.reader.edn.read_unmatched_delimiter;
|
||||
|
||||
break;
|
||||
case "\\":
|
||||
return cljs.tools.reader.edn.read_char_STAR_;
|
||||
|
||||
break;
|
||||
case "#":
|
||||
return cljs.tools.reader.edn.read_dispatch;
|
||||
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.dispatch_macros = (function cljs$tools$reader$edn$dispatch_macros(ch){
|
||||
var G__5943 = ch;
|
||||
switch (G__5943) {
|
||||
case "^":
|
||||
return cljs.tools.reader.edn.read_meta;
|
||||
|
||||
break;
|
||||
case "{":
|
||||
return cljs.tools.reader.edn.read_set;
|
||||
|
||||
break;
|
||||
case "<":
|
||||
return cljs.tools.reader.impl.commons.throwing_reader("Unreadable form");
|
||||
|
||||
break;
|
||||
case "!":
|
||||
return cljs.tools.reader.impl.commons.read_comment;
|
||||
|
||||
break;
|
||||
case "_":
|
||||
return cljs.tools.reader.edn.read_discard;
|
||||
|
||||
break;
|
||||
case ":":
|
||||
return cljs.tools.reader.edn.read_namespaced_map;
|
||||
|
||||
break;
|
||||
case "#":
|
||||
return cljs.tools.reader.edn.read_symbolic_value;
|
||||
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.edn.read_tagged = (function cljs$tools$reader$edn$read_tagged(rdr,initch,opts){
|
||||
var tag = (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
|
||||
var object = (cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 ? cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(rdr,true,null,opts) : cljs.tools.reader.edn.read.call(null,rdr,true,null,opts));
|
||||
if((!((tag instanceof cljs.core.Symbol)))){
|
||||
cljs.tools.reader.impl.errors.throw_bad_reader_tag(rdr,"Reader tag must be a symbol");
|
||||
} else {
|
||||
}
|
||||
|
||||
var temp__4655__auto__ = (function (){var or__5045__auto__ = cljs.core.get.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$kw$readers.cljs$core$IFn$_invoke$arity$1(opts),tag);
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return (cljs.tools.reader.default_data_readers.cljs$core$IFn$_invoke$arity$1 ? cljs.tools.reader.default_data_readers.cljs$core$IFn$_invoke$arity$1(tag) : cljs.tools.reader.default_data_readers.call(null,tag));
|
||||
}
|
||||
})();
|
||||
if(cljs.core.truth_(temp__4655__auto__)){
|
||||
var f = temp__4655__auto__;
|
||||
return (f.cljs$core$IFn$_invoke$arity$1 ? f.cljs$core$IFn$_invoke$arity$1(object) : f.call(null,object));
|
||||
} else {
|
||||
var temp__4655__auto____$1 = cljs.core.cst$kw$default.cljs$core$IFn$_invoke$arity$1(opts);
|
||||
if(cljs.core.truth_(temp__4655__auto____$1)){
|
||||
var d = temp__4655__auto____$1;
|
||||
return (d.cljs$core$IFn$_invoke$arity$2 ? d.cljs$core$IFn$_invoke$arity$2(tag,object) : d.call(null,tag,object));
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.throw_unknown_reader_tag(rdr,tag);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Reads the first object from an IPushbackReader.
|
||||
* Returns the object read. If EOF, throws if eof-error? is true otherwise returns eof.
|
||||
* If no reader is provided, *in* will be used.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* cljs.tools.reader.edn/read doesn't depend on dynamic Vars, all configuration
|
||||
* is done by passing an opt map.
|
||||
*
|
||||
* opts is a map that can include the following keys:
|
||||
* :eof - value to return on end-of-file. When not supplied, eof throws an exception.
|
||||
* :readers - a map of tag symbols to data-reader functions to be considered before default-data-readers.
|
||||
* When not supplied, only the default-data-readers will be used.
|
||||
* :default - A function of two args, that will, if present and no reader is found for a tag,
|
||||
* be called with the tag and the value.
|
||||
*/
|
||||
cljs.tools.reader.edn.read = (function cljs$tools$reader$edn$read(var_args){
|
||||
var G__5946 = arguments.length;
|
||||
switch (G__5946) {
|
||||
case 1:
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 4:
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$1 = (function (reader){
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,reader);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2 = (function (p__5947,reader){
|
||||
var map__5948 = p__5947;
|
||||
var map__5948__$1 = cljs.core.__destructure_map(map__5948);
|
||||
var opts = map__5948__$1;
|
||||
var eof = cljs.core.get.cljs$core$IFn$_invoke$arity$2(map__5948__$1,cljs.core.cst$kw$eof);
|
||||
var eof_error_QMARK_ = (!(cljs.core.contains_QMARK_(opts,cljs.core.cst$kw$eof)));
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4(reader,eof_error_QMARK_,eof,opts);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$4 = (function (reader,eof_error_QMARK_,eof,opts){
|
||||
try{while(true){
|
||||
var ch = cljs.tools.reader.reader_types.read_char(reader);
|
||||
if(cljs.tools.reader.impl.utils.whitespace_QMARK_(ch)){
|
||||
continue;
|
||||
} else {
|
||||
if((ch == null)){
|
||||
if(cljs.core.truth_(eof_error_QMARK_)){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_error(reader,null);
|
||||
} else {
|
||||
return eof;
|
||||
}
|
||||
} else {
|
||||
if(cljs.tools.reader.impl.commons.number_literal_QMARK_(reader,ch)){
|
||||
return cljs.tools.reader.edn.read_number(reader,ch,opts);
|
||||
} else {
|
||||
var f = cljs.tools.reader.edn.macros(ch);
|
||||
if(cljs.core.truth_(f)){
|
||||
var res = (f.cljs$core$IFn$_invoke$arity$3 ? f.cljs$core$IFn$_invoke$arity$3(reader,ch,opts) : f.call(null,reader,ch,opts));
|
||||
if((res === reader)){
|
||||
continue;
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
return cljs.tools.reader.edn.read_symbol(reader,ch);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}catch (e5949){if((e5949 instanceof Error)){
|
||||
var e = e5949;
|
||||
if(cljs.tools.reader.impl.utils.ex_info_QMARK_(e)){
|
||||
var d = cljs.core.ex_data(e);
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(cljs.core.cst$kw$reader_DASH_exception,cljs.core.cst$kw$type.cljs$core$IFn$_invoke$arity$1(d))){
|
||||
throw e;
|
||||
} else {
|
||||
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3(e.message,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$type,cljs.core.cst$kw$reader_DASH_exception], null),d,((cljs.tools.reader.reader_types.indexing_reader_QMARK_(reader))?new cljs.core.PersistentArrayMap(null, 3, [cljs.core.cst$kw$line,cljs.tools.reader.reader_types.get_line_number(reader),cljs.core.cst$kw$column,cljs.tools.reader.reader_types.get_column_number(reader),cljs.core.cst$kw$file,cljs.tools.reader.reader_types.get_file_name(reader)], null):null)], 0)),e);
|
||||
}
|
||||
} else {
|
||||
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$3(e.message,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$type,cljs.core.cst$kw$reader_DASH_exception], null),((cljs.tools.reader.reader_types.indexing_reader_QMARK_(reader))?new cljs.core.PersistentArrayMap(null, 3, [cljs.core.cst$kw$line,cljs.tools.reader.reader_types.get_line_number(reader),cljs.core.cst$kw$column,cljs.tools.reader.reader_types.get_column_number(reader),cljs.core.cst$kw$file,cljs.tools.reader.reader_types.get_file_name(reader)], null):null)], 0)),e);
|
||||
}
|
||||
} else {
|
||||
throw e5949;
|
||||
|
||||
}
|
||||
}}));
|
||||
|
||||
(cljs.tools.reader.edn.read.cljs$lang$maxFixedArity = 4);
|
||||
|
||||
/**
|
||||
* Reads one object from the string s.
|
||||
* Returns nil when s is nil or empty.
|
||||
*
|
||||
* Reads data in the edn format (subset of Clojure data):
|
||||
* http://edn-format.org
|
||||
*
|
||||
* opts is a map as per cljs.tools.reader.edn/read
|
||||
*/
|
||||
cljs.tools.reader.edn.read_string = (function cljs$tools$reader$edn$read_string(var_args){
|
||||
var G__5952 = arguments.length;
|
||||
switch (G__5952) {
|
||||
case 1:
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$1 = (function (s){
|
||||
return cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$eof,null], null),s);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_string.cljs$core$IFn$_invoke$arity$2 = (function (opts,s){
|
||||
if(cljs.core.truth_((function (){var and__5043__auto__ = s;
|
||||
if(cljs.core.truth_(and__5043__auto__)){
|
||||
return cljs.core.not_EQ_.cljs$core$IFn$_invoke$arity$2(s,"");
|
||||
} else {
|
||||
return and__5043__auto__;
|
||||
}
|
||||
})())){
|
||||
return cljs.tools.reader.edn.read.cljs$core$IFn$_invoke$arity$2(opts,cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$1(s));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.edn.read_string.cljs$lang$maxFixedArity = 2);
|
||||
|
||||
Executable
+131
@@ -0,0 +1,131 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.tools.reader.impl.commons
|
||||
(:refer-clojure :exclude [char])
|
||||
(:require
|
||||
[cljs.tools.reader.impl.errors :refer [reader-error]]
|
||||
[cljs.tools.reader.reader-types :refer [peek-char read-char]]
|
||||
[cljs.tools.reader.impl.utils :refer [numeric? newline? char]]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn ^boolean number-literal?
|
||||
"Checks whether the reader is at the start of a number literal"
|
||||
[^not-native reader initch]
|
||||
(or (numeric? initch)
|
||||
(and (or (identical? \+ initch) (identical? \- initch))
|
||||
(numeric? (peek-char reader)))))
|
||||
|
||||
(defn read-past
|
||||
"Read until first character that doesn't match pred, returning
|
||||
char."
|
||||
[pred ^not-native rdr]
|
||||
(loop [ch (read-char rdr)]
|
||||
(if ^boolean (pred ch)
|
||||
(recur (read-char rdr))
|
||||
ch)))
|
||||
|
||||
(defn skip-line
|
||||
"Advances the reader to the end of a line. Returns the reader"
|
||||
[^not-native reader]
|
||||
(loop []
|
||||
(when-not (newline? (read-char reader))
|
||||
(recur)))
|
||||
reader)
|
||||
|
||||
(def int-pattern #"^([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?$")
|
||||
(def ratio-pattern #"([-+]?[0-9]+)/([0-9]+)")
|
||||
(def float-pattern #"([-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?")
|
||||
|
||||
(defn- match-int
|
||||
[s]
|
||||
(let [m (vec (re-find int-pattern s))]
|
||||
(if-not (nil? (m 2))
|
||||
0
|
||||
(let [^boolean negate? (identical? "-" (m 1))
|
||||
a (cond
|
||||
(not (nil? (m 3))) [(m 3) 10]
|
||||
(not (nil? (m 4))) [(m 4) 16]
|
||||
(not (nil? (m 5))) [(m 5) 8]
|
||||
(not (nil? (m 7))) [(m 7) (js/parseInt (m 6))]
|
||||
:else [nil nil])
|
||||
n (a 0)]
|
||||
(when-not (nil? n)
|
||||
(let [bn (js/parseInt n (a 1))
|
||||
bn (if negate? (* -1 bn) bn)]
|
||||
(when-not (js/isNaN bn)
|
||||
bn)))))))
|
||||
|
||||
(defn- match-ratio
|
||||
[s]
|
||||
(let [m (vec (re-find ratio-pattern s))
|
||||
numerator (m 1)
|
||||
denominator (m 2)
|
||||
numerator (if (re-find #"^\+" numerator)
|
||||
(subs numerator 1)
|
||||
numerator)]
|
||||
(/ (-> numerator js/parseInt) ;;; No ratio type in cljs
|
||||
(-> denominator js/parseInt)))); So will convert to js/Number
|
||||
|
||||
(defn- match-float
|
||||
[s]
|
||||
(let [m (vec (re-find float-pattern s))]
|
||||
(if-not (nil? (m 4)) ;; for BigDecimal "10.03M", as all parsed to js/Number
|
||||
(js/parseFloat (m 1))
|
||||
(js/parseFloat s))))
|
||||
|
||||
(defn ^boolean matches? [pattern s]
|
||||
(let [[match] (re-find pattern s)]
|
||||
(identical? match s)))
|
||||
|
||||
(defn match-number [s]
|
||||
(if (matches? int-pattern s)
|
||||
(match-int s)
|
||||
(if (matches? float-pattern s)
|
||||
(match-float s)
|
||||
(when (matches? ratio-pattern s)
|
||||
(match-ratio s)))))
|
||||
|
||||
(defn parse-symbol
|
||||
"Parses a string into a vector of the namespace and symbol"
|
||||
[token]
|
||||
(when-not (or (identical? "" token)
|
||||
(true? (.test #":$" token))
|
||||
(true? (.test #"^::" token)))
|
||||
(let [ns-idx (.indexOf token "/")
|
||||
ns (when (pos? ns-idx)
|
||||
(subs token 0 ns-idx))]
|
||||
(if-not (nil? ns)
|
||||
(let [ns-idx (inc ns-idx)]
|
||||
(when-not (== ns-idx (count token))
|
||||
(let [sym (subs token ns-idx)]
|
||||
(when (and (not (numeric? (nth sym 0)))
|
||||
(not (identical? "" sym))
|
||||
(false? (.test #":$" ns))
|
||||
(or (identical? sym "/")
|
||||
(== -1 (.indexOf sym "/"))))
|
||||
[ns sym]))))
|
||||
(when (or (identical? token "/")
|
||||
(== -1 (.indexOf token "/")))
|
||||
[nil token])))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; readers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn read-comment
|
||||
[rdr & _]
|
||||
(skip-line rdr))
|
||||
|
||||
(defn throwing-reader
|
||||
[msg]
|
||||
(fn [rdr & _]
|
||||
(reader-error rdr msg)))
|
||||
Executable
+192
@@ -0,0 +1,192 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.impl.commons');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('cljs.tools.reader.impl.errors');
|
||||
goog.require('cljs.tools.reader.reader_types');
|
||||
goog.require('cljs.tools.reader.impl.utils');
|
||||
/**
|
||||
* Checks whether the reader is at the start of a number literal
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.number_literal_QMARK_ = (function cljs$tools$reader$impl$commons$number_literal_QMARK_(reader,initch){
|
||||
return ((cljs.tools.reader.impl.utils.numeric_QMARK_(initch)) || (((((("+" === initch)) || (("-" === initch)))) && (cljs.tools.reader.impl.utils.numeric_QMARK_(reader.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null))))));
|
||||
});
|
||||
/**
|
||||
* Read until first character that doesn't match pred, returning
|
||||
* char.
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.read_past = (function cljs$tools$reader$impl$commons$read_past(pred,rdr){
|
||||
var ch = rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
while(true){
|
||||
if((pred.cljs$core$IFn$_invoke$arity$1 ? pred.cljs$core$IFn$_invoke$arity$1(ch) : pred.call(null,ch))){
|
||||
var G__5357 = rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
ch = G__5357;
|
||||
continue;
|
||||
} else {
|
||||
return ch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Advances the reader to the end of a line. Returns the reader
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.skip_line = (function cljs$tools$reader$impl$commons$skip_line(reader){
|
||||
while(true){
|
||||
if(cljs.tools.reader.impl.utils.newline_QMARK_(reader.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null))){
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return reader;
|
||||
});
|
||||
cljs.tools.reader.impl.commons.int_pattern = /^([-+]?)(?:(0)|([1-9][0-9]*)|0[xX]([0-9A-Fa-f]+)|0([0-7]+)|([1-9][0-9]?)[rR]([0-9A-Za-z]+)|0[0-9]+)(N)?$/;
|
||||
cljs.tools.reader.impl.commons.ratio_pattern = /([-+]?[0-9]+)\/([0-9]+)/;
|
||||
cljs.tools.reader.impl.commons.float_pattern = /([-+]?[0-9]+(\.[0-9]*)?([eE][-+]?[0-9]+)?)(M)?/;
|
||||
cljs.tools.reader.impl.commons.match_int = (function cljs$tools$reader$impl$commons$match_int(s){
|
||||
var m = cljs.core.vec(cljs.core.re_find(cljs.tools.reader.impl.commons.int_pattern,s));
|
||||
if((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((2)) : m.call(null,(2))) == null)))){
|
||||
return (0);
|
||||
} else {
|
||||
var negate_QMARK_ = ("-" === (m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((1)) : m.call(null,(1))));
|
||||
var a = (((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((3)) : m.call(null,(3))) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((3)) : m.call(null,(3))),(10)], null):(((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((4)) : m.call(null,(4))) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((4)) : m.call(null,(4))),(16)], null):(((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((5)) : m.call(null,(5))) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((5)) : m.call(null,(5))),(8)], null):(((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((7)) : m.call(null,(7))) == null))))?new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((7)) : m.call(null,(7))),parseInt((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((6)) : m.call(null,(6))))], null):new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,null], null)
|
||||
))));
|
||||
var n = (a.cljs$core$IFn$_invoke$arity$1 ? a.cljs$core$IFn$_invoke$arity$1((0)) : a.call(null,(0)));
|
||||
if((n == null)){
|
||||
return null;
|
||||
} else {
|
||||
var bn = parseInt(n,(a.cljs$core$IFn$_invoke$arity$1 ? a.cljs$core$IFn$_invoke$arity$1((1)) : a.call(null,(1))));
|
||||
var bn__$1 = ((negate_QMARK_)?((-1) * bn):bn);
|
||||
if(cljs.core.truth_(isNaN(bn__$1))){
|
||||
return null;
|
||||
} else {
|
||||
return bn__$1;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.commons.match_ratio = (function cljs$tools$reader$impl$commons$match_ratio(s){
|
||||
var m = cljs.core.vec(cljs.core.re_find(cljs.tools.reader.impl.commons.ratio_pattern,s));
|
||||
var numerator = (m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((1)) : m.call(null,(1)));
|
||||
var denominator = (m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((2)) : m.call(null,(2)));
|
||||
var numerator__$1 = (cljs.core.truth_(cljs.core.re_find(/^\+/,numerator))?cljs.core.subs.cljs$core$IFn$_invoke$arity$2(numerator,(1)):numerator);
|
||||
return (parseInt(numerator__$1) / parseInt(denominator));
|
||||
});
|
||||
cljs.tools.reader.impl.commons.match_float = (function cljs$tools$reader$impl$commons$match_float(s){
|
||||
var m = cljs.core.vec(cljs.core.re_find(cljs.tools.reader.impl.commons.float_pattern,s));
|
||||
if((!(((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((4)) : m.call(null,(4))) == null)))){
|
||||
return parseFloat((m.cljs$core$IFn$_invoke$arity$1 ? m.cljs$core$IFn$_invoke$arity$1((1)) : m.call(null,(1))));
|
||||
} else {
|
||||
return parseFloat(s);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.commons.matches_QMARK_ = (function cljs$tools$reader$impl$commons$matches_QMARK_(pattern,s){
|
||||
var vec__5358 = cljs.core.re_find(pattern,s);
|
||||
var match = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5358,(0),null);
|
||||
return (match === s);
|
||||
});
|
||||
cljs.tools.reader.impl.commons.match_number = (function cljs$tools$reader$impl$commons$match_number(s){
|
||||
if(cljs.tools.reader.impl.commons.matches_QMARK_(cljs.tools.reader.impl.commons.int_pattern,s)){
|
||||
return cljs.tools.reader.impl.commons.match_int(s);
|
||||
} else {
|
||||
if(cljs.tools.reader.impl.commons.matches_QMARK_(cljs.tools.reader.impl.commons.float_pattern,s)){
|
||||
return cljs.tools.reader.impl.commons.match_float(s);
|
||||
} else {
|
||||
if(cljs.tools.reader.impl.commons.matches_QMARK_(cljs.tools.reader.impl.commons.ratio_pattern,s)){
|
||||
return cljs.tools.reader.impl.commons.match_ratio(s);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Parses a string into a vector of the namespace and symbol
|
||||
*/
|
||||
cljs.tools.reader.impl.commons.parse_symbol = (function cljs$tools$reader$impl$commons$parse_symbol(token){
|
||||
if(((("" === token)) || (((/:$/.test(token) === true) || (/^::/.test(token) === true))))){
|
||||
return null;
|
||||
} else {
|
||||
var ns_idx = token.indexOf("/");
|
||||
var ns = (((ns_idx > (0)))?cljs.core.subs.cljs$core$IFn$_invoke$arity$3(token,(0),ns_idx):null);
|
||||
if((!((ns == null)))){
|
||||
var ns_idx__$1 = (ns_idx + (1));
|
||||
if((ns_idx__$1 === cljs.core.count(token))){
|
||||
return null;
|
||||
} else {
|
||||
var sym = cljs.core.subs.cljs$core$IFn$_invoke$arity$2(token,ns_idx__$1);
|
||||
if((((!(cljs.tools.reader.impl.utils.numeric_QMARK_(cljs.core.nth.cljs$core$IFn$_invoke$arity$2(sym,(0)))))) && ((((!(("" === sym)))) && (((/:$/.test(ns) === false) && ((((sym === "/")) || (((-1) === sym.indexOf("/"))))))))))){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [ns,sym], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if((((token === "/")) || (((-1) === token.indexOf("/"))))){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [null,token], null);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.commons.read_comment = (function cljs$tools$reader$impl$commons$read_comment(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5363 = arguments.length;
|
||||
var i__5770__auto___5364 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5364 < len__5769__auto___5363)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5364]));
|
||||
|
||||
var G__5365 = (i__5770__auto___5364 + (1));
|
||||
i__5770__auto___5364 = G__5365;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((1) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.commons.read_comment.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.commons.read_comment.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,_){
|
||||
return cljs.tools.reader.impl.commons.skip_line(rdr);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.commons.read_comment.cljs$lang$maxFixedArity = (1));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.commons.read_comment.cljs$lang$applyTo = (function (seq5361){
|
||||
var G__5362 = cljs.core.first(seq5361);
|
||||
var seq5361__$1 = cljs.core.next(seq5361);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5362,seq5361__$1);
|
||||
}));
|
||||
|
||||
cljs.tools.reader.impl.commons.throwing_reader = (function cljs$tools$reader$impl$commons$throwing_reader(msg){
|
||||
return (function() {
|
||||
var G__5366__delegate = function (rdr,_){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([msg], 0));
|
||||
};
|
||||
var G__5366 = function (rdr,var_args){
|
||||
var _ = null;
|
||||
if (arguments.length > 1) {
|
||||
var G__5367__i = 0, G__5367__a = new Array(arguments.length - 1);
|
||||
while (G__5367__i < G__5367__a.length) {G__5367__a[G__5367__i] = arguments[G__5367__i + 1]; ++G__5367__i;}
|
||||
_ = new cljs.core.IndexedSeq(G__5367__a,0,null);
|
||||
}
|
||||
return G__5366__delegate.call(this,rdr,_);};
|
||||
G__5366.cljs$lang$maxFixedArity = 1;
|
||||
G__5366.cljs$lang$applyTo = (function (arglist__5368){
|
||||
var rdr = cljs.core.first(arglist__5368);
|
||||
var _ = cljs.core.rest(arglist__5368);
|
||||
return G__5366__delegate(rdr,_);
|
||||
});
|
||||
G__5366.cljs$core$IFn$_invoke$arity$variadic = G__5366__delegate;
|
||||
return G__5366;
|
||||
})()
|
||||
;
|
||||
});
|
||||
Executable
+247
@@ -0,0 +1,247 @@
|
||||
;; Copyright (c) Russ Olsen, Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.tools.reader.impl.errors
|
||||
(:require [cljs.tools.reader.reader-types :as types]
|
||||
[clojure.string :as s]
|
||||
[cljs.tools.reader.impl.inspect :as i]))
|
||||
|
||||
(defn- ex-details
|
||||
[rdr ex-type]
|
||||
(let [details {:type :reader-exception
|
||||
:ex-kind ex-type}]
|
||||
(if (types/indexing-reader? rdr)
|
||||
(assoc
|
||||
details
|
||||
:file (types/get-file-name rdr)
|
||||
:line (types/get-line-number rdr)
|
||||
:col (types/get-column-number rdr))
|
||||
details)))
|
||||
|
||||
(defn- throw-ex
|
||||
"Throw an ex-info error."
|
||||
[rdr ex-type & msg]
|
||||
(let [details (ex-details rdr ex-type)
|
||||
file (:file details)
|
||||
line (:line details)
|
||||
col (:col details)
|
||||
msg1 (if file (str file " "))
|
||||
msg2 (if line (str "[line " line ", col " col "]"))
|
||||
msg3 (if (or msg1 msg2) " ")
|
||||
full-msg (apply str msg1 msg2 msg3 msg)]
|
||||
(throw (ex-info full-msg details))))
|
||||
|
||||
(defn reader-error
|
||||
"Throws an ExceptionInfo with the given message.
|
||||
If rdr is an IndexingReader, additional information about column and line number is provided"
|
||||
[rdr & msgs]
|
||||
(throw-ex rdr :reader-error (apply str msgs)))
|
||||
|
||||
(defn illegal-arg-error
|
||||
"Throws an ExceptionInfo with the given message.
|
||||
If rdr is an IndexingReader, additional information about column and line number is provided"
|
||||
[rdr & msgs]
|
||||
(throw-ex rdr :illegal-argument (apply str msgs)))
|
||||
|
||||
(defn eof-error
|
||||
"Throws an ExceptionInfo with the given message.
|
||||
If rdr is an IndexingReader, additional information about column and line number is provided"
|
||||
[rdr & msgs]
|
||||
(throw-ex rdr :eof (apply str msgs)))
|
||||
|
||||
(defn throw-eof-delimited
|
||||
([rdr kind column line] (throw-eof-delimited rdr kind line column nil))
|
||||
([rdr kind line column n]
|
||||
(eof-error
|
||||
rdr
|
||||
"Unexpected EOF while reading "
|
||||
(if n
|
||||
(str "item " n " of "))
|
||||
(name kind)
|
||||
(if line
|
||||
(str ", starting at line " line " and column " column))
|
||||
".")))
|
||||
|
||||
(defn throw-odd-map [rdr line col elements]
|
||||
(reader-error
|
||||
rdr
|
||||
"The map literal starting with "
|
||||
(i/inspect (first elements))
|
||||
(if line (str " on line " line " column " col))
|
||||
" contains "
|
||||
(count elements)
|
||||
" form(s). Map literals must contain an even number of forms."))
|
||||
|
||||
(defn throw-invalid-number [rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid number: "
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-invalid-unicode-literal [rdr token]
|
||||
(throw
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid unicode literal: \\"
|
||||
token
|
||||
".")))
|
||||
|
||||
(defn throw-invalid-unicode-escape [rdr ch]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid unicode escape: \\u"
|
||||
ch
|
||||
"."))
|
||||
|
||||
(defn throw-invalid [rdr kind token]
|
||||
(reader-error rdr "Invalid " (name kind) ": " token "."))
|
||||
|
||||
(defn throw-eof-at-start [rdr kind]
|
||||
(eof-error rdr "Unexpected EOF while reading start of " (name kind) "."))
|
||||
|
||||
(defn throw-bad-char [rdr kind ch]
|
||||
(reader-error rdr "Invalid character: " ch " found while reading " (name kind) "."))
|
||||
|
||||
(defn throw-eof-at-dispatch [rdr]
|
||||
(eof-error rdr "Unexpected EOF while reading dispatch character."))
|
||||
|
||||
(defn throw-unmatch-delimiter [rdr ch]
|
||||
(reader-error rdr "Unmatched delimiter " ch "."))
|
||||
|
||||
(defn throw-eof-reading [rdr kind & start]
|
||||
(let [init (case kind :regex "#\"" :string \")]
|
||||
(eof-error rdr "Unexpected EOF reading " (name kind) " starting " (apply str init start) ".")))
|
||||
|
||||
(defn throw-invalid-unicode-char[rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid unicode character \\"
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-invalid-unicode-digit-in-token[rdr ch token]
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid digit "
|
||||
ch
|
||||
" in unicode character \\"
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-invalid-unicode-digit[rdr ch]
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid digit "
|
||||
ch
|
||||
" in unicode character."))
|
||||
|
||||
(defn throw-invalid-unicode-len[rdr actual expected]
|
||||
(illegal-arg-error
|
||||
rdr
|
||||
"Invalid unicode literal. Unicode literals should be "
|
||||
expected
|
||||
"characters long. "
|
||||
"Value supplied is "
|
||||
actual
|
||||
" characters long."))
|
||||
|
||||
(defn throw-invalid-character-literal[rdr token]
|
||||
(reader-error rdr "Invalid character literal \\u" token "."))
|
||||
|
||||
(defn throw-invalid-octal-len[rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid octal escape sequence in a character literal: "
|
||||
token
|
||||
". Octal escape sequences must be 3 or fewer digits."))
|
||||
|
||||
(defn throw-bad-octal-number [rdr]
|
||||
(reader-error rdr "Octal escape sequence must be in range [0, 377]."))
|
||||
|
||||
(defn throw-unsupported-character[rdr token]
|
||||
(reader-error
|
||||
rdr
|
||||
"Unsupported character: "
|
||||
token
|
||||
"."))
|
||||
|
||||
(defn throw-eof-in-character [rdr]
|
||||
(eof-error
|
||||
rdr
|
||||
"Unexpected EOF while reading character."))
|
||||
|
||||
(defn throw-bad-escape-char [rdr ch]
|
||||
(reader-error rdr "Unsupported escape character: \\" ch "."))
|
||||
|
||||
(defn throw-single-colon [rdr]
|
||||
(reader-error rdr "A single colon is not a valid keyword."))
|
||||
|
||||
(defn throw-bad-metadata [rdr x]
|
||||
(reader-error
|
||||
rdr
|
||||
"Metadata cannot be "
|
||||
(i/inspect x)
|
||||
". Metadata must be a Symbol, Keyword, String or Map."))
|
||||
|
||||
(defn throw-bad-metadata-target [rdr target]
|
||||
(reader-error
|
||||
rdr
|
||||
"Metadata can not be applied to "
|
||||
(i/inspect target)
|
||||
". "
|
||||
"Metadata can only be applied to IMetas."))
|
||||
|
||||
(defn throw-feature-not-keyword [rdr feature]
|
||||
(reader-error
|
||||
rdr
|
||||
"Feature cannot be "
|
||||
(i/inspect feature)
|
||||
". Features must be keywords."))
|
||||
|
||||
(defn throw-ns-map-no-map [rdr ns-name]
|
||||
(reader-error rdr "Namespaced map with namespace " ns-name " does not specify a map."))
|
||||
|
||||
(defn throw-bad-ns [rdr ns-name]
|
||||
(reader-error rdr "Invalid value used as namespace in namespaced map: " ns-name "."))
|
||||
|
||||
(defn throw-bad-reader-tag [rdr tag]
|
||||
(reader-error
|
||||
rdr
|
||||
"Invalid reader tag: "
|
||||
(i/inspect tag)
|
||||
". Reader tags must be symbols."))
|
||||
|
||||
(defn throw-unknown-reader-tag [rdr tag]
|
||||
(reader-error
|
||||
rdr
|
||||
"No reader function for tag "
|
||||
(i/inspect tag)
|
||||
"."))
|
||||
|
||||
(defn- duplicate-keys-error [msg coll]
|
||||
(letfn [(duplicates [seq]
|
||||
(for [[id freq] (frequencies seq)
|
||||
:when (> freq 1)]
|
||||
id))]
|
||||
(let [dups (duplicates coll)]
|
||||
(apply str msg
|
||||
(when (> (count dups) 1) "s")
|
||||
": " (interpose ", " dups)))))
|
||||
|
||||
(defn throw-dup-keys [rdr kind ks]
|
||||
(reader-error
|
||||
rdr
|
||||
(duplicate-keys-error
|
||||
(str (s/capitalize (name kind)) " literal contains duplicate key")
|
||||
ks)))
|
||||
|
||||
(defn throw-eof-error [rdr line]
|
||||
(if line
|
||||
(eof-error rdr "EOF while reading, starting at line " line ".")
|
||||
(eof-error rdr "EOF while reading.")))
|
||||
Executable
+416
@@ -0,0 +1,416 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.impl.errors');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('cljs.tools.reader.reader_types');
|
||||
goog.require('clojure.string');
|
||||
goog.require('cljs.tools.reader.impl.inspect');
|
||||
cljs.tools.reader.impl.errors.ex_details = (function cljs$tools$reader$impl$errors$ex_details(rdr,ex_type){
|
||||
var details = new cljs.core.PersistentArrayMap(null, 2, [cljs.core.cst$kw$type,cljs.core.cst$kw$reader_DASH_exception,cljs.core.cst$kw$ex_DASH_kind,ex_type], null);
|
||||
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_(rdr)){
|
||||
return cljs.core.assoc.cljs$core$IFn$_invoke$arity$variadic(details,cljs.core.cst$kw$file,cljs.tools.reader.reader_types.get_file_name(rdr),cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$line,cljs.tools.reader.reader_types.get_line_number(rdr),cljs.core.cst$kw$col,cljs.tools.reader.reader_types.get_column_number(rdr)], 0));
|
||||
} else {
|
||||
return details;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Throw an ex-info error.
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.throw_ex = (function cljs$tools$reader$impl$errors$throw_ex(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5303 = arguments.length;
|
||||
var i__5770__auto___5304 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5304 < len__5769__auto___5303)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5304]));
|
||||
|
||||
var G__5305 = (i__5770__auto___5304 + (1));
|
||||
i__5770__auto___5304 = G__5305;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((2) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((2)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,ex_type,msg){
|
||||
var details = cljs.tools.reader.impl.errors.ex_details(rdr,ex_type);
|
||||
var file = cljs.core.cst$kw$file.cljs$core$IFn$_invoke$arity$1(details);
|
||||
var line = cljs.core.cst$kw$line.cljs$core$IFn$_invoke$arity$1(details);
|
||||
var col = cljs.core.cst$kw$col.cljs$core$IFn$_invoke$arity$1(details);
|
||||
var msg1 = (cljs.core.truth_(file)?[cljs.core.str.cljs$core$IFn$_invoke$arity$1(file)," "].join(''):null);
|
||||
var msg2 = (cljs.core.truth_(line)?["[line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line),", col ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(col),"]"].join(''):null);
|
||||
var msg3 = (cljs.core.truth_((function (){var or__5045__auto__ = msg1;
|
||||
if(cljs.core.truth_(or__5045__auto__)){
|
||||
return or__5045__auto__;
|
||||
} else {
|
||||
return msg2;
|
||||
}
|
||||
})())?" ":null);
|
||||
var full_msg = cljs.core.apply.cljs$core$IFn$_invoke$arity$5(cljs.core.str,msg1,msg2,msg3,msg);
|
||||
throw cljs.core.ex_info.cljs$core$IFn$_invoke$arity$2(full_msg,details);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_ex.cljs$lang$maxFixedArity = (2));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.throw_ex.cljs$lang$applyTo = (function (seq5300){
|
||||
var G__5301 = cljs.core.first(seq5300);
|
||||
var seq5300__$1 = cljs.core.next(seq5300);
|
||||
var G__5302 = cljs.core.first(seq5300__$1);
|
||||
var seq5300__$2 = cljs.core.next(seq5300__$1);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5301,G__5302,seq5300__$2);
|
||||
}));
|
||||
|
||||
/**
|
||||
* Throws an ExceptionInfo with the given message.
|
||||
* If rdr is an IndexingReader, additional information about column and line number is provided
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.reader_error = (function cljs$tools$reader$impl$errors$reader_error(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5308 = arguments.length;
|
||||
var i__5770__auto___5309 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5309 < len__5769__auto___5308)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5309]));
|
||||
|
||||
var G__5310 = (i__5770__auto___5309 + (1));
|
||||
i__5770__auto___5309 = G__5310;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((1) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,msgs){
|
||||
return cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.cst$kw$reader_DASH_error,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.str,msgs)], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.reader_error.cljs$lang$maxFixedArity = (1));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.reader_error.cljs$lang$applyTo = (function (seq5306){
|
||||
var G__5307 = cljs.core.first(seq5306);
|
||||
var seq5306__$1 = cljs.core.next(seq5306);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5307,seq5306__$1);
|
||||
}));
|
||||
|
||||
/**
|
||||
* Throws an ExceptionInfo with the given message.
|
||||
* If rdr is an IndexingReader, additional information about column and line number is provided
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.illegal_arg_error = (function cljs$tools$reader$impl$errors$illegal_arg_error(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5313 = arguments.length;
|
||||
var i__5770__auto___5314 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5314 < len__5769__auto___5313)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5314]));
|
||||
|
||||
var G__5315 = (i__5770__auto___5314 + (1));
|
||||
i__5770__auto___5314 = G__5315;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((1) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,msgs){
|
||||
return cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.cst$kw$illegal_DASH_argument,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.str,msgs)], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.illegal_arg_error.cljs$lang$maxFixedArity = (1));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.illegal_arg_error.cljs$lang$applyTo = (function (seq5311){
|
||||
var G__5312 = cljs.core.first(seq5311);
|
||||
var seq5311__$1 = cljs.core.next(seq5311);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5312,seq5311__$1);
|
||||
}));
|
||||
|
||||
/**
|
||||
* Throws an ExceptionInfo with the given message.
|
||||
* If rdr is an IndexingReader, additional information about column and line number is provided
|
||||
*/
|
||||
cljs.tools.reader.impl.errors.eof_error = (function cljs$tools$reader$impl$errors$eof_error(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5318 = arguments.length;
|
||||
var i__5770__auto___5319 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5319 < len__5769__auto___5318)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5319]));
|
||||
|
||||
var G__5320 = (i__5770__auto___5319 + (1));
|
||||
i__5770__auto___5319 = G__5320;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((1) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((1)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,msgs){
|
||||
return cljs.tools.reader.impl.errors.throw_ex.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.cst$kw$eof,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.str,msgs)], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.eof_error.cljs$lang$maxFixedArity = (1));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.eof_error.cljs$lang$applyTo = (function (seq5316){
|
||||
var G__5317 = cljs.core.first(seq5316);
|
||||
var seq5316__$1 = cljs.core.next(seq5316);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5317,seq5316__$1);
|
||||
}));
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_eof_delimited = (function cljs$tools$reader$impl$errors$throw_eof_delimited(var_args){
|
||||
var G__5322 = arguments.length;
|
||||
switch (G__5322) {
|
||||
case 4:
|
||||
return cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$4((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]));
|
||||
|
||||
break;
|
||||
case 5:
|
||||
return cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),(arguments[(3)]),(arguments[(4)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$4 = (function (rdr,kind,column,line){
|
||||
return cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5(rdr,kind,line,column,null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$core$IFn$_invoke$arity$5 = (function (rdr,kind,line,column,n){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF while reading ",(cljs.core.truth_(n)?["item ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(n)," of "].join(''):null),cljs.core.name(kind),(cljs.core.truth_(line)?[", starting at line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line)," and column ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(column)].join(''):null),"."], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_delimited.cljs$lang$maxFixedArity = 5);
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_odd_map = (function cljs$tools$reader$impl$errors$throw_odd_map(rdr,line,col,elements){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["The map literal starting with ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(cljs.core.first(elements)),(cljs.core.truth_(line)?[" on line ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(line)," column ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(col)].join(''):null)," contains ",cljs.core.count(elements)," form(s). Map literals must contain an even number of forms."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_number = (function cljs$tools$reader$impl$errors$throw_invalid_number(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid number: ",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_literal = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_literal(rdr,token){
|
||||
throw cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid unicode literal: \\",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_escape = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_escape(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid unicode escape: \\u",ch,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid = (function cljs$tools$reader$impl$errors$throw_invalid(rdr,kind,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid ",cljs.core.name(kind),": ",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_at_start = (function cljs$tools$reader$impl$errors$throw_eof_at_start(rdr,kind){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF while reading start of ",cljs.core.name(kind),"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_char = (function cljs$tools$reader$impl$errors$throw_bad_char(rdr,kind,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid character: ",ch," found while reading ",cljs.core.name(kind),"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_at_dispatch = (function cljs$tools$reader$impl$errors$throw_eof_at_dispatch(rdr){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF while reading dispatch character."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_unmatch_delimiter = (function cljs$tools$reader$impl$errors$throw_unmatch_delimiter(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unmatched delimiter ",ch,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_reading = (function cljs$tools$reader$impl$errors$throw_eof_reading(var_args){
|
||||
var args__5775__auto__ = [];
|
||||
var len__5769__auto___5328 = arguments.length;
|
||||
var i__5770__auto___5329 = (0);
|
||||
while(true){
|
||||
if((i__5770__auto___5329 < len__5769__auto___5328)){
|
||||
args__5775__auto__.push((arguments[i__5770__auto___5329]));
|
||||
|
||||
var G__5330 = (i__5770__auto___5329 + (1));
|
||||
i__5770__auto___5329 = G__5330;
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var argseq__5776__auto__ = ((((2) < args__5775__auto__.length))?(new cljs.core.IndexedSeq(args__5775__auto__.slice((2)),(0),null)):null);
|
||||
return cljs.tools.reader.impl.errors.throw_eof_reading.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),argseq__5776__auto__);
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_reading.cljs$core$IFn$_invoke$arity$variadic = (function (rdr,kind,start){
|
||||
var init = (function (){var G__5327 = kind;
|
||||
var G__5327__$1 = (((G__5327 instanceof cljs.core.Keyword))?G__5327.fqn:null);
|
||||
switch (G__5327__$1) {
|
||||
case "regex":
|
||||
return "#\"";
|
||||
|
||||
break;
|
||||
case "string":
|
||||
return "\"";
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["No matching clause: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(G__5327__$1)].join('')));
|
||||
|
||||
}
|
||||
})();
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF reading ",cljs.core.name(kind)," starting ",cljs.core.apply.cljs$core$IFn$_invoke$arity$3(cljs.core.str,init,start),"."], 0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.errors.throw_eof_reading.cljs$lang$maxFixedArity = (2));
|
||||
|
||||
/** @this {Function} */
|
||||
(cljs.tools.reader.impl.errors.throw_eof_reading.cljs$lang$applyTo = (function (seq5324){
|
||||
var G__5325 = cljs.core.first(seq5324);
|
||||
var seq5324__$1 = cljs.core.next(seq5324);
|
||||
var G__5326 = cljs.core.first(seq5324__$1);
|
||||
var seq5324__$2 = cljs.core.next(seq5324__$1);
|
||||
var self__5754__auto__ = this;
|
||||
return self__5754__auto__.cljs$core$IFn$_invoke$arity$variadic(G__5325,G__5326,seq5324__$2);
|
||||
}));
|
||||
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_char = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_char(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid unicode character \\",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_digit_in_token = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_digit_in_token(rdr,ch,token){
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid digit ",ch," in unicode character \\",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_digit = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_digit(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid digit ",ch," in unicode character."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_unicode_len = (function cljs$tools$reader$impl$errors$throw_invalid_unicode_len(rdr,actual,expected){
|
||||
return cljs.tools.reader.impl.errors.illegal_arg_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid unicode literal. Unicode literals should be ",expected,"characters long. ","Value supplied is ",actual," characters long."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_character_literal = (function cljs$tools$reader$impl$errors$throw_invalid_character_literal(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid character literal \\u",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_invalid_octal_len = (function cljs$tools$reader$impl$errors$throw_invalid_octal_len(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid octal escape sequence in a character literal: ",token,". Octal escape sequences must be 3 or fewer digits."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_octal_number = (function cljs$tools$reader$impl$errors$throw_bad_octal_number(rdr){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Octal escape sequence must be in range [0, 377]."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_unsupported_character = (function cljs$tools$reader$impl$errors$throw_unsupported_character(rdr,token){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unsupported character: ",token,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_in_character = (function cljs$tools$reader$impl$errors$throw_eof_in_character(rdr){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unexpected EOF while reading character."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_escape_char = (function cljs$tools$reader$impl$errors$throw_bad_escape_char(rdr,ch){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Unsupported escape character: \\",ch,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_single_colon = (function cljs$tools$reader$impl$errors$throw_single_colon(rdr){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["A single colon is not a valid keyword."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_metadata = (function cljs$tools$reader$impl$errors$throw_bad_metadata(rdr,x){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Metadata cannot be ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(x),". Metadata must be a Symbol, Keyword, String or Map."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_metadata_target = (function cljs$tools$reader$impl$errors$throw_bad_metadata_target(rdr,target){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Metadata can not be applied to ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(target),". ","Metadata can only be applied to IMetas."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_feature_not_keyword = (function cljs$tools$reader$impl$errors$throw_feature_not_keyword(rdr,feature){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Feature cannot be ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(feature),". Features must be keywords."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_ns_map_no_map = (function cljs$tools$reader$impl$errors$throw_ns_map_no_map(rdr,ns_name){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Namespaced map with namespace ",ns_name," does not specify a map."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_ns = (function cljs$tools$reader$impl$errors$throw_bad_ns(rdr,ns_name){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid value used as namespace in namespaced map: ",ns_name,"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_bad_reader_tag = (function cljs$tools$reader$impl$errors$throw_bad_reader_tag(rdr,tag){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["Invalid reader tag: ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(tag),". Reader tags must be symbols."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_unknown_reader_tag = (function cljs$tools$reader$impl$errors$throw_unknown_reader_tag(rdr,tag){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["No reader function for tag ",cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1(tag),"."], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.duplicate_keys_error = (function cljs$tools$reader$impl$errors$duplicate_keys_error(msg,coll){
|
||||
var duplicates = (function cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates(seq){
|
||||
var iter__5523__auto__ = (function cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates_$_iter__5342(s__5343){
|
||||
return (new cljs.core.LazySeq(null,(function (){
|
||||
var s__5343__$1 = s__5343;
|
||||
while(true){
|
||||
var temp__4657__auto__ = cljs.core.seq(s__5343__$1);
|
||||
if(temp__4657__auto__){
|
||||
var s__5343__$2 = temp__4657__auto__;
|
||||
if(cljs.core.chunked_seq_QMARK_(s__5343__$2)){
|
||||
var c__5521__auto__ = cljs.core.chunk_first(s__5343__$2);
|
||||
var size__5522__auto__ = cljs.core.count(c__5521__auto__);
|
||||
var b__5345 = cljs.core.chunk_buffer(size__5522__auto__);
|
||||
if((function (){var i__5344 = (0);
|
||||
while(true){
|
||||
if((i__5344 < size__5522__auto__)){
|
||||
var vec__5346 = cljs.core._nth.cljs$core$IFn$_invoke$arity$2(c__5521__auto__,i__5344);
|
||||
var id = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5346,(0),null);
|
||||
var freq = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5346,(1),null);
|
||||
if((freq > (1))){
|
||||
cljs.core.chunk_append(b__5345,id);
|
||||
|
||||
var G__5352 = (i__5344 + (1));
|
||||
i__5344 = G__5352;
|
||||
continue;
|
||||
} else {
|
||||
var G__5353 = (i__5344 + (1));
|
||||
i__5344 = G__5353;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})()){
|
||||
return cljs.core.chunk_cons(cljs.core.chunk(b__5345),cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates_$_iter__5342(cljs.core.chunk_rest(s__5343__$2)));
|
||||
} else {
|
||||
return cljs.core.chunk_cons(cljs.core.chunk(b__5345),null);
|
||||
}
|
||||
} else {
|
||||
var vec__5349 = cljs.core.first(s__5343__$2);
|
||||
var id = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5349,(0),null);
|
||||
var freq = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5349,(1),null);
|
||||
if((freq > (1))){
|
||||
return cljs.core.cons(id,cljs$tools$reader$impl$errors$duplicate_keys_error_$_duplicates_$_iter__5342(cljs.core.rest(s__5343__$2)));
|
||||
} else {
|
||||
var G__5354 = cljs.core.rest(s__5343__$2);
|
||||
s__5343__$1 = G__5354;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}),null,null));
|
||||
});
|
||||
return iter__5523__auto__(cljs.core.frequencies(seq));
|
||||
});
|
||||
var dups = duplicates(coll);
|
||||
return cljs.core.apply.cljs$core$IFn$_invoke$arity$5(cljs.core.str,msg,(((cljs.core.count(dups) > (1)))?"s":null),": ",cljs.core.interpose.cljs$core$IFn$_invoke$arity$2(", ",dups));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_dup_keys = (function cljs$tools$reader$impl$errors$throw_dup_keys(rdr,kind,ks){
|
||||
return cljs.tools.reader.impl.errors.reader_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.tools.reader.impl.errors.duplicate_keys_error([clojure.string.capitalize(cljs.core.name(kind))," literal contains duplicate key"].join(''),ks)], 0));
|
||||
});
|
||||
cljs.tools.reader.impl.errors.throw_eof_error = (function cljs$tools$reader$impl$errors$throw_eof_error(rdr,line){
|
||||
if(cljs.core.truth_(line)){
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["EOF while reading, starting at line ",line,"."], 0));
|
||||
} else {
|
||||
return cljs.tools.reader.impl.errors.eof_error.cljs$core$IFn$_invoke$arity$variadic(rdr,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2(["EOF while reading."], 0));
|
||||
}
|
||||
});
|
||||
Executable
+90
@@ -0,0 +1,90 @@
|
||||
;; Copyright (c) Russ Olsen, Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.tools.reader.impl.inspect)
|
||||
|
||||
(declare inspect*)
|
||||
|
||||
(defn- inspect*-col [truncate col start end]
|
||||
(let [n (count col)
|
||||
l (if truncate 0 (min 10 n))
|
||||
elements (map (partial inspect* true) (take l col))
|
||||
content (apply str (interpose " " elements))
|
||||
suffix (if (< l n) "...")]
|
||||
(str start content suffix end)))
|
||||
|
||||
(defn- dispatch-inspect
|
||||
[_ x]
|
||||
(cond
|
||||
(nil? x) :nil
|
||||
(string? x) :string
|
||||
(keyword? x) :strable
|
||||
(number? x) :strable
|
||||
(symbol? x) :strable
|
||||
(vector? x) :vector
|
||||
(list? x) :list
|
||||
(map? x) :map
|
||||
(set? x) :set
|
||||
(= x true) :strable
|
||||
(= x false) :strable
|
||||
:default (type x)))
|
||||
|
||||
(defmulti inspect* dispatch-inspect)
|
||||
|
||||
(defmethod inspect* :string [truncate ^String x]
|
||||
(let [n (if truncate 5 20)
|
||||
suffix (if (> (.-length x) n) "...\"" "\"")]
|
||||
(str
|
||||
\"
|
||||
(.substring ^String x 0 (min n (.-length x)))
|
||||
suffix)))
|
||||
|
||||
(defmethod inspect* :strable [truncate x] (str x))
|
||||
|
||||
(defmethod inspect* cljs.core/IndexedSeq [truncate x]
|
||||
"<indexed seq>")
|
||||
|
||||
(defmethod inspect* cljs.core/PersistentArrayMapSeq [truncate x]
|
||||
"<map seq>")
|
||||
|
||||
(defmethod inspect* cljs.core/NodeSeq [truncate x]
|
||||
"<map seq>")
|
||||
|
||||
(defmethod inspect* cljs.core/Cons [truncate x] "<cons>")
|
||||
|
||||
(defmethod inspect* cljs.core/LazySeq [truncate x] "<lazy seq>")
|
||||
|
||||
(defmethod inspect* :nil [_ _] "nil")
|
||||
|
||||
(defmethod inspect* :list [truncate col]
|
||||
(inspect*-col truncate col \( \)))
|
||||
|
||||
(defmethod inspect* :map [truncate m]
|
||||
(let [len (count m)
|
||||
n-shown (if truncate 0 len)
|
||||
contents (apply concat (take n-shown m))
|
||||
suffix (if (> len n-shown) "...}" \})]
|
||||
(inspect*-col truncate contents \{ suffix)))
|
||||
|
||||
(defmethod inspect* :set [truncate col]
|
||||
(inspect*-col truncate col "#{" \}))
|
||||
|
||||
(defmethod inspect* :vector [truncate col]
|
||||
(inspect*-col truncate col \[ \]))
|
||||
|
||||
(defmethod inspect* :default [truncate x]
|
||||
(pr-str (type x)))
|
||||
|
||||
(defn inspect
|
||||
"Return a string description of the value supplied.
|
||||
May be the a string version of the value itself (e.g. \"true\")
|
||||
or it may be a description (e.g. \"an instance of Foo\").
|
||||
If truncate is true then return a very terse version of
|
||||
the inspection."
|
||||
([x] (inspect* false x))
|
||||
([truncate x] (inspect* truncate x)))
|
||||
Executable
+157
@@ -0,0 +1,157 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.impl.inspect');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR__col = (function cljs$tools$reader$impl$inspect$inspect_STAR__col(truncate,col,start,end){
|
||||
var n = cljs.core.count(col);
|
||||
var l = (cljs.core.truth_(truncate)?(0):(function (){var x__5133__auto__ = (10);
|
||||
var y__5134__auto__ = n;
|
||||
return ((x__5133__auto__ < y__5134__auto__) ? x__5133__auto__ : y__5134__auto__);
|
||||
})());
|
||||
var elements = cljs.core.map.cljs$core$IFn$_invoke$arity$2(cljs.core.partial.cljs$core$IFn$_invoke$arity$2(cljs.tools.reader.impl.inspect.inspect_STAR_,true),cljs.core.take.cljs$core$IFn$_invoke$arity$2(l,col));
|
||||
var content = cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.str,cljs.core.interpose.cljs$core$IFn$_invoke$arity$2(" ",elements));
|
||||
var suffix = (((l < n))?"...":null);
|
||||
return [cljs.core.str.cljs$core$IFn$_invoke$arity$1(start),cljs.core.str.cljs$core$IFn$_invoke$arity$1(content),suffix,cljs.core.str.cljs$core$IFn$_invoke$arity$1(end)].join('');
|
||||
});
|
||||
cljs.tools.reader.impl.inspect.dispatch_inspect = (function cljs$tools$reader$impl$inspect$dispatch_inspect(_,x){
|
||||
if((x == null)){
|
||||
return cljs.core.cst$kw$nil;
|
||||
} else {
|
||||
if(typeof x === 'string'){
|
||||
return cljs.core.cst$kw$string;
|
||||
} else {
|
||||
if((x instanceof cljs.core.Keyword)){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
if(typeof x === 'number'){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
if((x instanceof cljs.core.Symbol)){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
if(cljs.core.vector_QMARK_(x)){
|
||||
return cljs.core.cst$kw$vector;
|
||||
} else {
|
||||
if(cljs.core.list_QMARK_(x)){
|
||||
return cljs.core.cst$kw$list;
|
||||
} else {
|
||||
if(cljs.core.map_QMARK_(x)){
|
||||
return cljs.core.cst$kw$map;
|
||||
} else {
|
||||
if(cljs.core.set_QMARK_(x)){
|
||||
return cljs.core.cst$kw$set;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(x,true)){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(x,false)){
|
||||
return cljs.core.cst$kw$strable;
|
||||
} else {
|
||||
return cljs.core.type(x);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if((typeof cljs !== 'undefined') && (typeof cljs.tools !== 'undefined') && (typeof cljs.tools.reader !== 'undefined') && (typeof cljs.tools.reader.impl !== 'undefined') && (typeof cljs.tools.reader.impl.inspect !== 'undefined') && (typeof cljs.tools.reader.impl.inspect.inspect_STAR_ !== 'undefined')){
|
||||
} else {
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_ = (function (){var method_table__5642__auto__ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
|
||||
var prefer_table__5643__auto__ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
|
||||
var method_cache__5644__auto__ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
|
||||
var cached_hierarchy__5645__auto__ = cljs.core.atom.cljs$core$IFn$_invoke$arity$1(cljs.core.PersistentArrayMap.EMPTY);
|
||||
var hierarchy__5646__auto__ = cljs.core.get.cljs$core$IFn$_invoke$arity$3(cljs.core.PersistentArrayMap.EMPTY,cljs.core.cst$kw$hierarchy,(function (){var fexpr__5294 = cljs.core.get_global_hierarchy;
|
||||
return (fexpr__5294.cljs$core$IFn$_invoke$arity$0 ? fexpr__5294.cljs$core$IFn$_invoke$arity$0() : fexpr__5294.call(null));
|
||||
})());
|
||||
return (new cljs.core.MultiFn(cljs.core.symbol.cljs$core$IFn$_invoke$arity$2("cljs.tools.reader.impl.inspect","inspect*"),cljs.tools.reader.impl.inspect.dispatch_inspect,cljs.core.cst$kw$default,hierarchy__5646__auto__,method_table__5642__auto__,prefer_table__5643__auto__,method_cache__5644__auto__,cached_hierarchy__5645__auto__));
|
||||
})();
|
||||
}
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$string,(function (truncate,x){
|
||||
var n = (cljs.core.truth_(truncate)?(5):(20));
|
||||
var suffix = (((x.length > n))?"...\"":"\"");
|
||||
return ["\"",cljs.core.str.cljs$core$IFn$_invoke$arity$1(x.substring((0),(function (){var x__5133__auto__ = n;
|
||||
var y__5134__auto__ = x.length;
|
||||
return ((x__5133__auto__ < y__5134__auto__) ? x__5133__auto__ : y__5134__auto__);
|
||||
})())),suffix].join('');
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$strable,(function (truncate,x){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(x);
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.IndexedSeq,(function (truncate,x){
|
||||
return "<indexed seq>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.PersistentArrayMapSeq,(function (truncate,x){
|
||||
return "<map seq>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.NodeSeq,(function (truncate,x){
|
||||
return "<map seq>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.Cons,(function (truncate,x){
|
||||
return "<cons>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.LazySeq,(function (truncate,x){
|
||||
return "<lazy seq>";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$nil,(function (_,___$1){
|
||||
return "nil";
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$list,(function (truncate,col){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col(truncate,col,"(",")");
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$map,(function (truncate,m){
|
||||
var len = cljs.core.count(m);
|
||||
var n_shown = (cljs.core.truth_(truncate)?(0):len);
|
||||
var contents = cljs.core.apply.cljs$core$IFn$_invoke$arity$2(cljs.core.concat,cljs.core.take.cljs$core$IFn$_invoke$arity$2(n_shown,m));
|
||||
var suffix = (((len > n_shown))?"...}":"}");
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col(truncate,contents,"{",suffix);
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$set,(function (truncate,col){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col(truncate,col,"#{","}");
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$vector,(function (truncate,col){
|
||||
return cljs.tools.reader.impl.inspect.inspect_STAR__col(truncate,col,"[","]");
|
||||
}));
|
||||
cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IMultiFn$_add_method$arity$3(null,cljs.core.cst$kw$default,(function (truncate,x){
|
||||
return cljs.core.pr_str.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.type(x)], 0));
|
||||
}));
|
||||
/**
|
||||
* Return a string description of the value supplied.
|
||||
* May be the a string version of the value itself (e.g. "true")
|
||||
* or it may be a description (e.g. "an instance of Foo").
|
||||
* If truncate is true then return a very terse version of
|
||||
* the inspection.
|
||||
*/
|
||||
cljs.tools.reader.impl.inspect.inspect = (function cljs$tools$reader$impl$inspect$inspect(var_args){
|
||||
var G__5296 = arguments.length;
|
||||
switch (G__5296) {
|
||||
case 1:
|
||||
return cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$1 = (function (x){
|
||||
return (cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IFn$_invoke$arity$2 ? cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IFn$_invoke$arity$2(false,x) : cljs.tools.reader.impl.inspect.inspect_STAR_.call(null,false,x));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.inspect.inspect.cljs$core$IFn$_invoke$arity$2 = (function (truncate,x){
|
||||
return (cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IFn$_invoke$arity$2 ? cljs.tools.reader.impl.inspect.inspect_STAR_.cljs$core$IFn$_invoke$arity$2(truncate,x) : cljs.tools.reader.impl.inspect.inspect_STAR_.call(null,truncate,x));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.inspect.inspect.cljs$lang$maxFixedArity = 2);
|
||||
|
||||
Executable
+103
@@ -0,0 +1,103 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns cljs.tools.reader.impl.utils
|
||||
(:refer-clojure :exclude [char])
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[goog.string :as gstring]))
|
||||
|
||||
(defn char [x]
|
||||
(when-not (nil? x)
|
||||
(cljs.core/char x)))
|
||||
|
||||
(defn ^boolean ex-info? [ex]
|
||||
(instance? cljs.core.ExceptionInfo ex))
|
||||
|
||||
(defrecord ReaderConditional [splicing? form])
|
||||
|
||||
(defn ^boolean reader-conditional?
|
||||
"Return true if the value is the data representation of a reader conditional"
|
||||
[value]
|
||||
(instance? ReaderConditional value))
|
||||
|
||||
(defn reader-conditional
|
||||
"Construct a data representation of a reader conditional.
|
||||
If true, splicing? indicates read-cond-splicing."
|
||||
[form splicing?]
|
||||
(ReaderConditional. splicing? form))
|
||||
|
||||
(extend-protocol IPrintWithWriter
|
||||
ReaderConditional
|
||||
(-pr-writer [coll writer opts]
|
||||
(-write writer (str "#?" (when (:splicing? coll) "@")))
|
||||
(pr-writer (:form coll) writer opts)))
|
||||
|
||||
(def ws-rx #"[\s]")
|
||||
|
||||
(defn ^boolean whitespace?
|
||||
"Checks whether a given character is whitespace"
|
||||
[ch]
|
||||
(when-not (nil? ch)
|
||||
(if (identical? ch \,)
|
||||
true
|
||||
(.test ws-rx ch))))
|
||||
|
||||
(defn ^boolean numeric?
|
||||
"Checks whether a given character is numeric"
|
||||
[ch]
|
||||
(when-not (nil? ch)
|
||||
(gstring/isNumeric ch)))
|
||||
|
||||
(defn ^boolean newline?
|
||||
"Checks whether the character is a newline"
|
||||
[c]
|
||||
(or (identical? \newline c)
|
||||
(identical? "\n" c)
|
||||
(nil? c)))
|
||||
|
||||
(defn desugar-meta
|
||||
"Resolves syntactical sugar in metadata" ;; could be combined with some other desugar?
|
||||
[f]
|
||||
(cond
|
||||
(keyword? f) {f true}
|
||||
(symbol? f) {:tag f}
|
||||
(string? f) {:tag f}
|
||||
:else f))
|
||||
|
||||
(def last-id (atom 0))
|
||||
|
||||
(defn next-id
|
||||
[]
|
||||
(swap! last-id inc))
|
||||
|
||||
(defn namespace-keys [ns keys]
|
||||
(for [key keys]
|
||||
(if (or (symbol? key)
|
||||
(keyword? key))
|
||||
(let [[key-ns key-name] ((juxt namespace name) key)
|
||||
->key (if (symbol? key) symbol keyword)]
|
||||
(cond
|
||||
(nil? key-ns)
|
||||
(->key ns key-name)
|
||||
|
||||
(= "_" key-ns)
|
||||
(->key key-name)
|
||||
|
||||
:else
|
||||
key))
|
||||
key)))
|
||||
|
||||
(defn second' [[a b]]
|
||||
(when-not a b))
|
||||
|
||||
(defn char-code [ch base]
|
||||
(let [code (js/parseInt ch base)]
|
||||
(if (js/isNaN code)
|
||||
-1
|
||||
code)))
|
||||
Executable
+413
@@ -0,0 +1,413 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.impl.utils');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('clojure.string');
|
||||
goog.require('goog.string');
|
||||
cljs.tools.reader.impl.utils.char$ = (function cljs$tools$reader$impl$utils$char(x){
|
||||
if((x == null)){
|
||||
return null;
|
||||
} else {
|
||||
return cljs.core.char$(x);
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.utils.ex_info_QMARK_ = (function cljs$tools$reader$impl$utils$ex_info_QMARK_(ex){
|
||||
return (ex instanceof cljs.core.ExceptionInfo);
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.core.IRecord}
|
||||
* @implements {cljs.core.IKVReduce}
|
||||
* @implements {cljs.core.IEquiv}
|
||||
* @implements {cljs.core.IHash}
|
||||
* @implements {cljs.core.ICollection}
|
||||
* @implements {cljs.core.ICounted}
|
||||
* @implements {cljs.core.ISeqable}
|
||||
* @implements {cljs.core.IMeta}
|
||||
* @implements {cljs.core.ICloneable}
|
||||
* @implements {cljs.core.IPrintWithWriter}
|
||||
* @implements {cljs.core.IIterable}
|
||||
* @implements {cljs.core.IWithMeta}
|
||||
* @implements {cljs.core.IAssociative}
|
||||
* @implements {cljs.core.IMap}
|
||||
* @implements {cljs.core.ILookup}
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.ReaderConditional = (function (splicing_QMARK_,form,__meta,__extmap,__hash){
|
||||
this.splicing_QMARK_ = splicing_QMARK_;
|
||||
this.form = form;
|
||||
this.__meta = __meta;
|
||||
this.__extmap = __extmap;
|
||||
this.__hash = __hash;
|
||||
this.cljs$lang$protocol_mask$partition0$ = 2230716170;
|
||||
this.cljs$lang$protocol_mask$partition1$ = 139264;
|
||||
});
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ILookup$_lookup$arity$2 = (function (this__5343__auto__,k__5344__auto__){
|
||||
var self__ = this;
|
||||
var this__5343__auto____$1 = this;
|
||||
return this__5343__auto____$1.cljs$core$ILookup$_lookup$arity$3(null,k__5344__auto__,null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ILookup$_lookup$arity$3 = (function (this__5345__auto__,k5233,else__5346__auto__){
|
||||
var self__ = this;
|
||||
var this__5345__auto____$1 = this;
|
||||
var G__5237 = k5233;
|
||||
var G__5237__$1 = (((G__5237 instanceof cljs.core.Keyword))?G__5237.fqn:null);
|
||||
switch (G__5237__$1) {
|
||||
case "splicing?":
|
||||
return self__.splicing_QMARK_;
|
||||
|
||||
break;
|
||||
case "form":
|
||||
return self__.form;
|
||||
|
||||
break;
|
||||
default:
|
||||
return cljs.core.get.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k5233,else__5346__auto__);
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IKVReduce$_kv_reduce$arity$3 = (function (this__5363__auto__,f__5364__auto__,init__5365__auto__){
|
||||
var self__ = this;
|
||||
var this__5363__auto____$1 = this;
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3((function (ret__5366__auto__,p__5238){
|
||||
var vec__5239 = p__5238;
|
||||
var k__5367__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5239,(0),null);
|
||||
var v__5368__auto__ = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5239,(1),null);
|
||||
return (f__5364__auto__.cljs$core$IFn$_invoke$arity$3 ? f__5364__auto__.cljs$core$IFn$_invoke$arity$3(ret__5366__auto__,k__5367__auto__,v__5368__auto__) : f__5364__auto__.call(null,ret__5366__auto__,k__5367__auto__,v__5368__auto__));
|
||||
}),init__5365__auto__,this__5363__auto____$1);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (this__5358__auto__,writer__5359__auto__,opts__5360__auto__){
|
||||
var self__ = this;
|
||||
var this__5358__auto____$1 = this;
|
||||
var pr_pair__5361__auto__ = (function (keyval__5362__auto__){
|
||||
return cljs.core.pr_sequential_writer(writer__5359__auto__,cljs.core.pr_writer,""," ","",opts__5360__auto__,keyval__5362__auto__);
|
||||
});
|
||||
return cljs.core.pr_sequential_writer(writer__5359__auto__,pr_pair__5361__auto__,"#cljs.tools.reader.impl.utils.ReaderConditional{",", ","}",opts__5360__auto__,cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.cst$kw$splicing_QMARK_,self__.splicing_QMARK_],null)),(new cljs.core.PersistentVector(null,2,(5),cljs.core.PersistentVector.EMPTY_NODE,[cljs.core.cst$kw$form,self__.form],null))], null),self__.__extmap));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IIterable$_iterator$arity$1 = (function (G__5232){
|
||||
var self__ = this;
|
||||
var G__5232__$1 = this;
|
||||
return (new cljs.core.RecordIter((0),G__5232__$1,2,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$kw$splicing_QMARK_,cljs.core.cst$kw$form], null),(cljs.core.truth_(self__.__extmap)?cljs.core._iterator(self__.__extmap):cljs.core.nil_iter())));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IMeta$_meta$arity$1 = (function (this__5341__auto__){
|
||||
var self__ = this;
|
||||
var this__5341__auto____$1 = this;
|
||||
return self__.__meta;
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ICloneable$_clone$arity$1 = (function (this__5338__auto__){
|
||||
var self__ = this;
|
||||
var this__5338__auto____$1 = this;
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,self__.__meta,self__.__extmap,self__.__hash));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ICounted$_count$arity$1 = (function (this__5347__auto__){
|
||||
var self__ = this;
|
||||
var this__5347__auto____$1 = this;
|
||||
return (2 + cljs.core.count(self__.__extmap));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IHash$_hash$arity$1 = (function (this__5339__auto__){
|
||||
var self__ = this;
|
||||
var this__5339__auto____$1 = this;
|
||||
var h__5154__auto__ = self__.__hash;
|
||||
if((!((h__5154__auto__ == null)))){
|
||||
return h__5154__auto__;
|
||||
} else {
|
||||
var h__5154__auto____$1 = (function (){var fexpr__5242 = (function (coll__5340__auto__){
|
||||
return (-209062840 ^ cljs.core.hash_unordered_coll(coll__5340__auto__));
|
||||
});
|
||||
return fexpr__5242(this__5339__auto____$1);
|
||||
})();
|
||||
(self__.__hash = h__5154__auto____$1);
|
||||
|
||||
return h__5154__auto____$1;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IEquiv$_equiv$arity$2 = (function (this5234,other5235){
|
||||
var self__ = this;
|
||||
var this5234__$1 = this;
|
||||
return (((!((other5235 == null)))) && ((((this5234__$1.constructor === other5235.constructor)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this5234__$1.splicing_QMARK_,other5235.splicing_QMARK_)) && (((cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this5234__$1.form,other5235.form)) && (cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2(this5234__$1.__extmap,other5235.__extmap)))))))));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IMap$_dissoc$arity$2 = (function (this__5353__auto__,k__5354__auto__){
|
||||
var self__ = this;
|
||||
var this__5353__auto____$1 = this;
|
||||
if(cljs.core.contains_QMARK_(new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 2, [cljs.core.cst$kw$splicing_QMARK_,null,cljs.core.cst$kw$form,null], null), null),k__5354__auto__)){
|
||||
return cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(cljs.core._with_meta(cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,this__5353__auto____$1),self__.__meta),k__5354__auto__);
|
||||
} else {
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,self__.__meta,cljs.core.not_empty(cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(self__.__extmap,k__5354__auto__)),null));
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IAssociative$_contains_key_QMARK_$arity$2 = (function (this__5350__auto__,k5233){
|
||||
var self__ = this;
|
||||
var this__5350__auto____$1 = this;
|
||||
var G__5243 = k5233;
|
||||
var G__5243__$1 = (((G__5243 instanceof cljs.core.Keyword))?G__5243.fqn:null);
|
||||
switch (G__5243__$1) {
|
||||
case "splicing?":
|
||||
case "form":
|
||||
return true;
|
||||
|
||||
break;
|
||||
default:
|
||||
return cljs.core.contains_QMARK_(self__.__extmap,k5233);
|
||||
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IAssociative$_assoc$arity$3 = (function (this__5351__auto__,k__5352__auto__,G__5232){
|
||||
var self__ = this;
|
||||
var this__5351__auto____$1 = this;
|
||||
var pred__5244 = cljs.core.keyword_identical_QMARK_;
|
||||
var expr__5245 = k__5352__auto__;
|
||||
if(cljs.core.truth_((function (){var G__5247 = cljs.core.cst$kw$splicing_QMARK_;
|
||||
var G__5248 = expr__5245;
|
||||
return (pred__5244.cljs$core$IFn$_invoke$arity$2 ? pred__5244.cljs$core$IFn$_invoke$arity$2(G__5247,G__5248) : pred__5244.call(null,G__5247,G__5248));
|
||||
})())){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(G__5232,self__.form,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
if(cljs.core.truth_((function (){var G__5249 = cljs.core.cst$kw$form;
|
||||
var G__5250 = expr__5245;
|
||||
return (pred__5244.cljs$core$IFn$_invoke$arity$2 ? pred__5244.cljs$core$IFn$_invoke$arity$2(G__5249,G__5250) : pred__5244.call(null,G__5249,G__5250));
|
||||
})())){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,G__5232,self__.__meta,self__.__extmap,null));
|
||||
} else {
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,self__.__meta,cljs.core.assoc.cljs$core$IFn$_invoke$arity$3(self__.__extmap,k__5352__auto__,G__5232),null));
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ISeqable$_seq$arity$1 = (function (this__5356__auto__){
|
||||
var self__ = this;
|
||||
var this__5356__auto____$1 = this;
|
||||
return cljs.core.seq(cljs.core.concat.cljs$core$IFn$_invoke$arity$2(new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [(new cljs.core.MapEntry(cljs.core.cst$kw$splicing_QMARK_,self__.splicing_QMARK_,null)),(new cljs.core.MapEntry(cljs.core.cst$kw$form,self__.form,null))], null),self__.__extmap));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IWithMeta$_with_meta$arity$2 = (function (this__5342__auto__,G__5232){
|
||||
var self__ = this;
|
||||
var this__5342__auto____$1 = this;
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(self__.splicing_QMARK_,self__.form,G__5232,self__.__extmap,self__.__hash));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$ICollection$_conj$arity$2 = (function (this__5348__auto__,entry__5349__auto__){
|
||||
var self__ = this;
|
||||
var this__5348__auto____$1 = this;
|
||||
if(cljs.core.vector_QMARK_(entry__5349__auto__)){
|
||||
return this__5348__auto____$1.cljs$core$IAssociative$_assoc$arity$3(null,cljs.core._nth.cljs$core$IFn$_invoke$arity$2(entry__5349__auto__,(0)),cljs.core._nth.cljs$core$IFn$_invoke$arity$2(entry__5349__auto__,(1)));
|
||||
} else {
|
||||
return cljs.core.reduce.cljs$core$IFn$_invoke$arity$3(cljs.core._conj,this__5348__auto____$1,entry__5349__auto__);
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$splicing_QMARK_,cljs.core.cst$sym$form], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.cljs$lang$ctorPrSeq = (function (this__5389__auto__){
|
||||
return (new cljs.core.List(null,"cljs.tools.reader.impl.utils/ReaderConditional",null,(1),null));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.cljs$lang$ctorPrWriter = (function (this__5389__auto__,writer__5390__auto__){
|
||||
return cljs.core._write(writer__5390__auto__,"cljs.tools.reader.impl.utils/ReaderConditional");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.impl.utils/ReaderConditional.
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.__GT_ReaderConditional = (function cljs$tools$reader$impl$utils$__GT_ReaderConditional(splicing_QMARK_,form){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(splicing_QMARK_,form,null,null,null));
|
||||
});
|
||||
|
||||
/**
|
||||
* Factory function for cljs.tools.reader.impl.utils/ReaderConditional, taking a map of keywords to field values.
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.map__GT_ReaderConditional = (function cljs$tools$reader$impl$utils$map__GT_ReaderConditional(G__5236){
|
||||
var extmap__5385__auto__ = (function (){var G__5251 = cljs.core.dissoc.cljs$core$IFn$_invoke$arity$variadic(G__5236,cljs.core.cst$kw$splicing_QMARK_,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([cljs.core.cst$kw$form], 0));
|
||||
if(cljs.core.record_QMARK_(G__5236)){
|
||||
return cljs.core.into.cljs$core$IFn$_invoke$arity$2(cljs.core.PersistentArrayMap.EMPTY,G__5251);
|
||||
} else {
|
||||
return G__5251;
|
||||
}
|
||||
})();
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(cljs.core.cst$kw$splicing_QMARK_.cljs$core$IFn$_invoke$arity$1(G__5236),cljs.core.cst$kw$form.cljs$core$IFn$_invoke$arity$1(G__5236),null,cljs.core.not_empty(extmap__5385__auto__),null));
|
||||
});
|
||||
|
||||
/**
|
||||
* Return true if the value is the data representation of a reader conditional
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.reader_conditional_QMARK_ = (function cljs$tools$reader$impl$utils$reader_conditional_QMARK_(value){
|
||||
return (value instanceof cljs.tools.reader.impl.utils.ReaderConditional);
|
||||
});
|
||||
/**
|
||||
* Construct a data representation of a reader conditional.
|
||||
* If true, splicing? indicates read-cond-splicing.
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.reader_conditional = (function cljs$tools$reader$impl$utils$reader_conditional(form,splicing_QMARK_){
|
||||
return (new cljs.tools.reader.impl.utils.ReaderConditional(splicing_QMARK_,form,null,null,null));
|
||||
});
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IPrintWithWriter$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.impl.utils.ReaderConditional.prototype.cljs$core$IPrintWithWriter$_pr_writer$arity$3 = (function (coll,writer,opts){
|
||||
var coll__$1 = this;
|
||||
cljs.core._write(writer,["#?",(cljs.core.truth_(coll__$1.splicing_QMARK_)?"@":null)].join(''));
|
||||
|
||||
return cljs.core.pr_writer(coll__$1.form,writer,opts);
|
||||
}));
|
||||
cljs.tools.reader.impl.utils.ws_rx = /[\s]/;
|
||||
/**
|
||||
* Checks whether a given character is whitespace
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.whitespace_QMARK_ = (function cljs$tools$reader$impl$utils$whitespace_QMARK_(ch){
|
||||
if((ch == null)){
|
||||
return null;
|
||||
} else {
|
||||
if((ch === ",")){
|
||||
return true;
|
||||
} else {
|
||||
return cljs.tools.reader.impl.utils.ws_rx.test(ch);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Checks whether a given character is numeric
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.numeric_QMARK_ = (function cljs$tools$reader$impl$utils$numeric_QMARK_(ch){
|
||||
if((ch == null)){
|
||||
return null;
|
||||
} else {
|
||||
return goog.string.isNumeric(ch);
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Checks whether the character is a newline
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.newline_QMARK_ = (function cljs$tools$reader$impl$utils$newline_QMARK_(c){
|
||||
return ((("\n" === c)) || (((("\n" === c)) || ((c == null)))));
|
||||
});
|
||||
/**
|
||||
* Resolves syntactical sugar in metadata
|
||||
*/
|
||||
cljs.tools.reader.impl.utils.desugar_meta = (function cljs$tools$reader$impl$utils$desugar_meta(f){
|
||||
if((f instanceof cljs.core.Keyword)){
|
||||
return cljs.core.PersistentArrayMap.createAsIfByAssoc([f,true]);
|
||||
} else {
|
||||
if((f instanceof cljs.core.Symbol)){
|
||||
return new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,f], null);
|
||||
} else {
|
||||
if(typeof f === 'string'){
|
||||
return new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,f], null);
|
||||
} else {
|
||||
return f;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.utils.last_id = cljs.core.atom.cljs$core$IFn$_invoke$arity$1((0));
|
||||
cljs.tools.reader.impl.utils.next_id = (function cljs$tools$reader$impl$utils$next_id(){
|
||||
return cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$2(cljs.tools.reader.impl.utils.last_id,cljs.core.inc);
|
||||
});
|
||||
cljs.tools.reader.impl.utils.namespace_keys = (function cljs$tools$reader$impl$utils$namespace_keys(ns,keys){
|
||||
var iter__5523__auto__ = (function cljs$tools$reader$impl$utils$namespace_keys_$_iter__5254(s__5255){
|
||||
return (new cljs.core.LazySeq(null,(function (){
|
||||
var s__5255__$1 = s__5255;
|
||||
while(true){
|
||||
var temp__4657__auto__ = cljs.core.seq(s__5255__$1);
|
||||
if(temp__4657__auto__){
|
||||
var s__5255__$2 = temp__4657__auto__;
|
||||
if(cljs.core.chunked_seq_QMARK_(s__5255__$2)){
|
||||
var c__5521__auto__ = cljs.core.chunk_first(s__5255__$2);
|
||||
var size__5522__auto__ = cljs.core.count(c__5521__auto__);
|
||||
var b__5257 = cljs.core.chunk_buffer(size__5522__auto__);
|
||||
if((function (){var i__5256 = (0);
|
||||
while(true){
|
||||
if((i__5256 < size__5522__auto__)){
|
||||
var key = cljs.core._nth.cljs$core$IFn$_invoke$arity$2(c__5521__auto__,i__5256);
|
||||
cljs.core.chunk_append(b__5257,(((((key instanceof cljs.core.Symbol)) || ((key instanceof cljs.core.Keyword))))?(function (){var vec__5258 = (function (){var fexpr__5261 = cljs.core.juxt.cljs$core$IFn$_invoke$arity$2(cljs.core.namespace,cljs.core.name);
|
||||
return (fexpr__5261.cljs$core$IFn$_invoke$arity$1 ? fexpr__5261.cljs$core$IFn$_invoke$arity$1(key) : fexpr__5261.call(null,key));
|
||||
})();
|
||||
var key_ns = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5258,(0),null);
|
||||
var key_name = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5258,(1),null);
|
||||
var __GT_key = (((key instanceof cljs.core.Symbol))?cljs.core.symbol:cljs.core.keyword);
|
||||
if((key_ns == null)){
|
||||
return (__GT_key.cljs$core$IFn$_invoke$arity$2 ? __GT_key.cljs$core$IFn$_invoke$arity$2(ns,key_name) : __GT_key.call(null,ns,key_name));
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("_",key_ns)){
|
||||
return (__GT_key.cljs$core$IFn$_invoke$arity$1 ? __GT_key.cljs$core$IFn$_invoke$arity$1(key_name) : __GT_key.call(null,key_name));
|
||||
} else {
|
||||
return key;
|
||||
|
||||
}
|
||||
}
|
||||
})():key));
|
||||
|
||||
var G__5266 = (i__5256 + (1));
|
||||
i__5256 = G__5266;
|
||||
continue;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
})()){
|
||||
return cljs.core.chunk_cons(cljs.core.chunk(b__5257),cljs$tools$reader$impl$utils$namespace_keys_$_iter__5254(cljs.core.chunk_rest(s__5255__$2)));
|
||||
} else {
|
||||
return cljs.core.chunk_cons(cljs.core.chunk(b__5257),null);
|
||||
}
|
||||
} else {
|
||||
var key = cljs.core.first(s__5255__$2);
|
||||
return cljs.core.cons((((((key instanceof cljs.core.Symbol)) || ((key instanceof cljs.core.Keyword))))?(function (){var vec__5262 = (function (){var fexpr__5265 = cljs.core.juxt.cljs$core$IFn$_invoke$arity$2(cljs.core.namespace,cljs.core.name);
|
||||
return (fexpr__5265.cljs$core$IFn$_invoke$arity$1 ? fexpr__5265.cljs$core$IFn$_invoke$arity$1(key) : fexpr__5265.call(null,key));
|
||||
})();
|
||||
var key_ns = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5262,(0),null);
|
||||
var key_name = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5262,(1),null);
|
||||
var __GT_key = (((key instanceof cljs.core.Symbol))?cljs.core.symbol:cljs.core.keyword);
|
||||
if((key_ns == null)){
|
||||
return (__GT_key.cljs$core$IFn$_invoke$arity$2 ? __GT_key.cljs$core$IFn$_invoke$arity$2(ns,key_name) : __GT_key.call(null,ns,key_name));
|
||||
} else {
|
||||
if(cljs.core._EQ_.cljs$core$IFn$_invoke$arity$2("_",key_ns)){
|
||||
return (__GT_key.cljs$core$IFn$_invoke$arity$1 ? __GT_key.cljs$core$IFn$_invoke$arity$1(key_name) : __GT_key.call(null,key_name));
|
||||
} else {
|
||||
return key;
|
||||
|
||||
}
|
||||
}
|
||||
})():key),cljs$tools$reader$impl$utils$namespace_keys_$_iter__5254(cljs.core.rest(s__5255__$2)));
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}),null,null));
|
||||
});
|
||||
return iter__5523__auto__(keys);
|
||||
});
|
||||
cljs.tools.reader.impl.utils.second_SINGLEQUOTE_ = (function cljs$tools$reader$impl$utils$second_SINGLEQUOTE_(p__5267){
|
||||
var vec__5268 = p__5267;
|
||||
var a = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5268,(0),null);
|
||||
var b = cljs.core.nth.cljs$core$IFn$_invoke$arity$3(vec__5268,(1),null);
|
||||
if(cljs.core.truth_(a)){
|
||||
return null;
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.impl.utils.char_code = (function cljs$tools$reader$impl$utils$char_code(ch,base){
|
||||
var code = parseInt(ch,base);
|
||||
if(cljs.core.truth_(isNaN(code))){
|
||||
return (-1);
|
||||
} else {
|
||||
return code;
|
||||
}
|
||||
});
|
||||
Executable
+283
@@ -0,0 +1,283 @@
|
||||
;; Copyright (c) Nicola Mometto, Rich Hickey & contributors.
|
||||
;; The use and distribution terms for this software are covered by the
|
||||
;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
|
||||
;; which can be found in the file epl-v10.html at the root of this distribution.
|
||||
;; By using this software in any fashion, you are agreeing to be bound by
|
||||
;; the terms of this license.
|
||||
;; You must not remove this notice, or any other, from this software.
|
||||
|
||||
(ns ^{:doc "Protocols and default Reader types implementation"
|
||||
:author "Bronsa"}
|
||||
cljs.tools.reader.reader-types
|
||||
(:refer-clojure :exclude [char read-line])
|
||||
(:require [cljs.tools.reader.impl.utils :refer [char whitespace? newline?]]
|
||||
[goog.string])
|
||||
(:import goog.string.StringBuffer))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; reader protocols
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defprotocol Reader
|
||||
(read-char [reader]
|
||||
"Returns the next char from the Reader, nil if the end of stream has been reached")
|
||||
(peek-char [reader]
|
||||
"Returns the next char from the Reader without removing it from the reader stream"))
|
||||
|
||||
(defprotocol IPushbackReader
|
||||
(unread [reader ch]
|
||||
"Pushes back a single character on to the stream"))
|
||||
|
||||
(defprotocol IndexingReader
|
||||
(get-line-number [reader]
|
||||
"Returns the line number of the next character to be read from the stream")
|
||||
(get-column-number [reader]
|
||||
"Returns the column number of the next character to be read from the stream")
|
||||
(get-file-name [reader]
|
||||
"Returns the file name the reader is reading from, or nil"))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; reader deftypes
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(deftype StringReader
|
||||
[s s-len ^:mutable s-pos]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(when (> s-len s-pos)
|
||||
(let [r (.charAt s s-pos)]
|
||||
(set! s-pos (inc s-pos))
|
||||
r)))
|
||||
(peek-char [reader]
|
||||
(when (> s-len s-pos)
|
||||
(.charAt s s-pos))))
|
||||
|
||||
(deftype NodeReadableReader [readable ^:mutable buf]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(if buf
|
||||
(let [c (aget buf 0)]
|
||||
(set! buf nil)
|
||||
(char c))
|
||||
(let [c (str (.read readable 1))]
|
||||
(when c
|
||||
(char c)))))
|
||||
(peek-char [reader]
|
||||
(when-not buf
|
||||
(set! buf (str (.read readable 1))))
|
||||
(when buf
|
||||
(char (aget buf 0)))))
|
||||
|
||||
(deftype PushbackReader
|
||||
[^not-native rdr buf buf-len ^:mutable buf-pos]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(let [c (if (< buf-pos buf-len)
|
||||
(aget buf buf-pos)
|
||||
(read-char rdr))]
|
||||
(when (< buf-pos buf-len)
|
||||
(set! buf-pos (inc buf-pos)))
|
||||
(char c)))
|
||||
(peek-char [reader]
|
||||
(let [c (if (< buf-pos buf-len)
|
||||
(aget buf buf-pos)
|
||||
(peek-char rdr))]
|
||||
(char c)))
|
||||
IPushbackReader
|
||||
(unread [reader ch]
|
||||
(when ch
|
||||
(if (zero? buf-pos) (throw (js/Error. "Pushback buffer is full")))
|
||||
(set! buf-pos (dec buf-pos))
|
||||
(aset buf buf-pos ch))))
|
||||
|
||||
(defn- normalize-newline [^not-native rdr ch]
|
||||
(if (identical? \return ch)
|
||||
(let [c (peek-char rdr)]
|
||||
(when (or (identical? \formfeed c)
|
||||
(identical? \newline c))
|
||||
(read-char rdr))
|
||||
\newline)
|
||||
ch))
|
||||
|
||||
(deftype IndexingPushbackReader
|
||||
[^not-native rdr ^:mutable line ^:mutable column
|
||||
^:mutable line-start? ^:mutable prev
|
||||
^:mutable prev-column file-name]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(when-let [ch (read-char rdr)]
|
||||
(let [ch (normalize-newline rdr ch)]
|
||||
(set! prev line-start?)
|
||||
(set! line-start? (newline? ch))
|
||||
(when line-start?
|
||||
(set! prev-column column)
|
||||
(set! column 0)
|
||||
(set! line (inc line)))
|
||||
(set! column (inc column))
|
||||
ch)))
|
||||
|
||||
(peek-char [reader]
|
||||
(peek-char rdr))
|
||||
|
||||
IPushbackReader
|
||||
(unread [reader ch]
|
||||
(if line-start?
|
||||
(do (set! line (dec line))
|
||||
(set! column prev-column))
|
||||
(set! column (dec column)))
|
||||
(set! line-start? prev)
|
||||
(unread rdr ch))
|
||||
|
||||
IndexingReader
|
||||
(get-line-number [reader] (int line))
|
||||
(get-column-number [reader] (int column))
|
||||
(get-file-name [reader] file-name))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Source Logging support
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defn merge-meta
|
||||
"Returns an object of the same type and value as `obj`, with its
|
||||
metadata merged over `m`."
|
||||
[obj m]
|
||||
(let [orig-meta (meta obj)]
|
||||
(with-meta obj (merge m (dissoc orig-meta :source)))))
|
||||
|
||||
(defn- peek-source-log
|
||||
"Returns a string containing the contents of the top most source
|
||||
logging frame."
|
||||
[frames]
|
||||
(subs (str (:buffer frames)) (first (:offset frames))))
|
||||
|
||||
(defn- log-source-char
|
||||
"Logs `char` to all currently active source logging frames."
|
||||
[frames char]
|
||||
(when-let [buffer (:buffer frames)]
|
||||
(.append buffer char)))
|
||||
|
||||
(defn- drop-last-logged-char
|
||||
"Removes the last logged character from all currently active source
|
||||
logging frames. Called when pushing a character back."
|
||||
[frames]
|
||||
(when-let [buffer (:buffer frames)]
|
||||
(.set buffer (subs (str buffer) 0 (dec (.getLength buffer))))))
|
||||
|
||||
(deftype SourceLoggingPushbackReader
|
||||
[^not-native rdr ^:mutable line ^:mutable column
|
||||
^:mutable line-start? ^:mutable prev
|
||||
^:mutable prev-column file-name frames]
|
||||
Reader
|
||||
(read-char [reader]
|
||||
(when-let [ch (read-char rdr)]
|
||||
(let [ch (normalize-newline rdr ch)]
|
||||
(set! prev line-start?)
|
||||
(set! line-start? (newline? ch))
|
||||
(when line-start?
|
||||
(set! prev-column column)
|
||||
(set! column 0)
|
||||
(set! line (inc line)))
|
||||
(set! column (inc column))
|
||||
(log-source-char @frames ch)
|
||||
ch)))
|
||||
|
||||
(peek-char [reader]
|
||||
(peek-char rdr))
|
||||
|
||||
IPushbackReader
|
||||
(unread [reader ch]
|
||||
(if line-start?
|
||||
(do (set! line (dec line))
|
||||
(set! column prev-column))
|
||||
(set! column (dec column)))
|
||||
(set! line-start? prev)
|
||||
(when ch
|
||||
(drop-last-logged-char @frames))
|
||||
(unread rdr ch))
|
||||
|
||||
IndexingReader
|
||||
(get-line-number [reader] (int line))
|
||||
(get-column-number [reader] (int column))
|
||||
(get-file-name [reader] file-name))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Public API
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; fast check for provided implementations
|
||||
(defn indexing-reader?
|
||||
"Returns true if the reader satisfies IndexingReader"
|
||||
[rdr]
|
||||
(implements? IndexingReader rdr))
|
||||
|
||||
(defn string-reader
|
||||
"Creates a StringReader from a given string"
|
||||
([s]
|
||||
(StringReader. s (count s) 0)))
|
||||
|
||||
(defn string-push-back-reader
|
||||
"Creates a PushbackReader from a given string"
|
||||
([s]
|
||||
(string-push-back-reader s 1))
|
||||
([s buf-len]
|
||||
(PushbackReader. (string-reader s) (object-array buf-len) buf-len buf-len)))
|
||||
|
||||
(defn node-readable-push-back-reader [readable]
|
||||
(PushbackReader. (NodeReadableReader. readable nil) (object-array 1) 1 1))
|
||||
|
||||
(defn indexing-push-back-reader
|
||||
"Creates an IndexingPushbackReader from a given string or PushbackReader"
|
||||
([s-or-rdr]
|
||||
(indexing-push-back-reader s-or-rdr 1))
|
||||
([s-or-rdr buf-len]
|
||||
(indexing-push-back-reader s-or-rdr buf-len nil))
|
||||
([s-or-rdr buf-len file-name]
|
||||
(IndexingPushbackReader.
|
||||
(if (string? s-or-rdr) (string-push-back-reader s-or-rdr buf-len) s-or-rdr) 1 1 true nil 0 file-name)))
|
||||
|
||||
(defn source-logging-push-back-reader
|
||||
"Creates a SourceLoggingPushbackReader from a given string or PushbackReader"
|
||||
([s-or-rdr]
|
||||
(source-logging-push-back-reader s-or-rdr 1))
|
||||
([s-or-rdr buf-len]
|
||||
(source-logging-push-back-reader s-or-rdr buf-len nil))
|
||||
([s-or-rdr buf-len file-name]
|
||||
(SourceLoggingPushbackReader.
|
||||
(if (string? s-or-rdr) (string-push-back-reader s-or-rdr buf-len) s-or-rdr)
|
||||
1
|
||||
1
|
||||
true
|
||||
nil
|
||||
0
|
||||
file-name
|
||||
(atom {:buffer (StringBuffer.) :offset '(0)}))))
|
||||
|
||||
(defn read-line
|
||||
"Reads a line from the reader or from *in* if no reader is specified"
|
||||
([^not-native rdr]
|
||||
(loop [c (read-char rdr) s (StringBuffer.)]
|
||||
(if (newline? c)
|
||||
(str s)
|
||||
(recur (read-char rdr) (.append s c))))))
|
||||
|
||||
(defn ^boolean source-logging-reader?
|
||||
[rdr]
|
||||
(instance? SourceLoggingPushbackReader rdr))
|
||||
|
||||
(defn ^boolean line-start?
|
||||
"Returns true if rdr is an IndexingReader and the current char starts a new line"
|
||||
[^not-native rdr]
|
||||
(when (indexing-reader? rdr)
|
||||
(== 1 (get-column-number rdr))))
|
||||
|
||||
(defn log-source*
|
||||
[reader f]
|
||||
(let [buffer (:buffer @(.-frames reader))]
|
||||
(try
|
||||
(swap! (.-frames reader) update-in [:offset] conj (.getLength buffer))
|
||||
(let [ret (f)]
|
||||
(if (implements? IMeta ret)
|
||||
(merge-meta ret {:source (peek-source-log @ (.-frames reader))})
|
||||
ret))
|
||||
(finally
|
||||
(swap! (.-frames reader) update-in [:offset] rest)))))
|
||||
|
||||
Executable
+815
@@ -0,0 +1,815 @@
|
||||
// Compiled by ClojureScript 1.11.60 {:static-fns true, :optimize-constants true, :optimizations :advanced}
|
||||
goog.provide('cljs.tools.reader.reader_types');
|
||||
goog.require('cljs.core');
|
||||
goog.require('cljs.core.constants');
|
||||
goog.require('cljs.tools.reader.impl.utils');
|
||||
goog.require('goog.string');
|
||||
goog.require('goog.string.StringBuffer');
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.tools.reader.reader_types.Reader = function(){};
|
||||
|
||||
var cljs$tools$reader$reader_types$Reader$read_char$dyn_5273 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.read_char[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.read_char["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Reader.read-char",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the next char from the Reader, nil if the end of stream has been reached
|
||||
*/
|
||||
cljs.tools.reader.reader_types.read_char = (function cljs$tools$reader$reader_types$read_char(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$Reader$read_char$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$Reader$read_char$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$Reader$read_char$dyn_5273(reader);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$tools$reader$reader_types$Reader$peek_char$dyn_5274 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.peek_char[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.peek_char["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("Reader.peek-char",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the next char from the Reader without removing it from the reader stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.peek_char = (function cljs$tools$reader$reader_types$peek_char(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$Reader$peek_char$dyn_5274(reader);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.tools.reader.reader_types.IPushbackReader = function(){};
|
||||
|
||||
var cljs$tools$reader$reader_types$IPushbackReader$unread$dyn_5275 = (function (reader,ch){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.unread[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$2(reader,ch) : m__5394__auto__.call(null,reader,ch));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.unread["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$2 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$2(reader,ch) : m__5392__auto__.call(null,reader,ch));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("IPushbackReader.unread",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Pushes back a single character on to the stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.unread = (function cljs$tools$reader$reader_types$unread(reader,ch){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2(reader,ch);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$IPushbackReader$unread$dyn_5275(reader,ch);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @interface
|
||||
*/
|
||||
cljs.tools.reader.reader_types.IndexingReader = function(){};
|
||||
|
||||
var cljs$tools$reader$reader_types$IndexingReader$get_line_number$dyn_5276 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.get_line_number[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.get_line_number["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("IndexingReader.get-line-number",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the line number of the next character to be read from the stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.get_line_number = (function cljs$tools$reader$reader_types$get_line_number(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$IndexingReader$get_line_number$dyn_5276(reader);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$tools$reader$reader_types$IndexingReader$get_column_number$dyn_5277 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.get_column_number[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.get_column_number["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("IndexingReader.get-column-number",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the column number of the next character to be read from the stream
|
||||
*/
|
||||
cljs.tools.reader.reader_types.get_column_number = (function cljs$tools$reader$reader_types$get_column_number(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$IndexingReader$get_column_number$dyn_5277(reader);
|
||||
}
|
||||
});
|
||||
|
||||
var cljs$tools$reader$reader_types$IndexingReader$get_file_name$dyn_5278 = (function (reader){
|
||||
var x__5393__auto__ = (((reader == null))?null:reader);
|
||||
var m__5394__auto__ = (cljs.tools.reader.reader_types.get_file_name[goog.typeOf(x__5393__auto__)]);
|
||||
if((!((m__5394__auto__ == null)))){
|
||||
return (m__5394__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5394__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5394__auto__.call(null,reader));
|
||||
} else {
|
||||
var m__5392__auto__ = (cljs.tools.reader.reader_types.get_file_name["_"]);
|
||||
if((!((m__5392__auto__ == null)))){
|
||||
return (m__5392__auto__.cljs$core$IFn$_invoke$arity$1 ? m__5392__auto__.cljs$core$IFn$_invoke$arity$1(reader) : m__5392__auto__.call(null,reader));
|
||||
} else {
|
||||
throw cljs.core.missing_protocol("IndexingReader.get-file-name",reader);
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Returns the file name the reader is reading from, or nil
|
||||
*/
|
||||
cljs.tools.reader.reader_types.get_file_name = (function cljs$tools$reader$reader_types$get_file_name(reader){
|
||||
if((((!((reader == null)))) && ((!((reader.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1 == null)))))){
|
||||
return reader.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1(reader);
|
||||
} else {
|
||||
return cljs$tools$reader$reader_types$IndexingReader$get_file_name$dyn_5278(reader);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.StringReader = (function (s,s_len,s_pos){
|
||||
this.s = s;
|
||||
this.s_len = s_len;
|
||||
this.s_pos = s_pos;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.StringReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if((self__.s_len > self__.s_pos)){
|
||||
var r = self__.s.charAt(self__.s_pos);
|
||||
(self__.s_pos = (self__.s_pos + (1)));
|
||||
|
||||
return r;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if((self__.s_len > self__.s_pos)){
|
||||
return self__.s.charAt(self__.s_pos);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$s,cljs.core.cst$sym$s_DASH_len,cljs.core.with_meta(cljs.core.cst$sym$s_DASH_pos,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null))], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/StringReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.StringReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/StringReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/StringReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_StringReader = (function cljs$tools$reader$reader_types$__GT_StringReader(s,s_len,s_pos){
|
||||
return (new cljs.tools.reader.reader_types.StringReader(s,s_len,s_pos));
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.NodeReadableReader = (function (readable,buf){
|
||||
this.readable = readable;
|
||||
this.buf = buf;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
var c = (self__.buf[(0)]);
|
||||
(self__.buf = null);
|
||||
|
||||
return cljs.tools.reader.impl.utils.char$(c);
|
||||
} else {
|
||||
var c = cljs.core.str.cljs$core$IFn$_invoke$arity$1(self__.readable.read((1)));
|
||||
if(cljs.core.truth_(c)){
|
||||
return cljs.tools.reader.impl.utils.char$(c);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
} else {
|
||||
(self__.buf = cljs.core.str.cljs$core$IFn$_invoke$arity$1(self__.readable.read((1))));
|
||||
}
|
||||
|
||||
if(cljs.core.truth_(self__.buf)){
|
||||
return cljs.tools.reader.impl.utils.char$((self__.buf[(0)]));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$sym$readable,cljs.core.with_meta(cljs.core.cst$sym$buf,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null))], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/NodeReadableReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.NodeReadableReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/NodeReadableReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/NodeReadableReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_NodeReadableReader = (function cljs$tools$reader$reader_types$__GT_NodeReadableReader(readable,buf){
|
||||
return (new cljs.tools.reader.reader_types.NodeReadableReader(readable,buf));
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
* @implements {cljs.tools.reader.reader_types.IPushbackReader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.PushbackReader = (function (rdr,buf,buf_len,buf_pos){
|
||||
this.rdr = rdr;
|
||||
this.buf = buf;
|
||||
this.buf_len = buf_len;
|
||||
this.buf_pos = buf_pos;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var c = (((self__.buf_pos < self__.buf_len))?(self__.buf[self__.buf_pos]):self__.rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null));
|
||||
if((self__.buf_pos < self__.buf_len)){
|
||||
(self__.buf_pos = (self__.buf_pos + (1)));
|
||||
} else {
|
||||
}
|
||||
|
||||
return cljs.tools.reader.impl.utils.char$(c);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var c = (((self__.buf_pos < self__.buf_len))?(self__.buf[self__.buf_pos]):self__.rdr.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null));
|
||||
return cljs.tools.reader.impl.utils.char$(c);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 = (function (reader,ch){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(ch)){
|
||||
if((self__.buf_pos === (0))){
|
||||
throw (new Error("Pushback buffer is full"));
|
||||
} else {
|
||||
}
|
||||
|
||||
(self__.buf_pos = (self__.buf_pos - (1)));
|
||||
|
||||
return (self__.buf[self__.buf_pos] = ch);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(cljs.core.cst$sym$rdr,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,cljs.core.cst$sym$not_DASH_native], null)),cljs.core.cst$sym$buf,cljs.core.cst$sym$buf_DASH_len,cljs.core.with_meta(cljs.core.cst$sym$buf_DASH_pos,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null))], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/PushbackReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.PushbackReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/PushbackReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/PushbackReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_PushbackReader = (function cljs$tools$reader$reader_types$__GT_PushbackReader(rdr,buf,buf_len,buf_pos){
|
||||
return (new cljs.tools.reader.reader_types.PushbackReader(rdr,buf,buf_len,buf_pos));
|
||||
});
|
||||
|
||||
cljs.tools.reader.reader_types.normalize_newline = (function cljs$tools$reader$reader_types$normalize_newline(rdr,ch){
|
||||
if(("\r" === ch)){
|
||||
var c = rdr.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null);
|
||||
if(((("\f" === c)) || (("\n" === c)))){
|
||||
rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
} else {
|
||||
}
|
||||
|
||||
return "\n";
|
||||
} else {
|
||||
return ch;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.IndexingReader}
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
* @implements {cljs.tools.reader.reader_types.IPushbackReader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.IndexingPushbackReader = (function (rdr,line,column,line_start_QMARK_,prev,prev_column,file_name){
|
||||
this.rdr = rdr;
|
||||
this.line = line;
|
||||
this.column = column;
|
||||
this.line_start_QMARK_ = line_start_QMARK_;
|
||||
this.prev = prev;
|
||||
this.prev_column = prev_column;
|
||||
this.file_name = file_name;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var temp__4657__auto__ = self__.rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var ch = temp__4657__auto__;
|
||||
var ch__$1 = cljs.tools.reader.reader_types.normalize_newline(self__.rdr,ch);
|
||||
(self__.prev = self__.line_start_QMARK_);
|
||||
|
||||
(self__.line_start_QMARK_ = cljs.tools.reader.impl.utils.newline_QMARK_(ch__$1));
|
||||
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
(self__.prev_column = self__.column);
|
||||
|
||||
(self__.column = (0));
|
||||
|
||||
(self__.line = (self__.line + (1)));
|
||||
} else {
|
||||
}
|
||||
|
||||
(self__.column = (self__.column + (1)));
|
||||
|
||||
return ch__$1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.rdr.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 = (function (reader,ch){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
(self__.line = (self__.line - (1)));
|
||||
|
||||
(self__.column = self__.prev_column);
|
||||
} else {
|
||||
(self__.column = (self__.column - (1)));
|
||||
}
|
||||
|
||||
(self__.line_start_QMARK_ = self__.prev);
|
||||
|
||||
return self__.rdr.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2(null,ch);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.line | (0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.column | (0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.file_name;
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 7, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(cljs.core.cst$sym$rdr,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,cljs.core.cst$sym$not_DASH_native], null)),cljs.core.with_meta(cljs.core.cst$sym$line,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$column,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$line_DASH_start_QMARK_,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$prev,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$prev_DASH_column,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.cst$sym$file_DASH_name], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/IndexingPushbackReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.IndexingPushbackReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/IndexingPushbackReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/IndexingPushbackReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_IndexingPushbackReader = (function cljs$tools$reader$reader_types$__GT_IndexingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name){
|
||||
return (new cljs.tools.reader.reader_types.IndexingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name));
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns an object of the same type and value as `obj`, with its
|
||||
* metadata merged over `m`.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.merge_meta = (function cljs$tools$reader$reader_types$merge_meta(obj,m){
|
||||
var orig_meta = cljs.core.meta(obj);
|
||||
return cljs.core.with_meta(obj,cljs.core.merge.cljs$core$IFn$_invoke$arity$variadic(cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([m,cljs.core.dissoc.cljs$core$IFn$_invoke$arity$2(orig_meta,cljs.core.cst$kw$source)], 0)));
|
||||
});
|
||||
/**
|
||||
* Returns a string containing the contents of the top most source
|
||||
* logging frame.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.peek_source_log = (function cljs$tools$reader$reader_types$peek_source_log(frames){
|
||||
return cljs.core.subs.cljs$core$IFn$_invoke$arity$2(cljs.core.str.cljs$core$IFn$_invoke$arity$1(cljs.core.cst$kw$buffer.cljs$core$IFn$_invoke$arity$1(frames)),cljs.core.first(cljs.core.cst$kw$offset.cljs$core$IFn$_invoke$arity$1(frames)));
|
||||
});
|
||||
/**
|
||||
* Logs `char` to all currently active source logging frames.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.log_source_char = (function cljs$tools$reader$reader_types$log_source_char(frames,char$){
|
||||
var temp__4657__auto__ = cljs.core.cst$kw$buffer.cljs$core$IFn$_invoke$arity$1(frames);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var buffer = temp__4657__auto__;
|
||||
return buffer.append(char$);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Removes the last logged character from all currently active source
|
||||
* logging frames. Called when pushing a character back.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.drop_last_logged_char = (function cljs$tools$reader$reader_types$drop_last_logged_char(frames){
|
||||
var temp__4657__auto__ = cljs.core.cst$kw$buffer.cljs$core$IFn$_invoke$arity$1(frames);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var buffer = temp__4657__auto__;
|
||||
return buffer.set(cljs.core.subs.cljs$core$IFn$_invoke$arity$3(cljs.core.str.cljs$core$IFn$_invoke$arity$1(buffer),(0),(buffer.getLength() - (1))));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @implements {cljs.tools.reader.reader_types.IndexingReader}
|
||||
* @implements {cljs.tools.reader.reader_types.Reader}
|
||||
* @implements {cljs.tools.reader.reader_types.IPushbackReader}
|
||||
*/
|
||||
cljs.tools.reader.reader_types.SourceLoggingPushbackReader = (function (rdr,line,column,line_start_QMARK_,prev,prev_column,file_name,frames){
|
||||
this.rdr = rdr;
|
||||
this.line = line;
|
||||
this.column = column;
|
||||
this.line_start_QMARK_ = line_start_QMARK_;
|
||||
this.prev = prev;
|
||||
this.prev_column = prev_column;
|
||||
this.file_name = file_name;
|
||||
this.frames = frames;
|
||||
});
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$read_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
var temp__4657__auto__ = self__.rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
if(cljs.core.truth_(temp__4657__auto__)){
|
||||
var ch = temp__4657__auto__;
|
||||
var ch__$1 = cljs.tools.reader.reader_types.normalize_newline(self__.rdr,ch);
|
||||
(self__.prev = self__.line_start_QMARK_);
|
||||
|
||||
(self__.line_start_QMARK_ = cljs.tools.reader.impl.utils.newline_QMARK_(ch__$1));
|
||||
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
(self__.prev_column = self__.column);
|
||||
|
||||
(self__.column = (0));
|
||||
|
||||
(self__.line = (self__.line + (1)));
|
||||
} else {
|
||||
}
|
||||
|
||||
(self__.column = (self__.column + (1)));
|
||||
|
||||
cljs.tools.reader.reader_types.log_source_char(cljs.core.deref(self__.frames),ch__$1);
|
||||
|
||||
return ch__$1;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$Reader$peek_char$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.rdr.cljs$tools$reader$reader_types$Reader$peek_char$arity$1(null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2 = (function (reader,ch){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
if(cljs.core.truth_(self__.line_start_QMARK_)){
|
||||
(self__.line = (self__.line - (1)));
|
||||
|
||||
(self__.column = self__.prev_column);
|
||||
} else {
|
||||
(self__.column = (self__.column - (1)));
|
||||
}
|
||||
|
||||
(self__.line_start_QMARK_ = self__.prev);
|
||||
|
||||
if(cljs.core.truth_(ch)){
|
||||
cljs.tools.reader.reader_types.drop_last_logged_char(cljs.core.deref(self__.frames));
|
||||
} else {
|
||||
}
|
||||
|
||||
return self__.rdr.cljs$tools$reader$reader_types$IPushbackReader$unread$arity$2(null,ch);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$ = cljs.core.PROTOCOL_SENTINEL);
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_line_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.line | (0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return (self__.column | (0));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.prototype.cljs$tools$reader$reader_types$IndexingReader$get_file_name$arity$1 = (function (reader){
|
||||
var self__ = this;
|
||||
var reader__$1 = this;
|
||||
return self__.file_name;
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.getBasis = (function (){
|
||||
return new cljs.core.PersistentVector(null, 8, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.with_meta(cljs.core.cst$sym$rdr,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$tag,cljs.core.cst$sym$not_DASH_native], null)),cljs.core.with_meta(cljs.core.cst$sym$line,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$column,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$line_DASH_start_QMARK_,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$prev,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.with_meta(cljs.core.cst$sym$prev_DASH_column,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$mutable,true], null)),cljs.core.cst$sym$file_DASH_name,cljs.core.cst$sym$frames], null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.cljs$lang$type = true);
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.cljs$lang$ctorStr = "cljs.tools.reader.reader-types/SourceLoggingPushbackReader");
|
||||
|
||||
(cljs.tools.reader.reader_types.SourceLoggingPushbackReader.cljs$lang$ctorPrWriter = (function (this__5330__auto__,writer__5331__auto__,opt__5332__auto__){
|
||||
return cljs.core._write(writer__5331__auto__,"cljs.tools.reader.reader-types/SourceLoggingPushbackReader");
|
||||
}));
|
||||
|
||||
/**
|
||||
* Positional factory function for cljs.tools.reader.reader-types/SourceLoggingPushbackReader.
|
||||
*/
|
||||
cljs.tools.reader.reader_types.__GT_SourceLoggingPushbackReader = (function cljs$tools$reader$reader_types$__GT_SourceLoggingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name,frames){
|
||||
return (new cljs.tools.reader.reader_types.SourceLoggingPushbackReader(rdr,line,column,line_start_QMARK_,prev,prev_column,file_name,frames));
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns true if the reader satisfies IndexingReader
|
||||
*/
|
||||
cljs.tools.reader.reader_types.indexing_reader_QMARK_ = (function cljs$tools$reader$reader_types$indexing_reader_QMARK_(rdr){
|
||||
if((!((rdr == null)))){
|
||||
if(((false) || ((cljs.core.PROTOCOL_SENTINEL === rdr.cljs$tools$reader$reader_types$IndexingReader$)))){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
/**
|
||||
* Creates a StringReader from a given string
|
||||
*/
|
||||
cljs.tools.reader.reader_types.string_reader = (function cljs$tools$reader$reader_types$string_reader(s){
|
||||
return (new cljs.tools.reader.reader_types.StringReader(s,cljs.core.count(s),(0)));
|
||||
});
|
||||
/**
|
||||
* Creates a PushbackReader from a given string
|
||||
*/
|
||||
cljs.tools.reader.reader_types.string_push_back_reader = (function cljs$tools$reader$reader_types$string_push_back_reader(var_args){
|
||||
var G__5281 = arguments.length;
|
||||
switch (G__5281) {
|
||||
case 1:
|
||||
return cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$1 = (function (s){
|
||||
return cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2(s,(1));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2 = (function (s,buf_len){
|
||||
return (new cljs.tools.reader.reader_types.PushbackReader(cljs.tools.reader.reader_types.string_reader(s),cljs.core.object_array.cljs$core$IFn$_invoke$arity$1(buf_len),buf_len,buf_len));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.string_push_back_reader.cljs$lang$maxFixedArity = 2);
|
||||
|
||||
cljs.tools.reader.reader_types.node_readable_push_back_reader = (function cljs$tools$reader$reader_types$node_readable_push_back_reader(readable){
|
||||
return (new cljs.tools.reader.reader_types.PushbackReader((new cljs.tools.reader.reader_types.NodeReadableReader(readable,null)),cljs.core.object_array.cljs$core$IFn$_invoke$arity$1((1)),(1),(1)));
|
||||
});
|
||||
/**
|
||||
* Creates an IndexingPushbackReader from a given string or PushbackReader
|
||||
*/
|
||||
cljs.tools.reader.reader_types.indexing_push_back_reader = (function cljs$tools$reader$reader_types$indexing_push_back_reader(var_args){
|
||||
var G__5284 = arguments.length;
|
||||
switch (G__5284) {
|
||||
case 1:
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$1 = (function (s_or_rdr){
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$2(s_or_rdr,(1));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$2 = (function (s_or_rdr,buf_len){
|
||||
return cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$3(s_or_rdr,buf_len,null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$core$IFn$_invoke$arity$3 = (function (s_or_rdr,buf_len,file_name){
|
||||
return (new cljs.tools.reader.reader_types.IndexingPushbackReader(((typeof s_or_rdr === 'string')?cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2(s_or_rdr,buf_len):s_or_rdr),(1),(1),true,null,(0),file_name));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.indexing_push_back_reader.cljs$lang$maxFixedArity = 3);
|
||||
|
||||
/**
|
||||
* Creates a SourceLoggingPushbackReader from a given string or PushbackReader
|
||||
*/
|
||||
cljs.tools.reader.reader_types.source_logging_push_back_reader = (function cljs$tools$reader$reader_types$source_logging_push_back_reader(var_args){
|
||||
var G__5287 = arguments.length;
|
||||
switch (G__5287) {
|
||||
case 1:
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));
|
||||
|
||||
break;
|
||||
case 2:
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));
|
||||
|
||||
break;
|
||||
case 3:
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$3((arguments[(0)]),(arguments[(1)]),(arguments[(2)]));
|
||||
|
||||
break;
|
||||
default:
|
||||
throw (new Error(["Invalid arity: ",cljs.core.str.cljs$core$IFn$_invoke$arity$1(arguments.length)].join('')));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
(cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$1 = (function (s_or_rdr){
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$2(s_or_rdr,(1));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$2 = (function (s_or_rdr,buf_len){
|
||||
return cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$3(s_or_rdr,buf_len,null);
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$core$IFn$_invoke$arity$3 = (function (s_or_rdr,buf_len,file_name){
|
||||
return (new cljs.tools.reader.reader_types.SourceLoggingPushbackReader(((typeof s_or_rdr === 'string')?cljs.tools.reader.reader_types.string_push_back_reader.cljs$core$IFn$_invoke$arity$2(s_or_rdr,buf_len):s_or_rdr),(1),(1),true,null,(0),file_name,cljs.core.atom.cljs$core$IFn$_invoke$arity$1(new cljs.core.PersistentArrayMap(null, 2, [cljs.core.cst$kw$buffer,(new goog.string.StringBuffer()),cljs.core.cst$kw$offset,cljs.core.list((0))], null))));
|
||||
}));
|
||||
|
||||
(cljs.tools.reader.reader_types.source_logging_push_back_reader.cljs$lang$maxFixedArity = 3);
|
||||
|
||||
/**
|
||||
* Reads a line from the reader or from *in* if no reader is specified
|
||||
*/
|
||||
cljs.tools.reader.reader_types.read_line = (function cljs$tools$reader$reader_types$read_line(rdr){
|
||||
var c = rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
var s = (new goog.string.StringBuffer());
|
||||
while(true){
|
||||
if(cljs.tools.reader.impl.utils.newline_QMARK_(c)){
|
||||
return cljs.core.str.cljs$core$IFn$_invoke$arity$1(s);
|
||||
} else {
|
||||
var G__5289 = rdr.cljs$tools$reader$reader_types$Reader$read_char$arity$1(null);
|
||||
var G__5290 = s.append(c);
|
||||
c = G__5289;
|
||||
s = G__5290;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.reader_types.source_logging_reader_QMARK_ = (function cljs$tools$reader$reader_types$source_logging_reader_QMARK_(rdr){
|
||||
return (rdr instanceof cljs.tools.reader.reader_types.SourceLoggingPushbackReader);
|
||||
});
|
||||
/**
|
||||
* Returns true if rdr is an IndexingReader and the current char starts a new line
|
||||
*/
|
||||
cljs.tools.reader.reader_types.line_start_QMARK_ = (function cljs$tools$reader$reader_types$line_start_QMARK_(rdr){
|
||||
if(cljs.tools.reader.reader_types.indexing_reader_QMARK_(rdr)){
|
||||
return ((1) === rdr.cljs$tools$reader$reader_types$IndexingReader$get_column_number$arity$1(null));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
cljs.tools.reader.reader_types.log_source_STAR_ = (function cljs$tools$reader$reader_types$log_source_STAR_(reader,f){
|
||||
var buffer = cljs.core.cst$kw$buffer.cljs$core$IFn$_invoke$arity$1(cljs.core.deref(reader.frames));
|
||||
try{cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$variadic(reader.frames,cljs.core.update_in,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$kw$offset], null),cljs.core.conj,cljs.core.prim_seq.cljs$core$IFn$_invoke$arity$2([buffer.getLength()], 0));
|
||||
|
||||
var ret = (f.cljs$core$IFn$_invoke$arity$0 ? f.cljs$core$IFn$_invoke$arity$0() : f.call(null));
|
||||
if((((!((ret == null))))?(((((ret.cljs$lang$protocol_mask$partition0$ & (131072))) || ((cljs.core.PROTOCOL_SENTINEL === ret.cljs$core$IMeta$))))?true:false):false)){
|
||||
return cljs.tools.reader.reader_types.merge_meta(ret,new cljs.core.PersistentArrayMap(null, 1, [cljs.core.cst$kw$source,cljs.tools.reader.reader_types.peek_source_log(cljs.core.deref(reader.frames))], null));
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
}finally {cljs.core.swap_BANG_.cljs$core$IFn$_invoke$arity$4(reader.frames,cljs.core.update_in,new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.cst$kw$offset], null),cljs.core.rest);
|
||||
}});
|
||||
Reference in New Issue
Block a user