Skip to content
Browse files

[viv] Fix HASH references in concise dumper

[Actions] Fix nested capture handling


git-svn-id: http://svn.pugscode.org/pugs@30895 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent a4b10b3 commit 0143df1119cc5615c4c556393de246ce4ccdfe15 sorear committed May 28, 2010
Showing with 12 additions and 5 deletions.
  1. +11 −4 Actions.pm
  2. +1 −1 viv
View
15 Actions.pm
@@ -1,11 +1,14 @@
use YAML::XS;
-
+use strict;
+use warnings;
package Actions;
# Generic ast translation done via autoload
our $AUTOLOAD;
my $SEQ = 1;
+my $OPT_log = 0;
+my $OPT_match = 0;
our %GENCLASS;
sub AUTOLOAD {
@@ -37,7 +40,7 @@ sub hoistast {
my @all;
my @fake;
for my $k (keys %$node) {
- print STDERR $node->{_reduced}, " $k\n" if $OPT_log;
+ print STDERR $node->{_reduced} // 'ANON', " $k\n" if $OPT_log;
my $v = $node->{$k};
if ($k eq 'O') {
for my $key (keys %$v) {
@@ -78,7 +81,7 @@ sub hoistast {
if (ref $v) {
for (@$v) {
next unless ref $_; # XXX skip keys?
- push @all, $_->{'_ast'};
+ push @all, $_->{'_ast'} //= hoistast($_);
}
}
}
@@ -117,7 +120,11 @@ sub hoistast {
# $r{zygs}{$k} = $SEQ++ if @$zyg and $k ne 'sym';
}
elsif (ref($v)) {
- if (exists $v->{'_ast'}) {
+ if ($v->isa('Cursor') && !$v->{_reduced}) {
+ $r{$k} = $v->{'_ast'} //= hoistast($v);
+ next;
+ }
+ elsif (exists $v->{'_ast'}) {
push @fake, $v->{'_ast'};
$r{$k} = $v->{'_ast'};
}
View
2 viv
@@ -188,7 +188,7 @@ sub concise {
if (!ref $node) {
return defined($node) ? shred($width, $width, "$node") : "undef";
} elsif (blessed($node) && ref($node) =~ /^VAST/) {
- my @pos = @{blessed $node->{"."}
+ my @pos = @{ref($node->{"."}) ne 'ARRAY'
? [ $node->{"."} ]
: $node->{"."} // []};
my %nam = %$node;

0 comments on commit 0143df1

Please sign in to comment.
Something went wrong with that request. Please try again.