mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-06-08 02:29:30 +00:00
got rid of core.match
This commit is contained in:
parent
90e31a4b22
commit
e9eb478a54
|
@ -6,7 +6,6 @@
|
|||
:min-lein-version "2.0.0"
|
||||
:javac-target "1.7"
|
||||
:dependencies [[org.clojure/clojure "1.5.1"]
|
||||
[org.clojure/core.match "0.2.0-rc5"]
|
||||
[clj-time "0.5.1"]
|
||||
[ring/ring-json "0.3.1"]
|
||||
[ring/ring-core "1.3.1"]]
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
(ns robotwar.assembler
|
||||
(:use (clojure [string :only [split join]])
|
||||
[clojure.core.match :only [match]]))
|
||||
(:use (clojure [string :only [split join]])))
|
||||
|
||||
(def op-commands [ "-" "+" "*" "/" "=" "#" "<" ">" ])
|
||||
(def word-commands [ "TO" "IF" "GOTO" "GOSUB" "ENDSUB" ])
|
||||
|
@ -138,13 +137,15 @@
|
|||
result []]
|
||||
(if (empty? tokens)
|
||||
result
|
||||
(match [token]
|
||||
[{:type (:or :number :register)}]
|
||||
(recur tail (conj result [(into token {:val ",", :type :command}) token]))
|
||||
[(:or {:type :label} {:type :command, :val "ENDSUB"})]
|
||||
(recur tail (conj result [token nil]))
|
||||
[{:type :command}]
|
||||
(recur (rest tail) (conj result [token (first tail)]))))))
|
||||
(let [{:keys [type val]} token]
|
||||
(cond
|
||||
(or (= type :number) (= type :register))
|
||||
(recur tail (conj result [(into token {:val ",", :type :command}) token]))
|
||||
(or (= type :label) (and (= type :command) (= val "ENDSUB")))
|
||||
(recur tail (conj result [token nil]))
|
||||
(= type :command)
|
||||
(recur (rest tail) (conj result [token (first tail)])))))))
|
||||
|
||||
|
||||
; TODO: preserve :line and :pos metadata with labels,
|
||||
; when labels are transferred from the instruction list to the label map
|
||||
|
|
Loading…
Reference in New Issue
Block a user