Whitespace should not return errors

This commit is contained in:
Scott Richmond 2022-02-20 18:39:18 -05:00
parent 23e2e95e77
commit 2751b7428f

View File

@ -129,7 +129,7 @@
nil nil
(::line scanner) (::line scanner)
(::start scanner)) (::start scanner))
err-token (assoc token :msg msg) err-token (assoc token :message msg)
] ]
(-> scanner (-> scanner
(update ::errors conj err-token) (update ::errors conj err-token)
@ -243,6 +243,7 @@
(add-error scanner (str "Expected <-. Got " char next))) (add-error scanner (str "Expected <-. Got " char next)))
;; |> ;; |>
;; Consider => , with =>> for bind
\| (if (= next \>) \| (if (= next \>)
(add-token (advance scanner) ::token/pipeline) (add-token (advance scanner) ::token/pipeline)
(add-error scanner (str "Expected |>. Got " char next))) (add-error scanner (str "Expected |>. Got " char next)))
@ -294,7 +295,7 @@
;; word matches ;; word matches
(cond (cond
;; for now, don't add whitespace tokens (whitespace? char) scanner ;; for now just skip whitespace characters
(digit? char) (add-number char scanner) (digit? char) (add-number char scanner)
(alpha? char) (add-word char scanner) (alpha? char) (add-word char scanner)
:else (add-error scanner (str "Unexpected character: " char)))))) :else (add-error scanner (str "Unexpected character: " char))))))
@ -309,3 +310,10 @@
{:tokens (::tokens scanner) {:tokens (::tokens scanner)
:errors (::errors scanner)}) :errors (::errors scanner)})
(recur (-> scanner (scan-token) (next-token)))))) (recur (-> scanner (scan-token) (next-token))))))
(do
(def source "abc nil")
(pp/pprint (scan source))
)