From c1afcd9d7911f8214a0615e85947c1155a7fd970 Mon Sep 17 00:00:00 2001 From: Richard Harrington Date: Tue, 16 Jul 2013 17:54:42 -0400 Subject: [PATCH] changed parse-token to loop and recur --- src/hs_robotwar/core.clj | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/hs_robotwar/core.clj b/src/hs_robotwar/core.clj index 38f8917..480acf9 100644 --- a/src/hs_robotwar/core.clj +++ b/src/hs_robotwar/core.clj @@ -66,12 +66,11 @@ [return-err :error]]) (defn parse-token - "takes a single token and adds the appropriate metadata" - [{:keys [token-str pos]}] - (first (for [[parser token-type] parser-priority - :let [token-val (parser token-str)] - :when token-val] - {:val token-val, :type token-type, :pos pos}))) + [{:keys [token-str pos]}] + (loop [[[parser token-type] & tail] parser-priority] + (if-let [token-val (parser token-str)] + {:val token-val, :type token-type, :pos pos} + (recur tail)))) (defn parse "take the tokens and convert them to strucured source code ready for compiling"