~ecs/wersh

wersh/wersh.awk -rwxr-xr-x 332 bytes
b5d8cd01Eyal Sawady Miscellaneous fixes 2 months 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;
		}
	}
}