Skip to content

Commit e3d5c8b

Browse files
committed
Add !LITERAL method to NQPCursorRole to simplify HLL literal matching.
1 parent dfef2ef commit e3d5c8b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/QRegex/Cursor.nqp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ role NQPCursorRole {
116116
else { $cur."!cursor_pass"($!pos, '') }
117117
$cur;
118118
}
119+
120+
method !LITERAL($str) {
121+
my $cur := self."!cursor_start"();
122+
my $litlen := nqp::chars($str);
123+
$cur."!cursor_pass"($!pos + $litlen)
124+
if nqp::substr($!target, $!pos, $litlen) eq $str;
125+
$cur;
126+
}
119127

120128
method ws() {
121129
# skip over any whitespace, fail if between two word chars

0 commit comments

Comments
 (0)