Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add Cursor.ws .
  • Loading branch information
pmichaud committed Jul 12, 2011
1 parent 22b4fa8 commit 05d1982
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/QRegex/Cursor.nqp
Expand Up @@ -77,7 +77,7 @@ role QRegex::Cursor {
nqp::elems($!cstack);
}

method !cursor_pass($pos) {
method !cursor_pass($pos, $name?) {
$!match := 1;
$!pos := $pos;
$!regexsub := Q:PIR {
Expand All @@ -92,6 +92,21 @@ role QRegex::Cursor {
$!pos := -3;
}

method ws() {
# skip over any whitespace, fail if between two word chars
my $cur := self."!cursor_start"();
$!pos >= nqp::chars($!target)
?? $cur."!cursor_pass"($!pos, 'ws')
!! ($!pos < 1
|| !nqp::iscclass(pir::const::CCLASS_WORD, $!target, $!pos)
|| !nqp::iscclass(pir::const::CCLASS_WORD, $!target, $!pos-1)
) && $cur."!cursor_pass"(
pir::find_not_cclass__Iisii(
pir::const::CCLASS_WHITESPACE, $!target, $!pos, nqp::chars($!target)),
'ws');
$cur;
}

method alpha() {
my $cur := self."!cursor_start"();
$cur."!cursor_pass"($!pos+1)
Expand Down

0 comments on commit 05d1982

Please sign in to comment.