summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-22 20:02:45 -0400
committerKaz Kylheku <kaz@kylheku.com>2011-10-22 20:02:45 -0400
commitc6de88f486896be891e73009dbe2ea0411bf89e1 (patch)
tree78a4401ba4035004bf7bf1575f729dacd16b81a7 /txr.1
parent6ddb4b8f329b14e6133f29573cfeb88d1ee30846 (diff)
downloadtxr-c6de88f486896be891e73009dbe2ea0411bf89e1.tar.gz
txr-c6de88f486896be891e73009dbe2ea0411bf89e1.tar.bz2
txr-c6de88f486896be891e73009dbe2ea0411bf89e1.zip
Task #11474
* filter.c (filter_equal): Takes two filters instead of one. (lfilt_k, rfilt_k): New keyword variables. (filter_init): New keyword variables initialized. * filter.h (filter_equal): Declaration updated. (lfilt_k, rfilt_k): Declared. * lib.c (funcall4): New function. (do_curry_1234_34): New static function. (curry_1234_34): New function. (do_swap_12_21): New static function. (swap_12_21): New function. * lib.h (funcall4, curry_1234_34, swap_12_21): Declared. * match.c (dest_bind): Swap use the function argument swapping combinator when calling tree find such that the value being searched is on the left and pattern material is on the right. (v_bind): Implemented :lfilt and :rfilt. * txr.1: Documented :lfilt and :rfilt.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.153
1 files changed, 36 insertions, 17 deletions
diff --git a/txr.1 b/txr.1
index dbfffd86..49ea719c 100644
--- a/txr.1
+++ b/txr.1
@@ -2049,8 +2049,7 @@ Example:
The syntax of the @(bind) directive is:
- @(bind pattern form { keyword value }*)
-
+ @(bind pattern expression { keyword value }*)
The @(bind) directive is a kind of pattern match, which matches one or more
variables on in the left hand side pattern to the value of a variable on the
@@ -2124,27 +2123,47 @@ keyword symbol object.
.SS Keyword in The Bind Directive
-The Bind directive accepts the :filter keyword parameter. This specifies a
-filter for performing a more loose match between the left and right hand side
-objects. In the absence of a filter specification, text is compared verbatim,
-in a case-insensitive manner. If a filter is specified, it is applied to the
-left and right hand side. This has no effect if the left side is an unbound
-variable: no filtering takes place in the stablishment of a binding. It is for
-comparison purposes only.
+The Bind directive accepts these keywords
-Example: suppose A contains "abc" and B contains "ABC". The following directive will fail:
+.IP :lfilt
+The argument to :lfilt is a filter specification. When the left side pattern
+contains a binding which is therefore matched against its counterpart from the
+right side expression, the left side is filtered through the filter specified
+by :lfilt for the purposes of the comparison. For example:
- @(bind A B)
+ @(bind "a" "A" :lfilt :upcase)
+
+produces a match, since the left side is the same as the right after
+filtering through the :upcase filter.
+
+.IP :rfilt
+The argument to :rfilt is a filter specification. The specified filter is
+applied to the right hand side material prior to matching it against
+the left side. The filter is not applied if the left side is a variable
+with no binding. It is only applied to determine a match. Binding takes
+place the unmodified right hand side object.
+
+Example, the following produces a match:
-However, the following will succeed:
+ @(bind "A" "a" :rfilt :upcase)
- @(bind A B :filter :upcase)
-Bind will see that A and B have bindings already, and so compare their
-contents. Since the :upcase filter is specified, both their contents will be
-reduced through it for the purposes of the comparison, rendering them equal.
+.IP :filter
+This keyword is a shorthand to specify both filters to the same value.
+So for instance :filter :upcase is equivalent to :lfilt :upcase :rfilt :upcase.
+
+Of course, compound filters like (:from_html :upcase) are supported with
+all these keywords. The filters apply across arbitrary patterns and nested data.
+
+Example:
+
+ @(bind (a b c) ("A" "B" "C"))
+ @(bind (a b c) (("z" "a") "b" "c") :rfilt :upcase)
-Of course, compound filters are supported like (:from_html :upcase).
+Here, the first bind establishes the values for a, b and c, and the second bind
+succeeds, because the value of a matches the second element of the list ("z"
+"a") if it is upcased, and likewise b matches "b" and c matches "c" if these
+are upcased.
.SS The Set Directive