1 /* -*-comment-start: "//";comment-end:""-*-
2 * Mes --- Maxwell Equations of Software
3 * Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
5 * This file is part of Mes.
7 * Mes is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or (at
10 * your option) any later version.
12 * Mes is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Mes. If not, see <http://www.gnu.org/licenses/>.
23 unquote (scm *x) ///((no-environment))
25 return cons (&symbol_unquote, x);
29 unquote_splicing (scm *x) ///((no-environment))
31 return cons (&symbol_unquote_splicing, x);
37 return cons (&symbol_syntax, x);
41 unsyntax (scm *x) ///((no-environment))
43 return cons (&symbol_unsyntax, x);
47 unsyntax_splicing (scm *x) ///((no-environment))
49 return cons (&symbol_unsyntax_splicing, x);
53 eval_quasiquote (scm *e, scm *a)
55 if (e == &scm_nil) return e;
56 else if (atom_p (e) == &scm_t) return e;
57 else if (eq_p (car (e), &symbol_unquote) == &scm_t)
58 return builtin_eval (cadr (e), a);
59 else if (e->type == PAIR && e->car->type == PAIR
60 && eq_p (caar (e), &symbol_unquote_splicing) == &scm_t)
61 return append2 (builtin_eval (cadar (e), a), eval_quasiquote (cdr (e), a));
62 return cons (eval_quasiquote (car (e), a), eval_quasiquote (cdr (e), a));
66 eval_quasisyntax (scm *e, scm *a)
68 if (e == &scm_nil) return e;
69 else if (atom_p (e) == &scm_t) return e;
70 else if (eq_p (car (e), &symbol_unsyntax) == &scm_t)
71 return builtin_eval (cadr (e), a);
72 else if (e->type == PAIR && e->car->type == PAIR
73 && eq_p (caar (e), &symbol_unsyntax_splicing) == &scm_t)
74 return append2 (builtin_eval (cadar (e), a), eval_quasisyntax (cdr (e), a));
75 return cons (eval_quasisyntax (car (e), a), eval_quasisyntax (cdr (e), a));
78 scm *add_environment (scm *a, char const *name, scm *x);
81 add_unquoters (scm *a)
83 a = cons (cons (&symbol_unquote, &scm_unquote), a);
84 a = cons (cons (&symbol_unquote_splicing, &scm_unquote_splicing), a);
89 add_unsyntaxers (scm *a)
91 a = cons (cons (&symbol_unsyntax, &scm_unsyntax), a);
92 a = cons (cons (&symbol_unsyntax_splicing, &scm_unsyntax_splicing), a);
98 scm*add_unquoters (scm *a){}
99 scm*add_unsyntaxers (scm *a){}
100 scm*eval_unsyntax (scm *e, scm *a){}
101 scm*eval_quasiquote (scm *e, scm *a){}
102 scm*eval_quasisyntax (scm *e, scm *a){}
104 #endif // !QUASIQUOTE