Better errors? WIP
This commit is contained in:
parent
40367d7e57
commit
23e2e95e77
|
@ -122,7 +122,18 @@
|
||||||
;; The goal is to be able to be able to hand this to an LSP?
|
;; The goal is to be able to be able to hand this to an LSP?
|
||||||
;; Do we need a different structure
|
;; Do we need a different structure
|
||||||
(defn- add-error [scanner msg]
|
(defn- add-error [scanner msg]
|
||||||
(update scanner ::errors conj {:msg msg :line (::line scanner) :start (::start scanner)}))
|
(let [
|
||||||
|
token (token/token
|
||||||
|
::token/error
|
||||||
|
(current-lexeme scanner)
|
||||||
|
nil
|
||||||
|
(::line scanner)
|
||||||
|
(::start scanner))
|
||||||
|
err-token (assoc token :msg msg)
|
||||||
|
]
|
||||||
|
(-> scanner
|
||||||
|
(update ::errors conj err-token)
|
||||||
|
(update ::tokens conj err-token))))
|
||||||
|
|
||||||
(defn- add-keyword
|
(defn- add-keyword
|
||||||
[scanner]
|
[scanner]
|
||||||
|
@ -132,7 +143,7 @@
|
||||||
(cond
|
(cond
|
||||||
(terminates? char) (add-token scanner ::token/keyword (keyword key))
|
(terminates? char) (add-token scanner ::token/keyword (keyword key))
|
||||||
(word-char? char) (recur (advance scanner) (str key char))
|
(word-char? char) (recur (advance scanner) (str key char))
|
||||||
:else (add-error scanner "Unexpected " char "after keyword :" key)))))
|
:else (add-error scanner (str "Unexpected " char "after keyword :" key))))))
|
||||||
|
|
||||||
;; TODO: improve number parsing?
|
;; TODO: improve number parsing?
|
||||||
;; Currently this uses Clojure's number formatting rules (since we use the EDN reader)
|
;; Currently this uses Clojure's number formatting rules (since we use the EDN reader)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user