From ff61f8c0f5a3b83e0ab2de6b4d98df877f7468b2 Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Fri, 1 Nov 2013 18:57:35 +0900 Subject: [PATCH] support quasiquote syntax --- piclib/built-in.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 0b2a9bb7..9c50a77a 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -110,3 +110,17 @@ (if-false (cons 'or (cdr exprs)))) (list 'let (list (list 'it test)) (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)))