Talk language extensions v0.2
use MONKEY-SEE-NO-EVAL;
my $file = slurp 'data.sm';
my @Extensions = [];
sub Parse-Extension(\file, $ext is copy) {
my @r;
my $Pattern = ($ext ~~ /^^Find':'\s*(.+?)[^^Replace':']/)[0].Str;
my $Replace = ($ext ~~ /^^Replace':'\s?(\N+)/)[0].Str;
$Pattern ~~ s:m:g/\n\h*//;
EVAL 'file ~~ s:g/' ~ $Pattern ~ '/' ~ $Replace ~ '/';
}
for $file.lines -> $line {
given $line {
when /^'#:'Extend\swith\s(\N+?)$/ {
push @Extensions, slurp "$0"
}
}
}
for @Extensions -> $ext {
Parse-Extension $file, $ext;
}
say $file;
#my $s = 'a is [ say [ 1 + 2 ] and ] then [a and b]';
#$s ~~ s:g/'[' ~ ']' (.+?)/<:$0:>/;
#say $sINFO