diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2009-11-20 14:30:16 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2009-11-20 14:30:16 -0800 |
commit | 768d6f677643332a440f822787517b1939135f2b (patch) | |
tree | 1731ee96a053b9185aac7cd7b64c1a421684b9eb /match.c | |
parent | 5ceb99701389a4a935165245e1dd0e7b8aaf6e40 (diff) | |
download | txr-768d6f677643332a440f822787517b1939135f2b.tar.gz txr-768d6f677643332a440f822787517b1939135f2b.tar.bz2 txr-768d6f677643332a440f822787517b1939135f2b.zip |
* match.c (dest_bind): Extended to handle more general forms
by using eval_form rather than direct symbol binding lookups.
False positive return fixed.
(match_line): Fixed merge to use eval_from
rather than direct symbol binding.
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 27 |
1 files changed, 12 insertions, 15 deletions
@@ -242,9 +242,7 @@ val dest_bind(val bindings, val pattern, val value) return t; } return cons(cons(pattern, value), bindings); - } - - if (consp(pattern)) { + } else if (consp(pattern)) { val piter = pattern, viter = value; while (consp(piter) && consp(viter)) @@ -261,9 +259,11 @@ val dest_bind(val bindings, val pattern, val value) if (bindings == t) return t; } + } else if (tree_find(value, pattern)) { + return bindings; } - return bindings; + return t; } val match_line(val bindings, val specline, val dataline, @@ -1337,22 +1337,19 @@ repeat_spec_same_data: sem_error(spec_linenum, lit("bad merge directive"), nao); for (; args; args = rest(args)) { - val other_sym = first(args); + val arg = first(args); - if (other_sym) { - val other_lookup = assoc(bindings, other_sym); + if (arg) { + val arg_eval = eval_form(arg, bindings); - if (!symbolp(other_sym)) - sem_error(spec_linenum, lit("non-symbol in merge directive"), - nao); - else if (!other_lookup) - sem_error(spec_linenum, lit("merge: nonexistent symbol ~a"), - other_sym, nao); + if (!arg_eval) + sem_error(spec_linenum, lit("merge: unbound variable in form ~a"), + arg, nao); if (merged) - merged = weird_merge(merged, cdr(other_lookup)); + merged = weird_merge(merged, cdr(arg_eval)); else - merged = cdr(other_lookup); + merged = cdr(arg_eval); } } |