summaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-02-13 02:58:57 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-02-13 02:58:57 -0800
commitf31be2486084f6388ea212f18574584ab4c13e64 (patch)
treea0d22b9fa99ff8067137de7aa83a8d7b064fc9c8 /eval.c
parentb970b2caac831c73078d2cee125e717124dff150 (diff)
downloadtxr-f31be2486084f6388ea212f18574584ab4c13e64.tar.gz
txr-f31be2486084f6388ea212f18574584ab4c13e64.tar.bz2
txr-f31be2486084f6388ea212f18574584ab4c13e64.zip
* eval.c (subst_vars): Handle lone symbols (not wrapped
in sys::var form) as variables. This allows interpretation of metanums in quasiliterals, because these are replaced by variables in the op expander. * parser.l: Recognize METANUM in QSILIT state. * parser.y (quasi_item): METANUM parsed in quasiliteral. * txr.vim: Metanums highlighted properly.
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/eval.c b/eval.c
index 07c7fc1c..380b4623 100644
--- a/eval.c
+++ b/eval.c
@@ -1117,6 +1117,20 @@ static val subst_vars(val forms, val env)
forms = cdr(forms);
continue;
}
+ } else if (bindable(form)) {
+ val pair = lookup_var(env, form);
+
+ if (pair) {
+ val str = cdr(pair);
+
+ if (!stringp(str) && !listp(str))
+ str = format(nil, lit("~a"), str, nao);
+
+ forms = cons(str, rest(forms));
+ continue;
+ }
+ uw_throwf(query_error_s, lit("unbound variable ~a"),
+ form, nao);
}
list_collect(iter, form);