diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2015-11-17 21:12:33 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2015-11-20 16:17:19 -0800 |
commit | ec5daf6385b68f08e82c106a925a758cf2b2bf14 (patch) | |
tree | a0023de2d03fcbe7a03e1ee72f1b9192980cb9ef /match.c | |
parent | 49b863afbd7e78dcc07d20df6652a969d919921e (diff) | |
download | txr-ec5daf6385b68f08e82c106a925a758cf2b2bf14.tar.gz txr-ec5daf6385b68f08e82c106a925a758cf2b2bf14.tar.bz2 txr-ec5daf6385b68f08e82c106a925a758cf2b2bf14.zip |
@(next) takes Lisp expression as source now.
* match.c (v_next): Evaluate the source expression as TXR Lisp,
unless it is meta-expression or meta-variable, or
the compatibility option is set to 124 or lower.
In those cases treat it as an expression of the TXR Pattern
* txr.1: Updated documentation of @(next) and all
relevant examples of @(next) everywhere.
Added compatibility notes.
Diffstat (limited to 'match.c')
-rw-r--r-- | match.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -2398,6 +2398,7 @@ static val v_next(match_files_ctx *c) if (rest(first_spec)) { val args = rest(first_spec); val source = first(args); + val meta = nil; if (source == args_k) { if (rest(args)) { @@ -2427,6 +2428,15 @@ static val v_next(match_files_ctx *c) } } + if (consp(source)) { + val sym = car(source); + if (sym == var_s || sym == expr_s) + meta = t; + } + + if (opt_compat && opt_compat <= 124) + meta = t; + if (keywordp(first(args))) { source = nil; } else { @@ -2442,7 +2452,10 @@ static val v_next(match_files_ctx *c) val list_expr = cdr(assoc(list_k, alist)); val string_expr = cdr(assoc(string_k, alist)); val nothrow = cdr(assoc(nothrow_k, alist)); - val str = txeval(specline, source, c->bindings); + val str = if3(meta, + txeval(specline, source, c->bindings), + eval_with_bindings(source, specline, c->bindings, + specline)); if (!from_var && !source && !string_expr && !list_expr) sem_error(specline, lit("next: source required before keyword arguments"), nao); |