summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-01-26 21:29:54 -0800
committerKaz Kylheku <kaz@kylheku.com>2017-01-26 21:29:54 -0800
commit7a6a9a0507afa1f43a2b1a11dc3f373949bfdad7 (patch)
treef6306dbc7706535f9ee696e2202628d365566827
parent831271a00fa6cfea74d2dc10df3ce9f4233a6926 (diff)
downloadtxr-7a6a9a0507afa1f43a2b1a11dc3f373949bfdad7.tar.gz
txr-7a6a9a0507afa1f43a2b1a11dc3f373949bfdad7.tar.bz2
txr-7a6a9a0507afa1f43a2b1a11dc3f373949bfdad7.zip
bugfix: :filter not handled right in output var.
This issue was fixed in quasiliterals only. Because of the implementation duplicity between output vars and quasiliteral vars, we have to fix it in two places. When the parser handles quasiliterals, it builds vars without expanding the contents. The quasiliteral expander takes care of recognzing (sys:var ...) forms and properly handles them and their attributes, avoiding expanding the argument of a :filter keyword. When the parser handles an o_var that is a braced variable, it calls expand on its contents right there, then builds the (sys:var ...) form from the expanded contents. Why don't we just call expand_quasi in the o_var rule to have a single (sys:var ...) form expanded exactly how it is done in quasiliterals. * eval.c (expand_quasi): Change static function to external. * eval.c (expand_quasi): Declared. * parser.y (o_var): Construct an unexpanded (sys:var ...) form, and then wrap it in a one-element list. This is a de-facto quasi-items list, which can be expanded by expand_quasi. Then we pull the car of the expansion to get our expanded var.
-rw-r--r--eval.c2
-rw-r--r--eval.h1
-rw-r--r--parser.y7
3 files changed, 5 insertions, 5 deletions
diff --git a/eval.c b/eval.c
index 74521190..4ccc6f62 100644
--- a/eval.c
+++ b/eval.c
@@ -3182,7 +3182,7 @@ static val expand_var_mods(val mods, val menv)
}
}
-static val expand_quasi(val quasi_forms, val menv)
+val expand_quasi(val quasi_forms, val menv)
{
if (nilp(quasi_forms)) {
return nil;
diff --git a/eval.h b/eval.h
index f7b334db..0b147225 100644
--- a/eval.h
+++ b/eval.h
@@ -70,6 +70,7 @@ val eval(val form, val env, val ctx_form);
val eval_intrinsic(val form, val env);
val format_field(val string_or_list, val modifier, val filter, val eval_fun);
val subst_vars(val forms, val env, val filter);
+val expand_quasi(val quasi_forms, val menv);
val load(val target);
val expand(val form, val menv);
val expand_forms(val forms, val menv);
diff --git a/parser.y b/parser.y
index 01a1c91a..5a2ef76f 100644
--- a/parser.y
+++ b/parser.y
@@ -782,10 +782,9 @@ o_var : SYMTOK { val expr = symhlpr($1, nil);
expand_meta($2, nil),
expand_meta($3, nil), nao); }
else
- { $$ = list(var_s,
- expand($2, nil),
- expand_forms($3, nil), nao); }
- rl($$, num(parser->lineno)); }
+ { val quasi_var = list(var_s, $2, $3, nao);
+ val quasi_items = cons(quasi_var, nil);
+ $$ = car(expand_quasi(quasi_items, nil)); } }
| SYMTOK error { $$ = nil;
yybadtok(yychar, lit("variable spec")); }
;