-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathgen-exercises.awk
More file actions
27 lines (26 loc) · 978 Bytes
/
Copy pathgen-exercises.awk
File metadata and controls
27 lines (26 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
BEGIN {
in_solution = 0; # for the advanced solution syntax
in_auto_solution = 0; # for the simple solution syntax that recognizes `Qed.`
}
{ # on every line of the input
# Capture leading whitespace into 's' to replace groups[1]
match($0, /^[ ]*/)
s = substr($0, 1, RLENGTH)
if ($0 ~ /^[ ]*\(\* *SOLUTION *\*\) *Proof.$/) {
print s "Proof."
in_auto_solution = 1
} else if (in_auto_solution == 1 && $0 ~ /^[ ]*Qed.$/) {
print s " (* exercise *)"
print s "Admitted."
in_auto_solution = 0
} else if ($0 ~ /^[ ]*\(\* *BEGIN SOLUTION *\*\)$/) {
in_solution = 1
} else if ($0 ~ /^[ ]*\(\* *END SOLUTION BEGIN TEMPLATE/) {
in_solution = 0
} else if ($0 ~ /^[ ]*END TEMPLATE *\*\)$/) {
# Nothing to do, just do not print this line.
} else if (in_solution == 0 && in_auto_solution == 0) {
gsub("From solutions Require", "From exercises Require")
print
}
}