diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-06-04 17:24:10 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-06-04 17:24:10 -0700 |
commit | 18f873d961486e46129eecfa17046faceb369939 (patch) | |
tree | 851d083f1aa6d5745f3a9f945b64bd836ec9cacb /match.c | |
parent | a7aa8066a82ac9fd7d2dffe83503b5db739ce3ec (diff) | |
download | txr-18f873d961486e46129eecfa17046faceb369939.tar.gz txr-18f873d961486e46129eecfa17046faceb369939.tar.bz2 txr-18f873d961486e46129eecfa17046faceb369939.zip |
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.
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 33 |
1 files changed, 30 insertions, 3 deletions
@@ -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))); |