summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-10-07 21:19:04 -0700
committerKaz Kylheku <kaz@kylheku.com>2011-10-07 21:19:04 -0700
commit81c5eee132546c90d878065722f52e70b27c359f (patch)
tree41e8b45cc3e000898b5c532c7a0fd4282159ff46 /txr.1
parentf5af9dd56254dd90f5985eb3e1dcbab042d72431 (diff)
downloadtxr-81c5eee132546c90d878065722f52e70b27c359f.tar.gz
txr-81c5eee132546c90d878065722f52e70b27c359f.tar.bz2
txr-81c5eee132546c90d878065722f52e70b27c359f.zip
* lib.c (eol_s): New symbol variable.
(obj_init): New variable initialized. * lib.h (eol_s): Declared. * match.c (match_line): Implemented horizontal skip as and new eol directive. (match_lines): Vertical skip defers to horizontal skip if there is trailing material. * txr.1: Updated. * lib.c (eol_s): New symbol variable. (obj_init): New variable initialized. * lib.h (eol_s): Declared. * match.c (match_line): Implemented horizontal skip as and new eol directive. (match_lines): Vertical skip defers to horizontal skip if there is trailing material. * txr.1: Updated.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.132
1 files changed, 29 insertions, 3 deletions
diff --git a/txr.1 b/txr.1
index b4546852..deda5f7f 100644
--- a/txr.1
+++ b/txr.1
@@ -906,6 +906,10 @@ A summary of the available directives follows:
Explicitly match the end of file. Fails if unmatched data remains in
the input stream.
+.IP @(eol)
+Explicitly match the end of line. Fails if the the current position is not the
+end of a line. Also Fails if no data remains (there is no current line).
+
.IP @(next)
Continue matching in another file.
@@ -915,9 +919,9 @@ Blocks may be referenced by @(accept) and @(fail) directives.
Blocks are discussed in the section BLOCKS below.
.IP @(skip)
-Treat the remaining query as a subquery unit, and search the lines of
-the input file until that subquery matches somewhere.
-A skip is also an anonymous block.
+Treat the remaining query as a subquery unit, and search the lines (or
+characters) of the input file until that subquery matches somewhere. A skip is
+also an anonymous block.
.IP @(trailer)
Treat the remaining query or subquery as a match for a trailing context. That
@@ -1137,6 +1141,17 @@ the query is understood to be processed there.
Of course, the remainder of the query can itself contain skip directives.
Each such directive performs a recursive subsearch.
+Skip comes in vertical and horizontal flavors. For instance, skip and match the
+last line:
+
+ @(skip)
+ @last
+ @(eof)
+
+Skip and match the last character of the line:
+
+ @(skip)@{last 1}@(eol)
+
The skip directive has an optional numeric argument. The value of this
argument limits the range of lines scanned for a match. Judicious use
of this feature can improve the performance of queries.
@@ -1194,6 +1209,17 @@ is a noop, because it means: "the remainder of the query must match starting on
the very next line", or, more briefly, "skip exactly zero lines", which is the
behavior if the skip directive is omitted altogether.
+Here is a trick for grabbing the fourth line from the bottom of the input:
+
+ @(skip)
+ @fourth_from_bottom
+ @(skip 1 3)
+ @(eof)
+
+Last three space-separated tokens of the line:
+
+ @(skip)@a @b @c@(eol)
+
.SS The Trailer Directive
The trailer directive introduces a trailing portion of a query or subquery