de7bc344142a9c5ec6241153c8812ec0dc419fb2
3 \details The driver assumes the existence of a bison-generated parser,
4 referenced by the external function 'yyparse'.
5 It also assumes the existence of a lexer which must be initialized
6 before parsing, referenced by the external function 'lexer_init'
7 which assumes standard error handling.
8 All input arguments are made available through the exposed (that is,
9 non-static) array of character pointers 'cargs', which point
10 to the non-duplicated strings in 'argv' directly from the system.
11 \author Jordan Lavatai
13 ----------------------------------------------------------------------------*/
15 #include <stdio.h> //print
16 #include <errno.h> //errors
17 #include <string.h> //strnlen
19 #include <stdlib.h> //exit
20 #include <unistd.h> //getopt
22 #include <apc/parser.tab.h> //bison
24 const char* cargs
['Z'] = {0};
26 int main(int, char*[]);
33 extern //apc/parser.tab.c
38 /* Main entry from terminal
39 parses the command line and kicks off recursive scanning
45 #define $($)#$ //stringifier
47 #define MAXERR "-%c allows at most " $(MAXSTR) " input characters\n", opt
48 #define USAGE "Usage: %s [-r root]\n", argv[0]
53 switch (opt
= getopt(argc
, argv
, "r:o:"))
58 if (strnlen(optarg
, MAXSTR
) != MAXSTR
)
59 { cargs
[opt
] = optarg
;
62 fprintf(stderr
, MAXERR
);
64 fprintf(stderr
, USAGE
);