Permalink
Browse files

[viv] Translate !~~

[Actions] Don't duplicate metaops


git-svn-id: http://svn.pugscode.org/pugs@30929 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 3d3842b commit dbe0283491fb8e76e192108eb9bf4ea2d6638915 sorear committed May 29, 2010
Showing with 14 additions and 1 deletion.
  1. +6 −1 Actions.pm
  2. +8 −0 viv
View
@@ -4,6 +4,7 @@ use warnings;
our $OPT_log;
our $OPT_match;
package Actions;
+use Scalar::Util 'refaddr';
# Generic ast translation done via autoload
@@ -38,6 +39,7 @@ sub hoistast {
my $text = $node->Str;
my %r;
my @all;
+ my %allused;
my @fake;
for my $k (keys %$node) {
print STDERR $node->{_reduced} // 'ANON', " $k\n" if $OPT_log;
@@ -81,7 +83,10 @@ sub hoistast {
if (ref $v) {
for (@$v) {
next unless ref $_; # XXX skip keys?
- push @all, $_->{'_ast'} if defined $_->{'_ast'};
+ push @all, $_->{'_ast'} if defined $_->{'_ast'}
+ and !($allused{refaddr $_}++);
+ # don't generate multiple entries for a multi-named
+ # capture
}
}
}
View
8 viv
@@ -840,6 +840,14 @@ sub indent {
{ package VAST::infix; our @ISA = 'VAST::Base';
}
+{ package VAST::infix_prefix_meta_operator__S_Bang; our @ISA = 'VAST::Base';
+ sub emit_p5 { my $self = shift;
+ my @t = $self->SUPER::emit_p5;
+ $t[1] = '~' if $t[1] eq '=~';
+ @t;
+ }
+}
+
{ package VAST::SYM_infix__S_ColonEqual; our @ISA = 'VAST::Item_assignment';
sub emit_p5 { my $self = shift;
my @t = $self->SUPER::emit_p5;

0 comments on commit dbe0283

Please sign in to comment.