~sircmpwn/wersh

wersh/wersh.awk -rwxr-xr-x 437 bytes
0d248590Drew DeVault Add wersh-watch 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/awk -f
BEGIN { mode="line" }
{
    if (mode == "line") {
        if ($0 ~ /^%%%$/) {
            mode="block";
        } else if ($0 ~ /^%.*$/) {
            print substr($0, 3);
        } else {
            gsub(/'/, "'\"'\"'", $0);
            print "emit '" $emit "'";
        }
    } else if (mode == "block") {
        if ($0 ~ /^%%%$/) {
            mode="line";
        } else {
            print $0;
        }
    }
}