support quasiquote syntax

This commit is contained in:
Yuichi Nishiwaki 2013-11-01 18:57:35 +09:00
parent 81aea6b3ba
commit ff61f8c0f5
1 changed files with 14 additions and 0 deletions

View File

@ -110,3 +110,17 @@
(if-false (cons 'or (cdr exprs)))) (if-false (cons 'or (cdr exprs))))
(list 'let (list (list 'it test)) (list 'let (list (list 'it test))
(list 'if 'it 'it if-false))))) (list 'if 'it 'it if-false)))))
(define-macro (quasiquote x)
(cond
((symbol? x) (list 'quote x))
((pair? x)
(cond
((eq? 'unquote (car x)) (cadr x))
((and (pair? (car x))
(eq? 'unquote-splicing (caar x)))
(list 'append (cadr (car x)) (list 'quasiquote (cdr x))))
(#t (list 'cons
(list 'quasiquote (car x))
(list 'quasiquote (cdr x))))))
(#t x)))