summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-09-12 22:00:51 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-09-12 22:00:51 -0700
commitaf7509ea7af412e5290906f5c5fa092ff87c077f (patch)
treec78296699418851c25d02b1316af92e25e496131
parent501f5a9e01b9b27e9b2199691c122cb30b956508 (diff)
downloadtxr-af7509ea7af412e5290906f5c5fa092ff87c077f.tar.gz
txr-af7509ea7af412e5290906f5c5fa092ff87c077f.tar.bz2
txr-af7509ea7af412e5290906f5c5fa092ff87c077f.zip
doc: more notes on regex % operator syntax.
* txr.1: The dual precedence of % leads to surprises; when parentheses are used around % expressions, they don't behave symmetrically on both sides.
-rw-r--r--txr.134
1 files changed, 34 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 4cf4b2fe..c2955ea7 100644
--- a/txr.1
+++ b/txr.1
@@ -2502,6 +2502,40 @@ is
.B not
equivalent to
.codn (R1%)R2 .
+Also note that
+.code A(XY%Z)B
+is equivalent to
+.codn AX(Y%Z)B .
+This is because the precedence of
+.code %
+is higher than that of catenation on its left side; this rule prevents the given
+syntax from expressing the
+.code XY
+catenation. The expression may be understood as:
+.code A(X(Y%Z))B
+where the inner parentheses clarify how the syntax surrounding the
+.code %
+operator is being parsed, and the outer parentheses are superfluous.
+The correct way to assert catenation of
+.code XY
+as the left operand of
+.code %
+is
+.codn A(XY)%ZB .
+To specify
+.code XY
+as the left operand, and limit the right operand to just
+.codn Z ,
+the correct syntax is
+.codn A((XY)%Z)B .
+By contrast, the expression
+.code A(X%YZ)B
+is not equivalent to
+.code A(X%Y)ZB
+because the precedence of
+.code %
+is lower than that of catenation on its right side. The operator is
+effectively "bi-precedential".
.coIP ~R
Match the opposite of the following expression
.codn R ;