File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change 4
4
[reader :as r]]))
5
5
6
6
(defn- read-to-boundary
7
- [reader]
8
- (r/read-until
9
- reader
10
- r/whitespace-or-boundary?))
7
+ [reader & [allowed]]
8
+ (let [allowed? (set allowed)]
9
+ (r/read-until
10
+ reader
11
+ #(and (not (allowed? %))
12
+ (r/whitespace-or-boundary? %)))))
11
13
12
14
(defn- read-to-char-boundary
13
15
[reader]
18
20
" " ))))
19
21
20
22
(defn- symbol-node
21
- " Symbols allow for trailing quotes that have to be handled
22
- explicitly."
23
+ " Symbols allow for certain boundary characters that have
24
+ to be handled explicitly."
23
25
[reader value value-string]
24
- (if (= (r/peek reader) \')
25
- (let [s (str value-string (r/next reader))]
26
- (node/token-node
27
- (r/string->edn s)
28
- s))
29
- (node/token-node value value-string)))
26
+ (let [suffix (read-to-boundary
27
+ reader
28
+ [\' \:])]
29
+ (if (empty? suffix)
30
+ (node/token-node value value-string)
31
+ (let [s (str value-string suffix)]
32
+ (node/token-node
33
+ (r/string->edn s)
34
+ s)))))
30
35
31
36
(defn parse-token
32
37
" Parse a single token."
You can’t perform that action at this time.
0 commit comments