Skip to content

Commit ae74971

Browse files
author
Yannick Scherer
committed
fix parsing of comments. (fixes #18)
1 parent 828b786 commit ae74971

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/rewrite_clj/reader.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@
8282
(defn read-include-linebreak
8383
"Read until linebreak and include it."
8484
[reader]
85-
(let [s (read-until reader linebreak?)
86-
c (r/read-char reader)]
87-
(str s c)))
85+
(str
86+
(read-until
87+
reader
88+
#(or (nil? %) (linebreak? %)))
89+
(r/read-char reader)))
8890

8991
(defn string->edn
9092
"Convert string to EDN value."

test/rewrite_clj/parser_test.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@
187187
:token :whitespace
188188
:token])
189189

190+
(tabular
191+
(fact "about parsing comments."
192+
(let [n (p/parse-string ?s)]
193+
n => node/printable-only?
194+
(node/tag n) => :comment
195+
(node/string n) => ?s))
196+
?s
197+
"; this is a comment\n"
198+
";; this is a comment\n"
199+
"; this is a comment"
200+
";; this is a comment")
201+
190202
(tabular
191203
(fact "about parsing exceptions"
192204
(p/parse-string ?s) => (throws Exception ?p))

0 commit comments

Comments
 (0)