Skip to content

Commit

Permalink
Tune handling of positional captures
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Jun 10, 2019
1 parent 36fa16b commit 0e7c6e7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/core/Match.pm6
Expand Up @@ -99,12 +99,15 @@ my class Match is Capture is Cool does NQPMatchRole {
$name = nqp::getattr_s($subcur, $?CLASS, '$!name');
if nqp::not_i(nqp::isnull_s($name)) && nqp::isgt_i(nqp::chars($name), 0) {
my Mu $submatch := $subcur.MATCH;
if nqp::eqat($name, '$', 0) && (nqp::iseq_s($name, '$!from') || nqp::iseq_s($name, '$!to')) {
my int $first = nqp::ord($name);
if nqp::iseq_i($first, 36) && (nqp::iseq_s($name, '$!from') || nqp::iseq_s($name, '$!to')) {
nqp::bindattr_i(self, Match, $name, $submatch.from);
}
elsif nqp::islt_i(nqp::index($name, '='), 0) {
if nqp::iscclass(nqp::const::CCLASS_NUMERIC, $name, 0) {
my $idx := nqp::fromstr_I($name, Int);
if nqp::islt_i($first, 58) && nqp::iscclass(nqp::const::CCLASS_NUMERIC, $name, 0) {
my $idx := nqp::iseq_i(nqp::chars($name), 1)
?? nqp::sub_i($first, 48)
!! nqp::fromstr_I($name, Int);
nqp::istype(nqp::atpos($list, $idx), Array)
?? nqp::atpos($list, $idx).append($submatch)
!! nqp::bindpos($list, $idx, $submatch);
Expand Down

0 comments on commit 0e7c6e7

Please sign in to comment.