Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

split_words Q:PIR -> nqp

  • Loading branch information...
commit 2a43fae1589e44819c743eacb25a009224d15683 1 parent ccfc25a
@kboga authored
Showing with 15 additions and 22 deletions.
  1. +15 −22 src/HLL/Grammar.pm
View
37 src/HLL/Grammar.pm
@@ -494,28 +494,20 @@ position C<pos>.
}
our method split_words($words) {
- Q:PIR {
- .include 'src/Regex/constants.pir'
- .local string words
- $P0 = find_lex '$words'
- words = $P0
- .local int pos, eos
- .local pmc result
- pos = 0
- eos = length words
- result = new ['ResizablePMCArray']
- split_loop:
- pos = find_not_cclass .CCLASS_WHITESPACE, words, pos, eos
- unless pos < eos goto split_done
- $I0 = find_cclass .CCLASS_WHITESPACE, words, pos, eos
- $I1 = $I0 - pos
- $S0 = substr words, pos, $I1
- push result, $S0
- pos = $I0
- goto split_loop
- split_done:
- .return (result)
- };
+ my $pos := 0;
+ my $eos := nqp::chars($words);
+ my @result := nqp::list();
+
+ while 1 {
+ $pos := nqp::findnotcclass(pir::const::CCLASS_WHITESPACE,
+ $words, $pos, $eos);
+ last unless $pos < $eos;
+ my $i := pir::find_cclass__Iisii(pir::const::CCLASS_WHITESPACE,
+ $words, $pos, $eos);
+ nqp::push(@result, nqp::substr($words, $pos, $i - $pos));
+ $pos := $i;
+ }
+ return @result;
}
=begin
@@ -525,6 +517,7 @@ position C<pos>.
An operator precedence parser.
=end
+
method EXPR($preclim = '') {
my $here := self.'!cursor_start'();
my $pos := nqp::getattr_i($here, $cursor_class, '$!from');
Please sign in to comment.
Something went wrong with that request. Please try again.