From 56da250d69615d70774dbc361fa2693cca1e3df4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 12 May 2022 12:11:28 -0400 Subject: Split backref/named captures into separate concepts for performance reasons. --- bp.1 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'bp.1') diff --git a/bp.1 b/bp.1 index 2524840..2c53ca6 100644 --- a/bp.1 +++ b/bp.1 @@ -305,7 +305,8 @@ against the edges file or line. Matches \f[I]pat\f[R], but does not consume any input (lookahead). .TP \f[B]\[at]\f[R] \f[I]pat\f[R] -Capture \f[I]pat\f[R] +Capture \f[I]pat\f[R]. +Captured patterns can be used in replacements. .TP \f[B]foo\f[R] The named pattern whose name is \f[B]\[lq]foo\[rq]\f[R]. @@ -315,11 +316,16 @@ Pattern names may contain dashes (\f[B]-\f[R]), but not underscores (\f[B]_\f[R]), since the underscore is used to match whitespace. See the \f[B]GRAMMAR FILES\f[R] section for more info. .TP +\f[B]\[at]\f[R] \f[I]name\f[R] \f[B]:\f[R] \f[I]pat\f[R] +For the rest of the current chain, define \f[I]name\f[R] to match +whatever \f[I]pat\f[R] matches, i.e.\ a backreference. +For example, \f[B]\[at]foo:word \[ga]( foo \[ga])\f[R] (matches +\f[B]\[lq]asdf(asdf)\[rq]\f[R] or \f[B]\[lq]baz(baz)\[rq]\f[R], but not +\f[B]\[lq]foo(baz)\[rq]\f[R]) +.TP \f[B]\[at]\f[R] \f[I]name\f[R] \f[B]=\f[R] \f[I]pat\f[R] Let \f[I]name\f[R] equal \f[I]pat\f[R] (named capture). -Named captures can be used as backreferences like so: \f[B]\[at]foo=word -\[ga]( foo \[ga])\f[R] (matches \f[B]\[lq]asdf(asdf)\[rq]\f[R] or -\f[B]\[lq]baz(baz)\[rq]\f[R], but not \f[B]\[lq]foo(baz)\[rq]\f[R]) +Named captures can be used in text replacements. .TP \f[I]pat\f[R] \f[B]=>\f[R] \f[B]\[dq]\f[R]\f[I]replacement\f[R]\f[B]\[dq]\f[R] Replace \f[I]pat\f[R] with \f[I]replacement\f[R]. -- cgit v1.2.3