5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 * of the Software, and to permit persons to whom the Software is furnished to do
10 * so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 static const char *output = "progs.dat";
26 static const char *input = NULL;
28 #define OptReq(opt, body) \
30 if (argv[0][2]) argarg = argv[0]+2; \
33 printf("option -%c requires an argument\n", opt); \
40 do { body } while (0); \
43 #define LongReq(opt, body) \
44 if (!strcmp(argv[0], opt)) { \
46 printf("option " opt " requires an argument\n"); \
52 do { body } while (0); \
54 } else if (!strncmp(argv[0], opt "=", sizeof(opt "="))) \
56 argarg = argv[0] + sizeof(opt "="); \
57 do { body } while (0); \
61 bool parser_compile(const char *filename, const char *datfile);
62 int main(int argc, char **argv) {
66 util_debug("COM", "starting ...\n");
71 if (argv[0][0] == '-') {
75 OptReq('o', output = argarg; );
77 LongReq("--output", output = argarg; );
79 printf("Unrecognized option: %s\n", argv[0]);
86 printf("Onlyh 1 input file allowed\n");
96 printf("must specify an input file\n");
99 if (!parser_compile(input, output)) {
100 printf("There were compile errors\n");
103 util_debug("COM", "cleaning ...\n");