Skip to content

Commit 32a218b

Browse files
committed
Eliminate Q:PIR in starter/stopper.
Took a simpler approach than the kboga++ patches for these two.
1 parent afbe2be commit 32a218b

File tree

1 file changed

+8
-46
lines changed

1 file changed

+8
-46
lines changed

src/HLL/Grammar.pm

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -418,55 +418,17 @@ position C<pos>.
418418
}
419419

420420
method starter() {
421-
Q:PIR {
422-
.local pmc self, cur
423-
.local string target, start
424-
.local int pos
425-
self = find_lex 'self'
426-
427-
$P0 = self.'!cursor_start_all'()
428-
cur = $P0[0]
429-
target = $P0[1]
430-
pos = $P0[2]
431-
432-
$P0 = find_dynamic_lex '$*QUOTE_START'
433-
if null $P0 goto fail
434-
start = $P0
435-
436-
$I0 = length start
437-
$S0 = substr target, pos, $I0
438-
unless $S0 == start goto fail
439-
pos += $I0
440-
cur.'!cursor_pass'(pos, 'starter')
441-
fail:
442-
.return (cur)
443-
};
421+
my $start := $*QUOTE_START;
422+
nqp::isnull($start)
423+
?? self.'!cursor_start_cur'()
424+
!! self.'!LITERAL'($start)
444425
}
445426

446427
method stopper() {
447-
Q:PIR {
448-
.local pmc self, cur
449-
.local string target, stop
450-
.local int pos
451-
self = find_lex 'self'
452-
453-
$P0 = self.'!cursor_start_all'()
454-
cur = $P0[0]
455-
target = $P0[1]
456-
pos = $P0[2]
457-
458-
$P0 = find_dynamic_lex '$*QUOTE_STOP'
459-
if null $P0 goto fail
460-
stop = $P0
461-
462-
$I0 = length stop
463-
$S0 = substr target, pos, $I0
464-
unless $S0 == stop goto fail
465-
pos += $I0
466-
cur.'!cursor_pass'(pos, 'stopper')
467-
fail:
468-
.return (cur)
469-
};
428+
my $stop := $*QUOTE_STOP;
429+
nqp::isnull($stop)
430+
?? self.'!cursor_start_cur'()
431+
!! self.'!LITERAL'($stop)
470432
}
471433

472434
our method split_words(str $words) {

0 commit comments

Comments
 (0)