summaryrefslogtreecommitdiffstats
path: root/match.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-03-25 22:10:31 -0700
committerKaz Kylheku <kaz@kylheku.com>2014-03-25 22:10:31 -0700
commitf4a6c56c8e8841c1991c1bb44546681ccbdb8f3a (patch)
tree943413daf7f15ed66562552b9cb43c8ada7053d0 /match.c
parent4c6d387b73dca86caed48b1e786c5c1bc2c4716b (diff)
downloadtxr-f4a6c56c8e8841c1991c1bb44546681ccbdb8f3a.tar.gz
txr-f4a6c56c8e8841c1991c1bb44546681ccbdb8f3a.tar.bz2
txr-f4a6c56c8e8841c1991c1bb44546681ccbdb8f3a.zip
* eval.c (me_quasilist): New static function.
(eval_init): Register me_quasilist as quasilist macro expander. * lib.c (quasilist_s): New global variable. (obj_init): quasilist_s initialized. * lib.h (quasilist_s): Declared. * match.c (do_txreval): Handle quasilist syntax. * parser.l (QWLIT): New exclusive state. Extend lexical grammar to transition to QWLIT state upon the #` or #*` sequence which kicks off a word literal, and in that state, piecewise lexically analyze the QLL, mostly by borrowing rules from quasiliterals. * parser.y (QWORDS, QWSPLICE): New tokens. (n_exprs): Integrate splicing form of QLL syntax. (n_expr): Integrate non-splicing form of QLL syntax. (litchars): Propagate line number info. (quasilit): Fix "string literal" wording in error message. * txr.1: Introduced WLL abbreviation for word list literals, cleaned up the text a little, and documented QLL's.
Diffstat (limited to 'match.c')
-rw-r--r--match.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/match.c b/match.c
index 9b2a6900..ae37a56d 100644
--- a/match.c
+++ b/match.c
@@ -1449,19 +1449,29 @@ static val do_txeval(val spec, val form, val bindings, val allow_unbound)
ret = cdr(binding);
}
} else if (consp(form)) {
- if (first(form) == quasi_s) {
+ val sym = first(form);
+ if (sym == quasi_s) {
uw_env_begin;
uw_set_match_context(cons(spec, bindings));
ret = cat_str(subst_vars(rest(form), bindings, nil), nil);
uw_env_end;
- } else if (regexp(car(form))) {
+ } else if (sym == quasilist_s) {
+ uw_env_begin;
+ val iter;
+ list_collect_decl (out, tail);
+ uw_set_match_context(cons(spec, bindings));
+ for (iter = rest(form); iter != nil; iter = cdr(iter))
+ list_collect(tail, subst_vars(cdr(car(iter)), bindings, nil));
+ ret = out;
+ uw_env_end;
+ } else if (regexp(sym)) {
ret = form;
- } else if (first(form) == var_s) {
+ } else if (sym == var_s) {
uw_env_begin;
uw_set_match_context(cons(spec, bindings));
ret = eval(second(form), make_env(bindings, nil, nil), form);
uw_env_end;
- } else if (first(form) == expr_s) {
+ } else if (sym == expr_s) {
uw_env_begin;
uw_set_match_context(cons(spec, bindings));
ret = eval(rest(form), make_env(bindings, nil, nil), form);