1
0
Fork 0
lesson-lisp/tests/arcana/parse.scm

37 lines
1.1 KiB
Scheme
Raw Normal View History

2023-05-07 10:11:11 -04:00
(assert-equal
'(displayln (+ 123 456))
(arcana/parse
(list
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "displayln")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "+")
(cons 'TOKEN_NUM "123")
(cons 'TOKEN_NUM "456")
(cons 'TOKEN_ROUND_CLOSE ")")
(cons 'TOKEN_ROUND_CLOSE ")"))))
2023-05-07 08:56:04 -04:00
2023-05-07 10:11:11 -04:00
(assert-equal
'(quasiquote
(cons
(unquote (+ 12 34))
(unquote (+ 56 78))))
(arcana/parse
(list
(cons 'TOKEN_QUASI_QUOTE "`")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "cons")
(cons 'TOKEN_QUASI_UNQUOTE ",")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "+")
(cons 'TOKEN_NUM "12")
(cons 'TOKEN_NUM "34")
(cons 'TOKEN_ROUND_CLOSE ")")
(cons 'TOKEN_QUASI_UNQUOTE ",")
(cons 'TOKEN_ROUND_OPEN "(")
(cons 'TOKEN_IDENT "+")
(cons 'TOKEN_NUM "56")
(cons 'TOKEN_NUM "78")
(cons 'TOKEN_ROUND_CLOSE ")")
(cons 'TOKEN_ROUND_CLOSE ")"))))