gen-exercises.awk 669 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
BEGIN {
    in_solution = 0;
}
{ # on every line of the input
    if (match($0, /^( *)\(\* *BEGIN SOLUTION *\*\)$/, groups)) {
        in_solution = 1
    } else if (match($0, /^( *)\(\* *END SOLUTION *\*\)$/, groups)) {
        print groups[1] "  (* exercise *)"
        print groups[1] "Admitted."
        in_solution = 0
    } else if (match($0, /^( *)\(\* *END SOLUTION BEGIN TEMPLATE *$/, groups)) {
        in_solution = 0
    } else if (match($0, /^( *)END TEMPLATE *\*\)$/, groups)) {
        # Nothing to do, just do not print this line.
    } else if (in_solution == 0) {
        gsub("From solutions Require", "From exercises Require")
        print
    }
}