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 $s
#:Extend with extension.sme
#:Extend with make-var.sme
make a be 1
if a is in <1 2 3> or a is in <4 5 6>
say true
end
Find:
(<[\w\-]>+)
[\sis\s+in\s+]
(.+?)
(and||or||$$)
Replace: $0 ~~ one $1$2
Find:
^^make\s+
(.+?)
\s+be\s+
(\N+)
Replace: my \\$0 = my \$$0 = $1;