Skip to content

Instantly share code, notes, and snippets.

@cognominal
Created May 23, 2012 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cognominal/2777326 to your computer and use it in GitHub Desktop.
Save cognominal/2777326 to your computer and use it in GitHub Desktop.
sprinting a Match, using a postfix 'for' instead of a block 'for' does not behave as expected.
sub sprint( Match:D $m, $nm='TOP', $indent is copy = 0) {
sub i { ' ' x ($indent * 2) }
sub show(Str $s) { $s.substr(0, 30).perl; }
my $s = '';
$s = i() ~ "$m.from() $m.to() $nm " ~ show( ~$m) ~ "\n";
for $m.caps {
$s ~= sprint $_.value, $_.key, $indent++ if $_.value ~~ Match; # for $m.caps;
}
$s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment