mirror of
https://github.com/richardharrington/robotwar.git
synced 2024-06-11 21:29:28 +00:00
minor refactoring of adding operators to set of commands
This commit is contained in:
parent
0ca4fac91c
commit
90152aa425
|
@ -5,13 +5,11 @@
|
|||
|
||||
(def operators "-+*/=#<>")
|
||||
|
||||
(def lex-re (re-pattern (str "[" operators "]|[^" operators "\\s]+")))
|
||||
(def operators-set (set (map str operators)))
|
||||
|
||||
(def registers (union (set (map #(-> % char str) (range (int \A) (inc (int \Z)))))
|
||||
#{"AIM" "SHOT" "RADAR" "DAMAGE" "SPEEDX" "SPEEDY" "RANDOM" "INDEX"}))
|
||||
|
||||
(def commands (union operators-set #{"TO" "IF" "GOTO" "GOSUB" "ENDSUB"}))
|
||||
(def commands (union (set (map str operators))
|
||||
#{"TO" "IF" "GOTO" "GOSUB" "ENDSUB"}))
|
||||
|
||||
(defn re-seq-with-pos
|
||||
"returns a sequence of 2-element vectors: [match position]"
|
||||
|
@ -33,6 +31,8 @@
|
|||
[s n]
|
||||
{:token-str s, :pos n})
|
||||
|
||||
(def lex-re (re-pattern (str "[" operators "]|[^" operators "\\s]+")))
|
||||
|
||||
(defn lex-line
|
||||
[line]
|
||||
(map #(apply build-lex-metadata %)
|
||||
|
|
Loading…
Reference in New Issue
Block a user