added:
[external/ragel.git] / doc / extract.awk
1 #!/usr/bin/awk
2 #
3
4 BEGIN {
5         in_generate = 0;
6         in_verbatim = 0;
7         return_val = 1;
8 }
9
10 /^% GENERATE: *[a-z0-9A-Z_\.\-]+ *$/ && $3 == exname {
11         in_generate = 1;
12         return_val = 0;
13         next;
14 }
15
16 /^% END GENERATE$/ {
17         in_generate = 0;
18         next;
19 }
20
21 in_generate && /\\begin\{verbatim\}/ {
22         in_generate = 0;
23         in_verbatim = 1;
24         next;
25 }
26
27 in_verbatim && /\\end\{verbatim\}/ {
28         in_generate = 1;
29         in_verbatim = 0;
30         next;
31 }
32
33 in_generate && /^%/ {
34         print substr( $0, 2 );
35 }
36
37 in_verbatim {
38         print $0;
39 }
40
41 END { exit return_val; }