Skip to content

Improvements to the debugging show method of PGML. #1223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: PG-2.20
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions macros/core/PGML.pl
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,21 @@ sub new {
bless { type => $type, %$fields }, $class;
}

sub stringifyHash {
my ($self, $hash) = @_;
return '{ ' . join(
', ',
map {
"$_ => "
. (
ref($hash->{$_}) eq 'HASH'
? $self->stringifyHash($hash->{$_})
: ("'" . $self->quote($hash->{$_}) . "'"))
} PGML::Sort(keys %$hash)
) . ' }';

}

sub show {
my $self = shift;
my $indent = shift || "";
Expand All @@ -974,7 +989,9 @@ sub show {
next if $id eq "stack";
if (ref($self->{$id}) eq 'ARRAY') {
push(@strings,
$indent . $id . ": [" . join(',', map { "'" . $self->quote($_) . "'" } @{ $self->{$id} }) . "]");
$indent . $id . ": [" . join(', ', map { "'" . $self->quote($_) . "'" } @{ $self->{$id} }) . "]");
} elsif (ref($self->{$id}) eq 'HASH') {
push(@strings, $indent . $id . ": " . $self->stringifyHash($self->{$id}));
} else {
push(@strings, $indent . $id . ": '" . $self->quote($self->{$id}) . "'");
}
Expand Down Expand Up @@ -1227,7 +1244,7 @@ sub show {
my $self = shift;
my $indent = shift;
my @strings = ($self->SUPER::show($indent));
push(@strings, $indent . "stack: ['" . join("','", map { $self->quote($_) } @{ $self->{stack} }) . "']");
push(@strings, $indent . "stack: ['" . join("', '", map { $self->quote($_) } @{ $self->{stack} }) . "']");
return join("\n", @strings);
}

Expand Down