minor refactoring of adding operators to set of commands

This commit is contained in:
Richard Harrington 2013-07-13 13:06:48 -04:00
parent 0ca4fac91c
commit 90152aa425

View File

@ -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 %)