Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Lookaheads should not change highexpect.
  • Loading branch information
jnthn committed Dec 10, 2012
1 parent fb3f186 commit e6ea357
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/QRegex/Cursor.nqp
Expand Up @@ -373,19 +373,24 @@ role NQPCursorRole is export {

method before($regex) {
my int $orig_highwater := nqp::getattr_i($!shared, ParseShared, '$!highwater');
my $orig_highexpect := nqp::getattr($!shared, ParseShared, '@!highexpect');
nqp::bindattr($!shared, ParseShared, '@!highexpect', []);
my $cur := self."!cursor_start"();
nqp::bindattr_i($cur, $?CLASS, '$!pos', $!pos);
nqp::getattr_i($regex($cur), $?CLASS, '$!pos') >= 0 ??
$cur."!cursor_pass"($!pos, 'before') !!
nqp::bindattr_i($cur, $?CLASS, '$!pos', -3);
nqp::bindattr_i($!shared, ParseShared, '$!highwater', $orig_highwater);
nqp::bindattr($!shared, ParseShared, '@!highexpect', $orig_highexpect);
$cur;
}

# Expects to get a regex whose syntax tree was flipped during the
# compile.
method after($regex) {
my int $orig_highwater := nqp::getattr_i($!shared, ParseShared, '$!highwater');
my $orig_highexpect := nqp::getattr($!shared, ParseShared, '@!highexpect');
nqp::bindattr($!shared, ParseShared, '@!highexpect', []);
my $cur := self."!cursor_start"();
my str $target := nqp::getattr_s($!shared, ParseShared, '$!target');
my $shared := pir::repr_clone__PP($!shared);
Expand All @@ -397,6 +402,7 @@ role NQPCursorRole is export {
$cur."!cursor_pass"($!pos, 'after') !!
nqp::bindattr_i($cur, $?CLASS, '$!pos', -3);
nqp::bindattr_i($!shared, ParseShared, '$!highwater', $orig_highwater);
nqp::bindattr($!shared, ParseShared, '@!highexpect', $orig_highexpect);
$cur;
}

Expand Down

0 comments on commit e6ea357

Please sign in to comment.