[t/spec] Unfudge log tests in real-bridge.t.
[pugs.git] / misc / pixie / insert_actions
blob23ed2181cd6220893660d223b6cfd568838f665b
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 use Term::ANSIColor qw(:constants);
5 open(my $std,shift);
7 open(my $actions,shift);
8 my (%actions,$action);
9 for (<$actions>) {
10 if (/^### (.*?)\s*$/) {
11 $action = $1;
12 } else {
13 $actions{$action} .= $_;
17 my ($name);
18 for (<$std>) {
19 if (/(?:regex|rule|token) \s+ ([:\w]+?(?:sym<.*?>)?)\s/x) {
20 $name = $1;
21 # $name =~ s/:sym<(.*)>/$1/;
22 # warn YELLOW,"$name",RESET;
24 if (/\{\*\} .*? (?:\#=(.*))?$/x) {
25 my $tag = $1 || "";
26 my $full_name = $name . $tag;
27 # warn "inserting ".GREEN.$full_name.RESET."\n".$_ if $actions{$full_name};
28 # warn "not inserting <".RED.$full_name.RESET.">" unless $actions{$full_name};
29 my $content = $actions{$full_name} // "*";
30 chomp($content);
31 s/\{\*\}/{$content}/;
33 print $_;