diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2011-12-04 16:27:31 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2011-12-04 16:27:31 -0800 |
commit | 45376e552a18a2991421a8df34c931d56ecdd31d (patch) | |
tree | 093d00994cc6a6a556f8e7e22b69a342af7c073f /eval.c | |
parent | 336071aa972798af0252345d90e0a8d4acdc1e00 (diff) | |
download | txr-45376e552a18a2991421a8df34c931d56ecdd31d.tar.gz txr-45376e552a18a2991421a8df34c931d56ecdd31d.tar.bz2 txr-45376e552a18a2991421a8df34c931d56ecdd31d.zip |
* eval.c (op_qquote_error, op_unquote_error): New static functions.
(expand_qquote): Bugfix: missing case added to handle directly quoted
quasiquote.
(eval_init): Error-catching pseudo-operators registered in
op_table.
* parser.y (force_regular_quotes): New function.
(list): Quotes within unquotes and splices are regular.
* txr.1: Clarified new rules. Removed description of ,'form and ,*'form
special syntax.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -353,6 +353,19 @@ static val op_quote(val form, val env) return second(form); } +static val op_qquote_error(val form, val env) +{ + eval_error(form, lit("unexpanded quasiquote encountered"), nao); + return second(form); +} + +static val op_unquote_error(val form, val env) +{ + eval_error(form, lit("unquote/splice without matching quote"), nao); + return second(form); +} + + static val bindings_helper(val vars, val env, val sequential, val ctx_form) { val iter; @@ -739,6 +752,9 @@ static val expand_qquote(val qquoted_form) second(qquoted_form), nao); } else if (sym == unquote_s) { return expand(second(qquoted_form)); + } else if (sym == qquote_s) { + return rlcp(expand_qquote(expand_qquote(second(qquoted_form))), + qquoted_form); } else { val f = car(qquoted_form); val r = cdr(qquoted_form); @@ -1004,6 +1020,9 @@ void eval_init(void) apply_s = intern(lit("apply"), user_package); sethash(op_table, quote_s, cptr((mem_t *) op_quote)); + sethash(op_table, qquote_s, cptr((mem_t *) op_qquote_error)); + sethash(op_table, unquote_s, cptr((mem_t *) op_unquote_error)); + sethash(op_table, splice_s, cptr((mem_t *) op_unquote_error)); sethash(op_table, let_s, cptr((mem_t *) op_let)); sethash(op_table, let_star_s, cptr((mem_t *) op_let)); sethash(op_table, lambda_s, cptr((mem_t *) op_lambda)); |