2023-05-07 10:11:11 -04:00
|
|
|
(assert-equal '() (arcana/tokenize ""))
|
|
|
|
(assert-equal '() (arcana/tokenize " "))
|
|
|
|
;(assert-equal '() (arcana/tokenize "\n"))
|
|
|
|
(assert-equal '() (arcana/tokenize "; foo"))
|
|
|
|
;(assert-equal '() (arcana/tokenize " ; foo\n ; foo"))
|
2023-05-07 07:16:53 -04:00
|
|
|
|
2023-05-07 10:11:11 -04:00
|
|
|
(assert-equal (arcana/tokenize "(") (list (cons 'TOKEN_ROUND_OPEN "(")))
|
|
|
|
(assert-equal (arcana/tokenize ")") (list (cons 'TOKEN_ROUND_CLOSE ")")))
|
|
|
|
(assert-equal (arcana/tokenize "[") (list (cons 'TOKEN_SQUARE_OPEN "[")))
|
|
|
|
(assert-equal (arcana/tokenize "]") (list (cons 'TOKEN_SQUARE_CLOSE "]")))
|
|
|
|
(assert-equal (arcana/tokenize "{") (list (cons 'TOKEN_CURLY_OPEN "{")))
|
|
|
|
(assert-equal (arcana/tokenize "}") (list (cons 'TOKEN_CURLY_CLOSE "}")))
|
|
|
|
(assert-equal (arcana/tokenize "'") (list (cons 'TOKEN_QUOTE "'")))
|
|
|
|
(assert-equal (arcana/tokenize "`") (list (cons 'TOKEN_QUASI_QUOTE "`")))
|
|
|
|
(assert-equal (arcana/tokenize ",") (list (cons 'TOKEN_QUASI_UNQUOTE ",")))
|
2023-05-07 07:16:53 -04:00
|
|
|
|
2023-05-07 10:11:11 -04:00
|
|
|
(assert-equal (arcana/tokenize "#f") (list (cons 'TOKEN_TAG "f")))
|
|
|
|
(assert-equal (arcana/tokenize "#t") (list (cons 'TOKEN_TAG "t")))
|
|
|
|
(assert-equal (arcana/tokenize "#false") (list (cons 'TOKEN_TAG "false")))
|
|
|
|
(assert-equal (arcana/tokenize "#true") (list (cons 'TOKEN_TAG "true")))
|
|
|
|
(assert-equal (arcana/tokenize "#qwe") (list (cons 'TOKEN_TAG "qwe")))
|
2023-05-07 07:16:53 -04:00
|
|
|
|
2023-05-07 10:11:11 -04:00
|
|
|
(assert-equal (arcana/tokenize "qwe") (list (cons 'TOKEN_IDENT "qwe")))
|
2023-05-07 07:16:53 -04:00
|
|
|
|
2023-05-07 10:11:11 -04:00
|
|
|
(assert-equal (arcana/tokenize "123") (list (cons 'TOKEN_NUM "123")))
|
|
|
|
;(assert-equal (arcana/tokenize "-123") (list (cons 'TOKEN_NUM "-123")))
|
2023-05-07 07:16:53 -04:00
|
|
|
|
2023-05-07 10:11:11 -04:00
|
|
|
(assert-equal (arcana/tokenize "\"\"") (list (cons 'TOKEN_STRING "")))
|
|
|
|
(assert-equal (arcana/tokenize "\"qwe\"") (list (cons 'TOKEN_STRING "qwe")))
|
|
|
|
(assert-equal (arcana/tokenize "\"\\\"\"") (list (cons 'TOKEN_STRING "\"")))
|
2023-05-07 07:16:53 -04:00
|
|
|
|
2023-05-07 10:11:11 -04:00
|
|
|
(assert-equal
|
|
|
|
(arcana/tokenize "(displayln \"qwe\")")
|
|
|
|
(list
|
|
|
|
(cons 'TOKEN_ROUND_OPEN "(")
|
|
|
|
(cons 'TOKEN_IDENT "displayln")
|
|
|
|
(cons 'TOKEN_STRING "qwe")
|
|
|
|
(cons 'TOKEN_ROUND_CLOSE ")")))
|
|
|
|
(assert-equal
|
|
|
|
(arcana/tokenize "(displayln (list 1))")
|
|
|
|
(list
|
|
|
|
(cons 'TOKEN_ROUND_OPEN "(")
|
|
|
|
(cons 'TOKEN_IDENT "displayln")
|
|
|
|
(cons 'TOKEN_ROUND_OPEN "(")
|
|
|
|
(cons 'TOKEN_IDENT "list")
|
|
|
|
(cons 'TOKEN_NUM "1")
|
|
|
|
(cons 'TOKEN_ROUND_CLOSE ")")
|
|
|
|
(cons 'TOKEN_ROUND_CLOSE ")")))
|