Skip to content

Commit

Permalink
handle quantified captures in Match.perl
Browse files Browse the repository at this point in the history
Actually this works only decently for named (and not positional) captures
because of another rakudobug (RT #64952).
  • Loading branch information
moritz committed Apr 21, 2009
1 parent ad73895 commit 50f6111
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/setting/Match.pm
Expand Up @@ -24,7 +24,7 @@ class Match is also {
take "positional => [\n";
for @(self) {
take "$sp ";
take $_!_perl($indent + 4);
self!_perl_quant($_, $indent);
take ",\n";
}
take $sp;
Expand All @@ -33,14 +33,9 @@ class Match is also {
if %(self) {
take $sp;
take "named => \{\n";
for %(self).kv -> $name, $match {
take "$sp '$name' => ";
# XXX why is this a Str, not a Match?
if $match ~~ Match {
take $match!_perl($indent + 3);
} else {
take $match.perl;
}
for %(self).pairs {
take "$sp '{.key}' => ";
self!_perl_quant(.value, $indent);
take ",\n";
}
take "$sp\},\n";
Expand All @@ -50,6 +45,21 @@ class Match is also {
}
}

method !_perl_quant($obj, $indent) {
my $sp = ' ' x $indent;
if $obj ~~ Match {
take $obj!_perl($indent + 3);
} else {
take "[\n";
for $obj.list {
take $sp ~ ' ';
take $_!_perl($indent + 5);
take ",\n";
}
take "$sp ]";
}
}

multi method caps() {
my @caps = gather {
for self.list.pairs, self.hash.pairs -> $p {
Expand Down

0 comments on commit 50f6111

Please sign in to comment.