Liking cljdoc? Tell your friends :D

std.block.parse


*dispatch-options*clj


*end-delimiter*clj


*hash-dispatch*clj


*hash-options*clj


*symbol-allowed*clj


-parsecljmultimethod

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}
raw docstring

delimiter-block?clj

(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
raw docstring

eof-block?clj

(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
raw docstring

parse-collectionclj

(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))
raw docstring

parse-commentclj

(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}
raw docstring

parse-consclj

(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)
raw docstring

parse-hashclj

(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))
raw docstring

parse-hash-cursorclj

(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 "#|")))
=> "|"
raw docstring

parse-hash-unevalclj

(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 "#_")))
=> "#_"
raw docstring

parse-keywordclj

(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")
raw docstring

parse-non-expressionsclj

(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]"
raw docstring

parse-readerclj

(parse-reader reader)

reads a :char block from the reader

reads a :char block from the reader
raw docstring

parse-rootclj

(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"
raw docstring

parse-selectclj

(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})
raw docstring

parse-stringclj

(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}))
raw docstring

parse-tokenclj

(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
raw docstring

parse-unquoteclj

(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)
raw docstring

parse-voidclj

(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))
   => ["␣" "\	" "\
" "\"]
raw docstring

read-collectionclj

(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"
raw docstring

read-consclj

(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" " " "{}")
raw docstring

read-dispatchclj

(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
raw docstring

read-startclj

(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)
raw docstring

read-string-dataclj

(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"
raw docstring

read-whitespaceclj

(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
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close