summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-01-23 06:13:28 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-01-23 06:13:28 -0800
commita35aed57a078c841dc36d1fa547fe2e74431597f (patch)
tree410bd735fca0b9d7318f4a3d943dce35d8b25750
parentfca47effb1490e6308be3f9600fe782f3cdea862 (diff)
downloadtxr-a35aed57a078c841dc36d1fa547fe2e74431597f.tar.gz
txr-a35aed57a078c841dc36d1fa547fe2e74431597f.tar.bz2
txr-a35aed57a078c841dc36d1fa547fe2e74431597f.zip
Bugfix: @(require ...) not expanding forms.
* eval.c (expand_forms): Static function becomes external. (expand_form): Remove case which handles do_s. * eval.h (expand_forms): Declared. * parser.y (elem): Expand both do_s and require_s forms by using expand_forms.
-rw-r--r--ChangeLog12
-rw-r--r--eval.c9
-rw-r--r--eval.h1
-rw-r--r--parser.y7
4 files changed, 19 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 221bc85d..f7047987 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2014-01-23 Kaz Kylheku <kaz@kylheku.com>
+
+ Bugfix: @(require ...) not expanding forms.
+
+ * eval.c (expand_forms): Static function becomes external.
+ (expand_form): Remove case which handles do_s.
+
+ * eval.h (expand_forms): Declared.
+
+ * parser.y (elem): Expand both do_s and require_s forms by
+ using expand_forms.
+
2014-01-22 Kaz Kylheku <kaz@kylheku.com>
* lib.c (conses, lazy_conses, func_set_env): New functions.
diff --git a/eval.c b/eval.c
index bd995ff4..3de5e7b8 100644
--- a/eval.c
+++ b/eval.c
@@ -1332,7 +1332,7 @@ static val op_quasi_lit(val form, val env)
return cat_str(subst_vars(rest(form), env), nil);
}
-static val expand_forms(val form)
+val expand_forms(val form)
{
if (atom(form)) {
return form;
@@ -1783,13 +1783,6 @@ val expand(val form)
return cons(sym, cons(cons(keysym,
cons(valsym, cons(hashform_ex, nil))),
body_ex));
- } else if (sym == do_s) {
- val forms = rest(form);
- val forms_ex = expand_forms(forms);
-
- if (forms == forms_ex)
- return form;
- return rlcp(cons(sym, forms_ex), form);
} else if (sym == quasi_s) {
val quasi = rest(form);
val quasi_ex = expand_quasi(quasi);
diff --git a/eval.h b/eval.h
index 163d352f..5389320d 100644
--- a/eval.h
+++ b/eval.h
@@ -39,6 +39,7 @@ val eval_progn(val forms, val env, val ctx_form);
val eval(val form, val env, val ctx_form);
val eval_intrinsic(val form, val env);
val expand(val form);
+val expand_forms(val forms);
val bindable(val obj);
val mapcarv(val fun, val list_of_lists);
diff --git a/parser.y b/parser.y
index 37fe0814..a29c7f00 100644
--- a/parser.y
+++ b/parser.y
@@ -341,8 +341,11 @@ texts : text %prec LOW { $$ = rlcp(cons($1, nil), $1); }
elem : texts { $$ = rlcp(cons(text_s, $1), $1);
$$ = rlcp(optimize_text($$), $$); }
| var { $$ = rl($1, num(lineno)); }
- | list { if (first($1) == do_s)
- $$ = expand($1);
+ | list { val sym = first($1);
+ if (sym == do_s || sym == require_s)
+ $$ = rlcp(cons(sym,
+ expand_forms(rest($1))),
+ $1);
else
$$ = $1; }
| COLL exprs_opt ')' elems END { $$ = list(coll_s, $4, nil, $2, nao);