extendable parsing function
(base/block-info (-parse (reader/create ":a"))) => {:type :token, :tag :keyword, :string ":a", :height 0, :width 2}
(base/block-info (-parse (reader/create ""
"")))
=> {:type :token, :tag :string, :string ""
"", :height 0, :width 4}
(base/block-info (-parse (reader/create ""\n""))) => {:type :token, :tag :string, :string ""\n"", :height 1, :width 1}
extendable parsing function (base/block-info (-parse (reader/create ":a"))) => {:type :token, :tag :keyword, :string ":a", :height 0, :width 2} (base/block-info (-parse (reader/create "\"\ \""))) => {:type :token, :tag :string, :string "\"\ \"", :height 0, :width 4} (base/block-info (-parse (reader/create "\"\n\""))) => {:type :token, :tag :string, :string "\"\n\"", :height 1, :width 1}
(delimiter-block? block)
checks if block is of tag :delimiter
(delimiter-block? (binding [end-delimiter (first "}")] (-parse (reader/create "}")))) => true
checks if block is of tag :delimiter (delimiter-block? (binding [*end-delimiter* (first "}")] (-parse (reader/create "}")))) => true
(eof-block? block)
checks if block is of tag :eof
(eof-block? (-parse (reader/create ""))) => true
checks if block is of tag :eof (eof-block? (-parse (reader/create ""))) => true
(parse-collection reader tag)
parses a collection
(-> (parse-collection (reader/create "#(+ 1 2 3 4)") :fn) (base/block-value)) => '(fn* [] (+ 1 2 3 4))
(-> (parse-collection (reader/create "(1 2 3 4)") :list) (base/block-value)) => '(1 2 3 4)
(-> (parse-collection (reader/create "[1 2 3 4]") :vector) (base/block-value)) => [1 2 3 4]
(-> (parse-collection (reader/create "{1 2 3 4}") :map) (base/block-value)) => {1 2, 3 4}
(-> (parse-collection (reader/create "#{1 2 3 4}") :set) (base/block-value)) => #{1 4 3 2}
(-> (parse-collection (reader/create "#[1 2 3 4]") :root) (base/block-value))
parses a collection (-> (parse-collection (reader/create "#(+ 1 2 3 4)") :fn) (base/block-value)) => '(fn* [] (+ 1 2 3 4)) (-> (parse-collection (reader/create "(1 2 3 4)") :list) (base/block-value)) => '(1 2 3 4) (-> (parse-collection (reader/create "[1 2 3 4]") :vector) (base/block-value)) => [1 2 3 4] (-> (parse-collection (reader/create "{1 2 3 4}") :map) (base/block-value)) => {1 2, 3 4} (-> (parse-collection (reader/create "#{1 2 3 4}") :set) (base/block-value)) => #{1 4 3 2} (-> (parse-collection (reader/create "#[1 2 3 4]") :root) (base/block-value))
(parse-comment reader)
creates a comment
(-> (reader/create ";this is a comment") parse-comment (base/block-info)) => {:type :comment, :tag :comment, :string ";this is a comment", :height 0, :width 18}
creates a comment (-> (reader/create ";this is a comment") parse-comment (base/block-info)) => {:type :comment, :tag :comment, :string ";this is a comment", :height 0, :width 18}
(parse-cons reader tag)
parses a cons
(-> (parse-cons (reader/create "~hello") :unquote) (base/block-value)) => '(unquote hello)
(-> (parse-cons (reader/create "~@hello") :unquote-splice) (base/block-value)) => '(unquote-splicing hello)
(-> (parse-cons (reader/create "^tag {:a 1}") :meta) (base/block-value) ((juxt meta identity))) => [{:tag 'tag} {:a 1}]
(-> (parse-cons (reader/create "@hello") :deref) (base/block-value)) => '(deref hello)
(-> (parse-cons (reader/create "`hello") :syntax) (base/block-value)) => '(quote std.block.parse-test/hello)
parses a cons (-> (parse-cons (reader/create "~hello") :unquote) (base/block-value)) => '(unquote hello) (-> (parse-cons (reader/create "~@hello") :unquote-splice) (base/block-value)) => '(unquote-splicing hello) (-> (parse-cons (reader/create "^tag {:a 1}") :meta) (base/block-value) ((juxt meta identity))) => [{:tag 'tag} {:a 1}] (-> (parse-cons (reader/create "@hello") :deref) (base/block-value)) => '(deref hello) (-> (parse-cons (reader/create "`hello") :syntax) (base/block-value)) => '(quote std.block.parse-test/hello)
(parse-hash reader)
parses a block starting with #
from the reader
(-> (parse-hash (reader/create "#{1 2 3}")) (base/block-value)) => #{1 2 3}
(-> (parse-hash (reader/create "#(+ 1 2)")) (base/block-value)) => '(fn* [] (+ 1 2))
parses a block starting with `#` from the reader (-> (parse-hash (reader/create "#{1 2 3}")) (base/block-value)) => #{1 2 3} (-> (parse-hash (reader/create "#(+ 1 2)")) (base/block-value)) => '(fn* [] (+ 1 2))
(parse-hash-cursor reader)
parses the hash-cursor string
(str (parse-hash-cursor (reader/create "#|"))) => "|"
parses the hash-cursor string (str (parse-hash-cursor (reader/create "#|"))) => "|"
(parse-hash-uneval reader)
parses the hash-uneval string
(str (parse-hash-uneval (reader/create "#"))) => "#"
parses the hash-uneval string (str (parse-hash-uneval (reader/create "#_"))) => "#_"
(parse-keyword reader)
reads a keyword block from the reader
(-> (reader/create ":a/b") (parse-keyword) (base/block-value)) => :a/b
(-> (reader/create "::hello") (parse-keyword) (base/block-value)) => (keyword ":hello")
reads a keyword block from the reader (-> (reader/create ":a/b") (parse-keyword) (base/block-value)) => :a/b (-> (reader/create "::hello") (parse-keyword) (base/block-value)) => (keyword ":hello")
(parse-non-expressions reader)
parses whitespace until next token
(str (parse-non-expressions (reader/create " \na")))
=> "[(␣
) a]"
parses whitespace until next token (str (parse-non-expressions (reader/create " \na"))) => "[(␣ \ ) a]"
(parse-reader reader)
reads a :char block from the reader
reads a :char block from the reader
(parse-root s)
parses a root
(str (parse-root "a b c")) => "a b c"
parses a root (str (parse-root "a b c")) => "a b c"
(parse-select reader)
parses a block starting with #?
from the reader
(-> (parse-select (reader/create "#?(:cljs a)")) (base/block-value)) => '(? {:cljs a})
(-> (parse-select (reader/create "#?@(:cljs a)")) (base/block-value)) => '(?-splicing {:cljs a})
parses a block starting with `#?` from the reader (-> (parse-select (reader/create "#?(:cljs a)")) (base/block-value)) => '(? {:cljs a}) (-> (parse-select (reader/create "#?@(:cljs a)")) (base/block-value)) => '(?-splicing {:cljs a})
(parse-string s)
parses a block from a string input
(-> (parse-string "#(:b {:b 1})") (base/block-value)) => '(fn* [] ((keyword "b") {(keyword "b") 1}))
parses a block from a string input (-> (parse-string "#(:b {:b 1})") (base/block-value)) => '(fn* [] ((keyword "b") {(keyword "b") 1}))
(parse-token reader)
reads token block from the reader
(-> (reader/create "abc") (parse-token) (base/block-value)) => 'abc
(-> (reader/create "3/5") (parse-token) (base/block-value)) => 3/5
reads token block from the reader (-> (reader/create "abc") (parse-token) (base/block-value)) => 'abc (-> (reader/create "3/5") (parse-token) (base/block-value)) => 3/5
(parse-unquote reader)
parses a block starting with ~
from the reader
(-> (parse-unquote (reader/create "~hello")) (base/block-value)) => '(unquote hello)
(-> (parse-unquote (reader/create "~@hello")) (base/block-value)) => '(unquote-splicing hello)
parses a block starting with `~` from the reader (-> (parse-unquote (reader/create "~hello")) (base/block-value)) => '(unquote hello) (-> (parse-unquote (reader/create "~@hello")) (base/block-value)) => '(unquote-splicing hello)
(parse-void reader)
reads a void block from reader
(->> (reader/read-repeatedly (reader/create " \t\n\f")
parse-void
eof-block?)
(take 5)
(map str))
=> ["␣" "\ " "
" "\"]
reads a void block from reader (->> (reader/read-repeatedly (reader/create " \t\n\f") parse-void eof-block?) (take 5) (map str)) => ["␣" "\ " "\ " "\"]
(read-collection reader start end-delimiter)
reads all children, taking a delimiter as option
(->> (read-collection (reader/create "(1 2 3 4 5)") "(" (first ")")) (apply str)) => "1␣2␣3␣4␣5"
reads all children, taking a delimiter as option (->> (read-collection (reader/create "(1 2 3 4 5)") "(" (first ")")) (apply str)) => "1␣2␣3␣4␣5"
(read-cons reader start)
(read-cons reader start n)
helper method for reading (->> (read-cons (reader/create "@hello") "@") (map base/block-string)) => '("hello")
(->> (read-cons (reader/create "^hello {}") "^" 2) (map base/block-string)) => '("hello" " " "{}")
helper method for reading (->> (read-cons (reader/create "@hello") "@") (map base/block-string)) => '("hello") (->> (read-cons (reader/create "^hello {}") "^" 2) (map base/block-string)) => '("hello" " " "{}")
(read-dispatch ch)
dispatches on first symbol
(read-dispatch \tab) => :void
(read-dispatch (first "#")) => :hash
dispatches on first symbol (read-dispatch \tab) => :void (read-dispatch (first "#")) => :hash
(read-start reader start)
helper to verify that the beginning has been read
(read-start (reader/create "~@") "~#") => (throws)
helper to verify that the beginning has been read (read-start (reader/create "~@") "~#") => (throws)
(read-string-data reader)
reads string data from the reader
(read-string-data (reader/create ""hello"")) => "hello"
reads string data from the reader (read-string-data (reader/create "\"hello\"")) => "hello"
(read-whitespace reader)
reads whitespace blocks as vector
(count (read-whitespace (reader/create " "))) => 3
reads whitespace blocks as vector (count (read-whitespace (reader/create " "))) => 3
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close