Skip to content

Instantly share code, notes, and snippets.

@seeeturtle
Last active July 6, 2018 11:07
Show Gist options
  • Save seeeturtle/790c7a947b80a67808ecea328e96d850 to your computer and use it in GitHub Desktop.
Save seeeturtle/790c7a947b80a67808ecea328e96d850 to your computer and use it in GitHub Desktop.
test
(defn combine-symbol [x y]
(symbol (str x y)))
(defmacro is [char token]
`(~(combine-symbol '.is token) ; combind .is with token name
Tokenizer ~char))
(defmacro set-token-type [token-type]
`(def token-type (~(combine-symbol '.- (clojure.string/upper-case (str token-type))) TOKEN_TYPE)))
(cond
(is char Blank) (set-token-type blank)
(is char Digits) (set-token-type digits)
(is char Operator) (cond
(= char "@") (set-token-type close_cont_marker)
(= char ".") (set-token-type member_operator)
:else (set-token-type equal-operator))
(is char CodeCover) (set-token-type code_cover)
(is char ContCover) (if
(= char "<") (set-token-type left_cont_cover)
(set-token-type right_cont_cover))
(is char IdentifierPart) (set-token-type identifier_char)
(is char CloseMarker) (set-token-type close_cont_marker)
:else (set-token-type any_character))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment