From 896ee4cc52ab9b5af09bcc425850c9a3410b44cf Mon Sep 17 00:00:00 2001 From: Richard Harrington Date: Thu, 4 Jul 2013 13:55:46 -0400 Subject: [PATCH] lexing working, except it has incorrect column numbers --- src/hs_robotwar/core.clj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hs_robotwar/core.clj b/src/hs_robotwar/core.clj index 89fad2e..307ae55 100644 --- a/src/hs_robotwar/core.clj +++ b/src/hs_robotwar/core.clj @@ -1,6 +1,6 @@ (ns hs-robotwar.core) -(def registers (set (concat (map #(-> % char str) (range 65 91)) +(def registers (set (concat (map #(-> % char str) (range (int \A) (inc (int \Z)))) ["AIM" "SHOT" "RADAR" "DAMAGE" "SPEEDX" "SPEEDY" "RANDOM" "INDEX"]))) (def operators #{"=" "<" ">" "#" "+" "-" "*" "/"}) @@ -28,7 +28,6 @@ parsing-token? (not (empty? partial-token)) head (str (first line)) tail (rest line)] - (println head current-pos parsing-token? previous-token) (cond (or (empty? line) (= ";" head)) (if parsing-token? (close-partial-token) @@ -42,10 +41,11 @@ ; make sure we're not a unary minus sign operator ; by making sure that if we are a minus sign, ; the previous token is, or could represent, a number. - (when (or (not= "-" head) - (digit? (last previous-token)) - (registers previous-token)) - (recur tail "" current-pos (conj-with-metadata result head current-pos)))) + (if (or (not= "-" head) + (digit? (last previous-token)) + (registers previous-token)) + (recur tail "" current-pos (conj-with-metadata result head current-pos)) + (recur tail (str partial-token head) saved-pos result))) :else (recur tail (str partial-token head) saved-pos result)))))