From 18f873d961486e46129eecfa17046faceb369939 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 4 Jun 2016 17:24:10 -0700 Subject: Allow @(repeat) to see variables in more places. * match.c (extract_vars): With these changes, if @{a b [c..d]} appears inside a @(repeat) or @(rep), variables in the b, c and d positions will be recognized for list iteration, not only a. --- match.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'match.c') diff --git a/match.c b/match.c index 2e65cd84..b4306d4a 100644 --- a/match.c +++ b/match.c @@ -1646,10 +1646,37 @@ static val extract_vars(val output_spec) if (consp(output_spec)) { val sym = first(output_spec); if (sym == var_s) { - if (bindable(second(output_spec))) - tai = list_collect(tai, second(output_spec)); + val name = second(output_spec); + val modifiers = third(output_spec); + + if (bindable(name)) + tai = list_collect(tai, name); else - tai = list_collect_nconc(tai, extract_vars(second(output_spec))); + tai = list_collect_nconc(tai, extract_vars(name)); + + for (; modifiers; modifiers = cdr(modifiers)) { + val mod = car(modifiers); + if (bindable(mod)) { + tai = list_collect(tai, mod); + } else if (consp(mod)) { + val msym = car(mod); + + if (msym == dwim_s) { + val arg = second(mod); + + if (bindable(arg)) { + tai = list_collect(tai, arg); + } else if (consp(arg) && car(arg) == rcons_s) { + val f = second(arg); + val t = third(arg); + if (bindable(f)) + tai = list_collect(tai, f); + if (bindable(t)) + tai = list_collect(tai, t); + } + } + } + } } else if (sym != expr_s) { for (; output_spec; output_spec = cdr(output_spec)) tai = list_collect_nconc(tai, extract_vars(car(output_spec))); -- cgit v1.2.3