├── doc
└── intro.md
├── .gitignore
├── CONTRIBUTING.md
├── deps.edn
├── src
├── main
│ ├── dotnet
│ │ └── packager
│ │ │ └── clojure.tools.reader.csproj
│ └── clojure
│ │ └── clojure
│ │ └── tools
│ │ ├── reader
│ │ ├── impl
│ │ │ ├── inspect.clj
│ │ │ ├── utils.clj
│ │ │ ├── errors.clj
│ │ │ └── commons.clj
│ │ ├── default_data_readers.clj
│ │ ├── reader_types.clj
│ │ └── edn.clj
│ │ └── reader.clj
└── test
│ └── clojure
│ └── clojure
│ └── tools
│ ├── reader_edn_test.clj
│ ├── common_tests.clj
│ ├── metadata_test.clj
│ └── reader_test.clj
├── README.md
├── project.clj
├── .gitattributes
├── LICENSE.txt
└── epl.html
/doc/intro.md:
--------------------------------------------------------------------------------
1 | # Introduction to clr.tools.reader
2 |
3 | TODO: write [great documentation](http://jacobian.org/writing/great-documentation/what-to-write/)
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | pom.xml
2 | /lib/
3 | /classes/
4 | /targets/
5 | /target
6 | /classes
7 | /checkouts
8 | *.jar
9 | *.class
10 | *.dll
11 | *.pdb
12 | *.exe
13 | .lein-deps-sum
14 | .lein-failures
15 | .lein-plugins
16 | .vs
17 | .cpcache
18 |
19 | #Visual Studio artifacts
20 | bin
21 | obj
22 | *.user
23 | *.suo
24 | *.nupkg
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | This is a [Clojure contrib] project.
2 |
3 | Under the Clojure contrib [guidelines], this project cannot accept
4 | pull requests. All patches must be submitted via [JIRA].
5 |
6 | See [Contributing] on the Clojure website for
7 | more information on how to contribute.
8 |
9 | [Clojure contrib]: https://clojure.org/community/contrib_libs
10 | [Contributing]: https://clojure.org/community/contributing
11 | [JIRA]: https://clojure.atlassian.net/browse/TNS
12 | [guidelines]: https://clojure.org/community/contrib_howto
--------------------------------------------------------------------------------
/deps.edn:
--------------------------------------------------------------------------------
1 | {:deps {} ;;; TODO: Figure out how we express ClojureCLR version dependency: org.clojure/clojure {:mvn/version "1.10.3"}
2 | :paths ["src/main/clojure"]
3 |
4 | :aliases
5 | {:test
6 | {:extra-paths ["src/test/clojure"]
7 | :extra-deps {io.github.dmiller/test-runner {:git/sha "c055ea13d19c6a9b9632aa2370fcc2215c8043c3"}}
8 | ;; :main-opts {"-m" "cognitect.test-runner" "-d" "src/test/clojure"}
9 | :exec-fn cognitect.test-runner.api/test
10 | :exec-args {:dirs ["src/test/clojure"]}}}
11 | }
--------------------------------------------------------------------------------
/src/main/dotnet/packager/clojure.tools.reader.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0;netstandard2.1
5 |
6 |
7 |
8 | clojure.tools.reader
9 | clojure.tools
10 | clojure.tools.reader
11 | clojure.tools.reader
12 | clojure.tools.reader
13 | ClojureCLR contributors
14 | A Clojure reader and edn-only reader
15 | Copyright © Rich Hickey, ClojureCLR contributors 2025
16 | EPL-1.0
17 | https://github.com/clojure/clr.tools.namesapce
18 | ClojureCLR contributors
19 | Clojure;ClojureCLR
20 | 1.5.2
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # clr.tools.reader
2 |
3 | A port [ clojure/tools.reader](https://github.com/clojure/tools.reader) library to ClojureCLR.
4 |
5 | From the parent's README:
6 |
7 | > A complete Clojure reader and an EDN-only reader, ...
8 |
9 | See the parent repo for documentation.
10 |
11 | # Releases
12 |
13 | Latest stable release: 1.5.2
14 |
15 | [clj](https://clojure.org/guides/getting_started) dependency information:
16 | ```clojure
17 | io.github.clojure/clr.tools.reader {:git/tag "v1.5.2" :git/sha "1a7a8e9"}
18 | ```
19 |
20 | Nuget reference:
21 |
22 | > PM> Install-Package clojure.tools.reader -Version 1.5.2
23 |
24 | [Leiningen](https://github.com/technomancy/leiningen) dependency information:
25 | ```clojure
26 | [org.clojure.clr/tools.reader "1.5.0"]
27 | ```
28 |
29 |
30 | # Note to maintainers
31 |
32 | If using lein-clr to work on this, specifically, to run tests, be aware that the structure of the tests in this project does not conform to the leiningen standard.
33 | There is a file common_tests.clj that is loaded by several other test files
34 | (Speaking to the notion that an include-file should be added for when load is not appropriate, as here).
35 | The leiningen test framework will load common_tests.clj and fail.
36 | You need to run each top-level file directly. For example,
37 |
38 | ```
39 | lein.bat clr test clojure.tools.metadata-test clojure.tools.reader-test clojure.tools.reader-edn-test
40 | ```
41 |
42 | # Copyright and License #
43 |
44 | Original Clojure(JVM) code:
45 |
46 | > Copyright © Nicola Mometto, Rich Hickey & contributors.
47 |
48 | > Licensed under the EPL. (See the file epl.html.))
49 |
--------------------------------------------------------------------------------
/project.clj:
--------------------------------------------------------------------------------
1 | (defproject org.clojure.clr/tools.reader "1.5.2"
2 | :description "Port of clojure.org/tool.reader to ClojureCLR"
3 | :url "https://github.com/clojure/clr.tools.reader"
4 | :license {:name "Eclipse Public License"
5 | :url "http://www.eclipse.org/legal/epl-v10.html"}
6 | :dependencies []
7 | :source-paths ["src/main/clojure"]
8 | :test-paths ["src/test/clojure"]
9 | :deploy-repositories [["clojars" {:url "https://clojars.org/repo/"
10 | :sign-releases false}]]
11 | :warn-on-reflection true
12 | :min-lein-version "2.0.0"
13 | :plugins [[lein-clr "0.2.1"]]
14 | :clr {:cmd-templates {:clj-exe [[?PATH "mono"] [CLJCLR17_40 %1]]
15 | :clj-dep [[?PATH "mono"] ["target/clr/clj/Debug 4.0" %1]]
16 | :clj-url "http://sourceforge.net/projects/clojureclr/files/clojure-clr-1.7.0-Debug-4.0.zip/download"
17 | :clj-zip "clojure-clr-1.7.0-Debug-4.0.zip"
18 | :curl ["curl" "--insecure" "-f" "-L" "-o" %1 %2]
19 | :nuget-ver [[?PATH "mono"] [*PATH "nuget.exe"] "install" %1 "-Version" %2]
20 | :nuget-any [[?PATH "mono"] [*PATH "nuget.exe"] "install" %1]
21 | :unzip ["unzip" "-d" %1 %2]
22 | :wget ["wget" "--no-check-certificate" "--no-clobber" "-O" %1 %2]}
23 | ;; for automatic download/unzip of ClojureCLR,
24 | ;; 1. make sure you have curl or wget installed and on PATH,
25 | ;; 2. uncomment deps in :deps-cmds, and
26 | ;; 3. use :clj-dep instead of :clj-exe in :main-cmd and :compile-cmd
27 | :deps-cmds [; [:wget :clj-zip :clj-url] ; edit to use :curl instead of :wget
28 | ; [:unzip "../clj" :clj-zip]
29 | ]
30 | :main-cmd [:clj-exe "Clojure.Main.exe"]
31 | :compile-cmd [:clj-exe "Clojure.Compile.exe"]})
32 |
--------------------------------------------------------------------------------
/src/test/clojure/clojure/tools/reader_edn_test.clj:
--------------------------------------------------------------------------------
1 | (ns clojure.tools.reader-edn-test
2 | (:refer-clojure :exclude [read-string])
3 | (:use [clojure.tools.reader.edn :as edn :only [read-string]]
4 | [clojure.test :only [deftest is testing]])
5 | (:import clojure.lang.BigInt))
6 |
7 | (load "common_tests")
8 |
9 | (deftest read-keyword
10 | (is (= :foo-bar (read-string ":foo-bar")))
11 | (is (= :foo/bar (read-string ":foo/bar")))
12 | (is (= :*+!-_? (read-string ":*+!-_?")))
13 | (is (= :abc:def:ghi (read-string ":abc:def:ghi")))
14 | (is (= :abc.def/ghi (read-string ":abc.def/ghi")))
15 | (is (= :abc/def.ghi (read-string ":abc/def.ghi")))
16 | (is (= :abc:def/ghi:jkl.mno (read-string ":abc:def/ghi:jkl.mno")))
17 | (is (instance? clojure.lang.Keyword (read-string ":alphabet"))) )
18 |
19 | (deftest read-tagged
20 | ;; (is (= #inst "2010-11-12T13:14:15.666"
21 | ;; (read-string "#inst \"2010-11-12T13:14:15.666\"")))
22 | ;; (is (= #inst "2010-11-12T13:14:15.666"
23 | ;; (read-string "#inst\"2010-11-12T13:14:15.666\"")))
24 | ;; (is (= #uuid "550e8400-e29b-41d4-a716-446655440000"
25 | ;; (read-string "#uuid \"550e8400-e29b-41d4-a716-446655440000\"")))
26 | ;; (is (= #uuid "550e8400-e29b-41d4-a716-446655440000"
27 | ;; (read-string "#uuid\"550e8400-e29b-41d4-a716-446655440000\"")))
28 | (is (= (System.Guid. "550e8400-e29b-41d4-a716-446655440000") ;;; java.util.UUID/fromString
29 | (read-string "#uuid \"550e8400-e29b-41d4-a716-446655440000\"")))
30 | (is (= (System.Guid. "550e8400-e29b-41d4-a716-446655440000") ;;; java.util.UUID/fromString
31 | (read-string "#uuid\"550e8400-e29b-41d4-a716-446655440000\"")))
32 | (let [my-unknown (fn [tag val] {:unknown-tag tag :value val})]
33 | (is (= {:unknown-tag 'foo :value 'bar}
34 | (read-string {:default my-unknown} "#foo bar")))))
35 |
36 | (deftest pushback-reader-test
37 | (testing "TRDR-63"
38 | (is (= '(+) (edn/read (clojure.lang.PushbackTextReader. (System.IO.StringReader. "(+)"))))))) ;;; java.io.PushbackReader. java.io.StringReader.
39 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/src/main/clojure/clojure/tools/reader/impl/inspect.clj:
--------------------------------------------------------------------------------
1 | ;; Copyright (c) Russ Olsen, Nicola Mometto, Rich Hickey & contributors.
2 | ;; The use and distribution terms for this software are covered by the
3 | ;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
4 | ;; which can be found in the file epl-v10.html at the root of this distribution.
5 | ;; By using this software in any fashion, you are agreeing to be bound by
6 | ;; the terms of this license.
7 | ;; You must not remove this notice, or any other, from this software.
8 |
9 | (ns clojure.tools.reader.impl.inspect)
10 |
11 | (declare inspect*)
12 |
13 | (defn- inspect*-col [truncate col start end]
14 | (let [n (count col)
15 | l (if truncate 0 (min 10 n))
16 | elements (map (partial inspect* true) (take l col))
17 | content (apply str (interpose " " elements))
18 | suffix (if (< l n) "...")]
19 | (str start content suffix end)))
20 |
21 | (defn- dispatch-inspect
22 | [_ x]
23 | (cond
24 | (nil? x) :nil
25 | (string? x) :string
26 | (keyword? x) :strable
27 | (number? x) :strable
28 | (symbol? x) :strable
29 | (vector? x) :vector
30 | (list? x) :list
31 | (map? x) :map
32 | (set? x) :set
33 | (= x true) :strable
34 | (= x false) :strable
35 | :default (class x)))
36 |
37 | (defmulti inspect* dispatch-inspect)
38 |
39 | (defmethod inspect* :string [truncate ^String x]
40 | (let [n (if truncate 5 20)
41 | suffix (if (> (.Length x) n) "...\"" "\"")] ;;; .length
42 | (str
43 | \"
44 | (.Substring ^String x 0 (min n (.Length x))) ;;; .substring .length
45 | suffix)))
46 |
47 | (defmethod inspect* :strable [truncate x] (str x))
48 |
49 | (defmethod inspect* clojure.lang.PersistentVector+ChunkedSeq [truncate x] ;;; clojure.lang.PersistentVector$ChunkedSeq
50 | "")
51 |
52 | (defmethod inspect* clojure.lang.PersistentArrayMap+Seq [truncate x] ;;; clojure.lang.PersistentArrayMap$Seq
53 | "