summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2012-01-26 12:26:16 -0800
committerKaz Kylheku <kaz@kylheku.com>2012-01-26 12:26:16 -0800
commitb58791b726228b97297cc4512476f6016b9346a2 (patch)
tree2ed1b157bb29f6f90c97565adac4b2d54c2e1912 /txr.1
parentb7aae46f879bfc8a43781a08aaef9f506f7211bf (diff)
downloadtxr-b58791b726228b97297cc4512476f6016b9346a2.tar.gz
txr-b58791b726228b97297cc4512476f6016b9346a2.tar.bz2
txr-b58791b726228b97297cc4512476f6016b9346a2.zip
* eval.c (dwim_loc, dwim_op): Eliminated redundant re-evaluation
of range arguments. They are already evaluated since the cons expression is evaluates as part of the dwim arglist. Replaced some open code with function calls to the new listref and listref_l functions. (tostring, tostringp): made extern and moved to lib.c. * lib.c (listref, listref_l): New functions. (tostring, tostringp): moved here from eval.c. * lib.h (listref, listref_l, tostring, tostringp): Declared. * match.c (format_field): Handle index and range references. * txr.1: Documented new output variable syntax.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.138
1 files changed, 37 insertions, 1 deletions
diff --git a/txr.1 b/txr.1
index 3853fe7f..ff427fc8 100644
--- a/txr.1
+++ b/txr.1
@@ -1046,7 +1046,10 @@ into the literal template. If a is bound to "apple" and b to "banana",
the quasiliteral `one@a and two @{b}s` represents the string
"one apple and two bananas". A backquote escaped by a backslash represents
itself, and two consecutive @ characters code for a literal @.
-There is no \e@ escape.
+There is no \e@ escape. Quasiliterals support the full output variable
+syntax. Expressions within variables substitutions follow the evaluation rules
+of TXR Lisp when the quasiliteral occurs in TXR Lisp, and the rules of
+the TXR pattern language when the quasiliteral occurs in the pattern language.
.SS Numbers
@@ -3318,6 +3321,39 @@ for the output clause. The syntax for this is @(NAME :filter <filterspec>}.
The filter specification syntax is the same as in the output clause.
See Output Filtering below.
+Additional syntax is supported in output variables that is does not appear
+in pattern matching variables.
+
+A square bracket index notation may be used to extract elements from a variable
+which is a list, or to extract ranges. Elements are indexed from zero. This
+notation is only available in brace-enclosed syntax, and looks like this:
+
+.IP
+@{NAME[expr])
+
+Extract the element at the position given by expr.
+
+.IP
+@{NAME[expr1..expr2])
+
+Extract a list of elements from the position given by expr1, up to
+one position less than the position given by expr2.
+The elements from the range are catenated together to form a single string,
+with a separator character in between. The default character is a space.
+An alternate character may be given as a string argument.
+
+.TP
+Example:
+
+ @(bind a ("a" "b" "c" "d"))
+ @(output)
+ @{a[1..3] "," 10}
+ @(end)
+
+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 The Repeat Directive
The repeat directive is generates repeated text from a ``boilerplate'',