changed return value of parser's error helper function to actual error message

This commit is contained in:
Richard Harrington 2013-07-13 10:59:13 -04:00
parent aae1c0b8c1
commit 05459307c7
2 changed files with 7 additions and 2 deletions

View File

@ -3,6 +3,7 @@
(use '[clojure.core.match :only (match)])
(use '[clojure.set :only (union)])
(def operators #{\= \< \> \# \+ \- \* \/})
(def registers (union (set (map #(-> % char str) (range (int \A) (inc (int \Z)))))
@ -62,6 +63,10 @@
[s]
(re-find #"^[A-Z]+\d*$" s))
(defn ignoring-args-thunk [x] (fn [& _] x))
(def return-err (ignoring-args-thunk "Invalid word or symbol"))
(defn parse-token
"takes a single token and adds the appropriate metadata"
[{token-str :token-str, pos :pos}]
@ -73,7 +78,7 @@
[commands :command]
[str->int :number]
[valid-word :label]
[identity :error]]))
[return-err :error]]))
(def value-type? #{:number :register})

View File

@ -104,7 +104,7 @@
(deftest parse-token-error
(testing "parsing error token"
(is (= (parse-token {:token-str "-GOTO", :pos 23})
{:val "-GOTO", :type :error, :pos 23}))))
{:val "Invalid word or symbol", :type :error, :pos 23}))))