1 rizwank 1.1 /*
2 * Describe all known highlight languages.
3 */
4
5 state describe_me
6 {
7 / \*$/ {
8 }
9
10 / \*\\\/.*/ {
11 print ("\n");
12 /* All done. */
13 return;
14 }
15
16 / \* ?(.*)/ {
17 print ($1);
18 }
19 }
20
21 state describe_languages
22 rizwank 1.1 {
23 /^\/\*\*.*$/ {
24 call (describe_me);
25 }
26 /[^\\\/]+/ {
27 /* NOP */
28 }
29 /./ {
30 /* NOP */
31 }
32 }
33
34 /*
35 * Create a HTML report of all supported highlighting rules.
36 */
37
38 sub html_annotate_mailtos (str)
39 {
40 return regsuball (str, /[-_a-zA-Z0-9\\.]+@[-_a-zA-Z0-9\\.]+/,
41 "<a href=\"mailto:$0\">$0</a>");
42 }
43 rizwank 1.1
44 sub html_quote (str)
45 {
46 str = regsuball (str, /\&/, "&");
47 str = regsuball (str, /</, "<");
48 str = regsuball (str, />/, ">");
49 str = regsuball (str, /\"/, """);
50 return str;
51 }
52
53 sub describe_me_html_print_pending_name ()
54 {
55 if (!language_name_pending)
56 return;
57
58 print ("<p>\n<dl compact>\n<dt><b>Name:</b><dd>",
59 html_quote (language_name), "\n");
60
61 language_name_pending = 0;
62 }
63
64 rizwank 1.1 state describe_me_html
65 {
66 / \*$/ {
67 }
68
69 / \*\\\/.*/ {
70 /* Terminate this state. */
71 describe_me_html_print_pending_name ();
72 print ("</dl>\n");
73 return;
74 }
75
76 / \* ?(.*)/ {
77 row = $1;
78 if (regmatch (row, /Name:(.*)/))
79 {
80 language_name = $1;
81 language_name_pending = 1;
82 }
83 else if (regmatch (row, /Description:(.*)/))
84 {
85 rizwank 1.1 /* This starts the new language. */
86 title = $1;
87 title = regsub (title, /^[ \t]+/, "");
88 title = regsub (title, /[ \t\\.]+$/, "");
89 print ("<p><li><b>", html_quote (title), "</b><p>\n");
90 }
91 else if (regmatch (row, /([a-zA-Z]+:)(.*)/))
92 {
93 describe_me_html_print_pending_name ();
94 print ("<dt><b>", html_quote ($1), "</b><dd>",
95 html_annotate_mailtos (html_quote ($2)));
96 }
97 else
98 print (html_annotate_mailtos (html_quote (row)));
99 }
100 }
101
102 current_input_file = 0;
103
104 state describe_languages_html
105 {
106 rizwank 1.1 BEGIN {
107 if (current_input_file == 0)
108 {
109 title = "Enscript Highlighting Languages And File Formats";
110 print ("<!DOCTYPE html PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n",
111 "<html>\n<head>\n<title>", title, "</title>\n",
112 "<LINK REV=\"made\" HREF=\"mailto:mtr@iki.fi\">\n",
113 "</head>\n",
114 "<body BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\" LINK=\"#1F00FF\"",
115 "ALINK=\"#FF0000\" VLINK=\"#9900DD\">\n",
116 "<h1>", title, "</h1>\n<hr>\n<ul>\n");
117 }
118 current_input_file++;
119 }
120
121 END {
122 if (current_input_file == length (argv))
123 print ("\n</ul>\n<hr><address>By ", version,
124 "</address>\n</body>\n</html>\n");
125 }
126
127 rizwank 1.1 /^\/\*\*.*$/ {
128 call (describe_me_html);
129 }
130
131 /[^\\\/]+/ {
132 /* NOP */
133 }
134
135 /./ {
136 /* NOP */
137 }
138 }
139
140
141 /*
142 Local variables:
143 mode: c
144 End:
145 */
|