Skip to content

Instantly share code, notes, and snippets.

@masak
Created August 1, 2010 14:27
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 masak/503417 to your computer and use it in GitHub Desktop.
Save masak/503417 to your computer and use it in GitHub Desktop.
sub descend-into(Match $m, :$key = "TOP", :&action, :@skip) {
action($m, $key);
for %($m).keys -> $key {
next if $key eq any @skip;
given $m{$key} {
when Match { descend-into($_, :$key, :&action, :@skip) }
when Array { descend-into($_, :$key, :&action, :@skip) for .list }
default { die "Unknown thing $_.WHAT() in parse tree!" }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment