comment on last line does not kill scanner

This commit is contained in:
Scott Richmond 2024-06-04 11:59:41 -04:00
parent bbd41a0f74
commit 943e96203e

View File

@ -250,7 +250,7 @@
(defn- add-comment [char scanner]
(defn recur [scanner comm]
(let [char (current-char scanner)]
(if (= "\n" char)
(if (or (= "\n" char) (at-end? scanner))
scanner # for now, we don't do anything with comments; can be added later
(recur (advance scanner) (buffer/push comm char)))))
(recur scanner (buffer char)))
@ -341,5 +341,9 @@
(recur (-> scanner (scan-token) (next-token)))))
(recur (new-scanner source input)))
(def source `print! ("hello")`)
(def source `
a :b "c"
& thing
`)
(pp ((scan source) :tokens))