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 (cell_symbol_unquote, x);
29 unquote_splicing (SCM x) ///((no-environment))
31 return cons (cell_symbol_unquote_splicing, x);
35 eval_quasiquote (SCM e, SCM a)
37 return vm_call (vm_eval_quasiquote, e, cell_undefined, a);
43 if (r1 == cell_nil) return r1;
44 else if (atom_p (r1) == cell_t) return r1;
45 else if (eq_p (car (r1), cell_symbol_unquote) == cell_t)
46 return eval_env (cadr (r1), r0);
47 else if (TYPE (r1) == PAIR && TYPE (car (r1)) == PAIR
48 && eq_p (caar (r1), cell_symbol_unquote_splicing) == cell_t)
50 r2 = eval_env (cadar (r1), r0);
51 return append2 (r2, eval_quasiquote (cdr (r1), r0));
53 r2 = eval_quasiquote (car (r1), r0);
54 return cons (r2, eval_quasiquote (cdr (r1), r0));
60 SCM q = assq_ref_cache (cell_symbol_the_unquoters, a);
61 return append2 (q, a);
65 SCM add_unquoters (SCM a){}
66 SCM eval_quasiquote (SCM e, SCM a){}
69 SCM unquote_splicing (SCM x){}
70 SCM vm_eval_quasiquote () {}
78 return cons (cell_symbol_syntax, x);
82 unsyntax (SCM x) ///((no-environment))
84 return cons (cell_symbol_unsyntax, x);
88 unsyntax_splicing (SCM x) ///((no-environment))
90 return cons (cell_symbol_unsyntax_splicing, x);
94 eval_quasisyntax (SCM e, SCM a)
96 return vm_call (vm_eval_quasisyntax, e, cell_undefined, a);
100 vm_eval_quasisyntax ()
102 if (r1 == cell_nil) return r1;
103 else if (atom_p (r1) == cell_t) return r1;
104 else if (eq_p (car (r1), cell_symbol_unsyntax) == cell_t)
105 return eval_env (cadr (r1), r0);
106 else if (TYPE (r1) == PAIR && TYPE (car (r1)) == PAIR
107 && eq_p (caar (r1), cell_symbol_unsyntax_splicing) == cell_t)
109 r2 = eval_env (cadar (r1), r0);
110 return append2 (r2, eval_quasisyntax (cdr (r1), r0));
112 r2 = eval_quasisyntax (car (r1), r0);
113 return cons (r2, eval_quasisyntax (cdr (r1), r0));
117 add_unsyntaxers (SCM a)
119 SCM q = assq_ref_cache (cell_symbol_the_unsyntaxers, a);
120 return append2 (q, a);
123 #else // !QUASISYNTAX
125 SCM unsyntax (SCM x){}
126 SCM unsyntax_splicing (SCM x){}
127 SCM add_unsyntaxers (SCM a){}
128 SCM eval_quasisyntax (SCM e, SCM a){}
129 SCM vm_eval_quasisyntax () {}
131 #endif // !QUASISYNTAX