summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2014-01-10 07:39:07 -0800
committerKaz Kylheku <kaz@kylheku.com>2014-01-10 07:39:07 -0800
commitaf2af7a4ed4321f955251f9da13a161a1e8940b3 (patch)
tree69f5864b4fbb97c0b8ea4fcb3828d1b1779c3753
parent7649cd2cc9165ad8019d9d33af697927fd2e64b4 (diff)
downloadtxr-af2af7a4ed4321f955251f9da13a161a1e8940b3.tar.gz
txr-af2af7a4ed4321f955251f9da13a161a1e8940b3.tar.bz2
txr-af2af7a4ed4321f955251f9da13a161a1e8940b3.zip
* match.c (do_txeval): Lift an annoying restriction in the pattern
language's expression evaluator. Whereas TXR Lisp expressions can be used int the pattern language, preceded by @, it was not possible to evaluate TXR Lisp variables this way. So instead of @var, some clumsy trick had to be used like @(identity var). This is not necessary any more. Code like @(next @*stdin*) will now work. * txr.1: Updated.
-rw-r--r--ChangeLog11
-rw-r--r--match.c6
-rw-r--r--txr.16
3 files changed, 20 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 5bdc3375..f5cf8026 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+014-01-10 Kaz Kylheku <kaz@kylheku.com>
+
+ * match.c (do_txeval): Lift an annoying restriction in the pattern
+ language's expression evaluator. Whereas TXR Lisp expressions can be
+ used int the pattern language, preceded by @, it was not possible
+ to evaluate TXR Lisp variables this way. So instead of @var,
+ some clumsy trick had to be used like @(identity var). This is not
+ necessary any more. Code like @(next @*stdin*) will now work.
+
+ * txr.1: Updated.
+
2014-01-10 Kaz Kylheku <kaz@kylheku.com>
* configure: Generate HAVE_VALGRIND as #define-d to 1, rathern
diff --git a/match.c b/match.c
index 23e96e9e..d46eced7 100644
--- a/match.c
+++ b/match.c
@@ -1432,8 +1432,10 @@ static val do_txeval(val spec, val form, val bindings, val allow_unbound)
} else if (regexp(car(form))) {
ret = form;
} else if (first(form) == var_s) {
- sem_error(spec, lit("metavariable @~s syntax cannot be used here"),
- second(form), nao);
+ 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) {
uw_env_begin;
uw_set_match_context(cons(spec, bindings));
diff --git a/txr.1 b/txr.1
index b93da15e..587e67e0 100644
--- a/txr.1
+++ b/txr.1
@@ -4763,7 +4763,7 @@ The TXR language contains an embedded Lisp dialect called TXR Lisp.
This language is exposed in TXR in three ways.
-Firstly, in any situation that calls for an expression, a Lisp compound
+Firstly, in any situation that calls for an expression, a Lisp
expression can be used, if it is preceded by the @ symbol. The Lisp expression
is evaluated and its value becomes the value of that expression.
Thus, TXR directives are embedded in literal text using @, and Lisp expressions
@@ -4785,6 +4785,10 @@ Bind variable a to the integer 4:
@(bind a @(+ 2 2))
+Bind variable b to the standard input stream:
+
+ @(bind a @*stdin*)
+
Define several Lisp functions using @(do):
@(do