4 use File
::Slurp
qw(slurp);
5 use Term
::ANSIColor
qw(:constants);
7 my $without = slurp
(shift);
8 my $with = slurp
(shift);
9 my @chunks = split(/\{\*\}/,$without);
13 /^.* (?:regex|rule|token) \s+ ([:\w]+?(?:sym<.*?>)?)\s/sx;
15 $name =~ s/sym:<(.*)>/$1/g;
16 push (@last_token,$name);
19 my $first = shift @chunks;
20 $with =~ /^\Q$first\E/gc or die "can't match first chunk\n";
21 for my $chunk (@chunks) {
22 die "can't match next chunk:$chunk at",substr($with,pos($with),20),"\n" unless $with =~ /\G\{(.*?)\}\Q$chunk\E/sgc;
24 my $name = shift @last_token;
26 # print RED,'{',$action,'}',RESET,$chunk;
27 # print '{',$action,'}',$chunk;
29 my ($tag,) = $chunk =~ /#= (.*)/;
31 print "### $name $tag\n$action\n";
34 die "no action! chunk:$chunk";
35 # print GREEN,$chunk,RESET;