got rid of core.match

This commit is contained in:
Richard Harrington 2015-07-22 17:52:48 -04:00
parent 90e31a4b22
commit e9eb478a54
2 changed files with 10 additions and 10 deletions

View File

@ -6,7 +6,6 @@
:min-lein-version "2.0.0" :min-lein-version "2.0.0"
:javac-target "1.7" :javac-target "1.7"
:dependencies [[org.clojure/clojure "1.5.1"] :dependencies [[org.clojure/clojure "1.5.1"]
[org.clojure/core.match "0.2.0-rc5"]
[clj-time "0.5.1"] [clj-time "0.5.1"]
[ring/ring-json "0.3.1"] [ring/ring-json "0.3.1"]
[ring/ring-core "1.3.1"]] [ring/ring-core "1.3.1"]]

View File

@ -1,6 +1,5 @@
(ns robotwar.assembler (ns robotwar.assembler
(:use (clojure [string :only [split join]]) (:use (clojure [string :only [split join]])))
[clojure.core.match :only [match]]))
(def op-commands [ "-" "+" "*" "/" "=" "#" "<" ">" ]) (def op-commands [ "-" "+" "*" "/" "=" "#" "<" ">" ])
(def word-commands [ "TO" "IF" "GOTO" "GOSUB" "ENDSUB" ]) (def word-commands [ "TO" "IF" "GOTO" "GOSUB" "ENDSUB" ])
@ -138,13 +137,15 @@
result []] result []]
(if (empty? tokens) (if (empty? tokens)
result result
(match [token] (let [{:keys [type val]} token]
[{:type (:or :number :register)}] (cond
(recur tail (conj result [(into token {:val ",", :type :command}) token])) (or (= type :number) (= type :register))
[(:or {:type :label} {:type :command, :val "ENDSUB"})] (recur tail (conj result [(into token {:val ",", :type :command}) token]))
(recur tail (conj result [token nil])) (or (= type :label) (and (= type :command) (= val "ENDSUB")))
[{:type :command}] (recur tail (conj result [token nil]))
(recur (rest tail) (conj result [token (first tail)])))))) (= type :command)
(recur (rest tail) (conj result [token (first tail)])))))))
; TODO: preserve :line and :pos metadata with labels, ; TODO: preserve :line and :pos metadata with labels,
; when labels are transferred from the instruction list to the label map ; when labels are transferred from the instruction list to the label map