From d14ddd48c53f3d9ec960782c75f657a627456d22 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 18 Feb 2012 17:43:56 -0800 Subject: Allow braced output variables to actually be arbitrary substitutions. * eval.c (subst_vars): Treat the variable as an arbitrary expression rather than just a symbol. * match.c (subst_vars): Likewise. * parser.y (o_var): Further simplification. The first item in an output var is an expr and not an IDENT. * txr.1: Updated. * txr.vim: Likewise. --- txr.1 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 79943997..98a1387a 100644 --- a/txr.1 +++ b/txr.1 @@ -3334,6 +3334,8 @@ for the output clause. The syntax for this is @(NAME :filter }. The filter specification syntax is the same as in the output clause. See Output Filtering below. +.SS Output Variables: Indexing + Additional syntax is supported in output variables that is does not appear in pattern matching variables. @@ -3367,6 +3369,21 @@ The above produces the text "b,c" in a field 10 spaces wide. The [1..3] argument extracts a range of a; the "," argument specifies an alternate separator string, and 10 specifies the field width. +.SS Output Substitutions + +The brace syntax has another syntactic and semantic extension. In place +of the symbol, an expression may appear. The value of that expression +is substituted. + +Example: + + @(bind a "foo") + @(output) + @{`@a:` -10} + +Here, the quasiliteral expression `@a:` is evaluated, producing the string +"foo:". This string is printed right-adjusted in a 10 character field. + .SS The Repeat Directive The repeat directive is generates repeated text from a ``boilerplate'', -- cgit v1.2.3