mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-09-28 16:54:23 +00:00
changed return value of parser's error helper function to actual error message
This commit is contained in:
parent
aae1c0b8c1
commit
05459307c7
@ -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})
|
||||
|
||||
|
@ -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}))))
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user