Skip to content

Commit

Permalink
split_words Q:PIR -> nqp
Browse files Browse the repository at this point in the history
  • Loading branch information
kboga committed Jun 4, 2012
1 parent ccfc25a commit 2a43fae
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions src/HLL/Grammar.pm
Expand Up @@ -494,28 +494,20 @@ position C<pos>.
} }


our method split_words($words) { our method split_words($words) {
Q:PIR { my $pos := 0;
.include 'src/Regex/constants.pir' my $eos := nqp::chars($words);
.local string words my @result := nqp::list();
$P0 = find_lex '$words'
words = $P0 while 1 {
.local int pos, eos $pos := nqp::findnotcclass(pir::const::CCLASS_WHITESPACE,
.local pmc result $words, $pos, $eos);
pos = 0 last unless $pos < $eos;
eos = length words my $i := pir::find_cclass__Iisii(pir::const::CCLASS_WHITESPACE,
result = new ['ResizablePMCArray'] $words, $pos, $eos);
split_loop: nqp::push(@result, nqp::substr($words, $pos, $i - $pos));
pos = find_not_cclass .CCLASS_WHITESPACE, words, pos, eos $pos := $i;
unless pos < eos goto split_done }
$I0 = find_cclass .CCLASS_WHITESPACE, words, pos, eos return @result;
$I1 = $I0 - pos
$S0 = substr words, pos, $I1
push result, $S0
pos = $I0
goto split_loop
split_done:
.return (result)
};
} }


=begin =begin
Expand All @@ -525,6 +517,7 @@ position C<pos>.
An operator precedence parser. An operator precedence parser.


=end =end

method EXPR($preclim = '') { method EXPR($preclim = '') {
my $here := self.'!cursor_start'(); my $here := self.'!cursor_start'();
my $pos := nqp::getattr_i($here, $cursor_class, '$!from'); my $pos := nqp::getattr_i($here, $cursor_class, '$!from');
Expand Down

0 comments on commit 2a43fae

Please sign in to comment.