We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 28fbc0f commit 5fd44e4Copy full SHA for 5fd44e4
src/rewrite_clj/parser/token.clj
@@ -3,13 +3,27 @@
3
[node :as node]
4
[reader :as r]]))
5
6
+(defn- read-to-boundary
7
+ [reader]
8
+ (r/read-until
9
+ reader
10
+ r/whitespace-or-boundary?))
11
+
12
+(defn- read-to-char-boundary
13
14
+ (let [c (r/next reader)]
15
+ (str c
16
+ (if (not= c \\)
17
+ (read-to-boundary reader)
18
+ ""))))
19
20
(defn parse-token
21
"Parse a single token."
22
[reader]
- (let [s (str
- (r/next reader)
- (r/read-until
- reader
- r/whitespace-or-boundary?))
23
+ (let [first-char (r/next reader)
24
+ s (->> (if (= first-char \\)
25
+ (read-to-char-boundary reader)
26
+ (read-to-boundary reader))
27
+ (str first-char))
28
v (r/string->edn s)]
29
(node/token-node v s)))
0 commit comments