Quick actions

cmd+k|ctrl+k

Navigation

Languages

Talk language extensions v0.2

Snippet info

Language

Raku

Visibility

public

Author

theangryepicbanana

Created

2018-07-28T23:34:15Z

Updated

2018-07-30T18:18:22Z

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
INFO