From af2af7a4ed4321f955251f9da13a161a1e8940b3 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 10 Jan 2014 07:39:07 -0800 Subject: * 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. --- ChangeLog | 11 +++++++++++ match.c | 6 ++++-- txr.1 | 6 +++++- 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 + + * 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 * 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 -- cgit v1.2.3