diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-01-23 06:13:28 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-01-23 06:13:28 -0800 |
commit | a35aed57a078c841dc36d1fa547fe2e74431597f (patch) | |
tree | 410bd735fca0b9d7318f4a3d943dce35d8b25750 | |
parent | fca47effb1490e6308be3f9600fe782f3cdea862 (diff) | |
download | txr-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-- | ChangeLog | 12 | ||||
-rw-r--r-- | eval.c | 9 | ||||
-rw-r--r-- | eval.h | 1 | ||||
-rw-r--r-- | parser.y | 7 |
4 files changed, 19 insertions, 10 deletions
@@ -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. @@ -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); @@ -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); @@ -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); |