blob: eedaee37486f772eb174b729446a105b0409518b (
plain) (
blame)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
#include <cstdio>
#include "lexcer.h"
int main(int argc, char *argv[]) {
if (argc != 2) {
printf("Usage: %s <*.{c,h} file>\n", argv[0]);
return 1; /* wrong usage */
}
auto fpIn = fopen(argv[1], "r");
if (!fpIn) {
return 2; /* unable to open file or inavlid file */
}
auto outputName = LexCer::getOutputFileName(argv[1]);
auto fpOut = fopen(outputName.c_str(), "w");
if (!fpOut) {
return 2;
}
fputs(
"<!doctype>\n"
"<html>\n"
"<head>\n"
" <title>LexCed</title>\n"
" <style>\n"
" .keyword {\n"
" color: purple;\n"
" }\n"
" .number {\n"
" color: darkblue;\n"
" }\n"
" .string {\n"
" color: green;\n"
" }\n"
" .operator {\n"
" font-style: bold;\n"
" }\n"
" .invalid {\n"
" text-decoration: underline;\n"
" text-decoration-color: red;\n"
" text-decoration-style: wavy;\n"
" }\n"
" .typename {\n"
" color: blue;\n"
" }\n"
" .preproc {\n"
" color: purple;\n"
" }\n"
" .identifier {\n"
" color: black;\n"
" }\n"
" .string {\n"
" color: brown;\n"
" }\n"
" .comment {\n"
" color: green;\n"
" }\n"
" </style>\n"
"</head>\n"
"<body>\n"
"<pre class=\"code\">\n",
fpOut
);
LexCer::lexCit(fpIn, fpOut);
fputs("</pre></body></html>\n", fpOut);
printf("Highlighted text written in %s!\n", outputName.c_str());
return 0;
}
|