From e9eb478a546581d180e24de04529d9ccbb4d31ed Mon Sep 17 00:00:00 2001 From: Richard Harrington Date: Wed, 22 Jul 2015 17:52:48 -0400 Subject: [PATCH] got rid of core.match --- project.clj | 1 - src/robotwar/assembler.clj | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/project.clj b/project.clj index 260ea35..cdd2752 100644 --- a/project.clj +++ b/project.clj @@ -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"]] diff --git a/src/robotwar/assembler.clj b/src/robotwar/assembler.clj index b25c563..9b52993 100644 --- a/src/robotwar/assembler.clj +++ b/src/robotwar/assembler.clj @@ -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