mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-10-31 20:09:53 +00:00
lexing working, except it has incorrect column numbers
This commit is contained in:
parent
d9f03a10fe
commit
896ee4cc52
@ -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)))))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user