Skip to content

Commit 31fdcee

Browse files
committed
oops, should have implemented <|w> in qregex right away. With basic tests this time
1 parent 770e9f2 commit 31fdcee

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/QRegex/P6Regex/Actions.nqp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,22 @@ class QRegex::P6Regex::Actions is HLL::Actions {
327327
make $qast;
328328
}
329329

330+
method assertion:sym<|>($/) {
331+
my $qast;
332+
my $name := ~$<identifier>;
333+
if $name eq 'c' {
334+
# codepoint boundaries alway match in
335+
# our current Unicode abstraction level
336+
$qast := 0;
337+
}
338+
elsif $name eq 'w' {
339+
$qast := QAST::Regex.new(:rxtype<subrule>, :subtype<method>,
340+
:node($/), PAST::Node.new('wb'),
341+
:name('') );
342+
}
343+
make $qast;
344+
}
345+
330346
method assertion:sym<method>($/) {
331347
my $qast := $<assertion>.ast;
332348
$qast.subtype('method');

src/QRegex/P6Regex/Grammar.nqp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ grammar QRegex::P6Regex::Grammar is HLL::Grammar {
176176

177177
token assertion:sym<?> { '?' [ <?before '>' > | <assertion> ] }
178178
token assertion:sym<!> { '!' [ <?before '>' > | <assertion> ] }
179+
token assertion:sym<|> { '|' <identifier> }
179180

180181
token assertion:sym<method> {
181182
'.' <assertion>

t/qregex/rx_subrules

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,7 @@ a<!wb> abc\ndef\n-==\nghi y \w\w nonword boundary
6666
<+alpha-[Jj]>+ abc y character class with no j
6767
<+ alpha - [ Jj ]> abc y character class with no j with ws
6868
^<+alpha-[Jj]>+$ aJc n character class with no j fail
69+
^a<|w> a/ y <|w> matches
70+
^a<|w> ab n <|w> without match
6971

7072
## vim: noexpandtab tabstop=4 shiftwidth=4

0 commit comments

Comments
 (0)