Skip to content

Commit 76377d0

Browse files
committed
Try to fix the hangs that implementing backtracking into subrules introduced.
1 parent c9fd128 commit 76377d0

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/QAST/Compiler.nqp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,14 @@ class QAST::Compiler is HLL::Compiler {
271271

272272
method pass($node) {
273273
my $ops := self.post_new('Ops', :result(%*REG<cur>));
274+
my @backtrack := ["'backtrack'=>1"]
275+
if $node.backtrack ne 'r';
274276
if $node.name() {
275277
my $name := $*PASTCOMPILER.as_post($node.name(), :rtype<~>);
276-
$ops.push_pirop('callmethod', '"!cursor_pass"', %*REG<cur>, %*REG<pos>, $name);
278+
$ops.push_pirop('callmethod', '"!cursor_pass"', %*REG<cur>, %*REG<pos>, $name, |@backtrack);
277279
}
278280
else {
279-
$ops.push_pirop('callmethod', '"!cursor_pass"', %*REG<cur>, %*REG<pos>);
281+
$ops.push_pirop('callmethod', '"!cursor_pass"', %*REG<cur>, %*REG<pos>, |@backtrack);
280282
}
281283
$ops.push_pirop('return', %*REG<cur>);
282284
$ops;

src/QRegex/Cursor.nqp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ role NQPCursorRole {
9999
}
100100

101101
my $pass_mark := 1; # NQP has no constant table yet
102-
method !cursor_pass($pos, $name?) {
102+
method !cursor_pass($pos, $name?, :$backtrack) {
103103
$!match := $pass_mark;
104104
$!pos := $pos;
105-
$!restart := $!regexsub;
105+
$!restart := $!regexsub
106+
if $backtrack;
106107
self.'!reduce'($name) if $name;
107108
}
108109

0 commit comments

Comments
 (0)