| 45 | #include "libtoken.h" |
| 46 | |
| 47 | int main(int argc, char *argv[]) |
| 48 | { |
| 49 | extern char *optarg; |
| 50 | extern int opterr; |
| 51 | extern int optind; |
| 52 | int option; |
| 53 | char const *opt_str = "1acdhl:o:rvw"; |
| 54 | char usage_str[80]; |
| 55 | |
| 56 | const char *token; |
| 57 | enum TokenClass type; |
| 58 | unsigned line; |
| 59 | unsigned col; |
| 60 | unsigned pos; |
| 61 | unsigned token_len; |
| 62 | unsigned num_files = 0; // number of files read |
| 63 | int continuous_files = 0; // when 1 do not reset after each file |
| 64 | |
| 65 | char *outfile = 0; |
| 66 | Language source; |
| 67 | int explicit_source = 0; |
| 68 | int append = 0; |
| 69 | |
| 70 | comment_token = 1; |
| 71 | whitespace_token = 1; |
| 72 | |
| 73 | sprintf(usage_str, "usage: %%s [ -%s ] [ FILES ]\n", opt_str); |
| 74 | |
| 75 | /* Process arguments: */ |
| 76 | while ((option = getopt(argc, argv, opt_str)) != EOF) { |
| 77 | switch (option) { |
| 78 | |
| 79 | case '1': |
| 80 | continuous_files = 1; |
| 81 | break; |
| 82 | |
| 83 | case 'a': |
| 84 | append = 1; |
| 85 | break; |
| 86 | |
| 87 | case 'c': |
| 88 | hash_as_comment = 1; |
| 89 | break; |
| 90 | |
| 91 | case 'd': |
| 92 | debug = verbose = 1; |
| 93 | break; |
| 94 | |
| 95 | case 'h': |
| 96 | fputs( |
| 97 | "A tokenizer for C/C++ (and Java) source code with output in XML.\n" |
| 98 | "Recognizes the following token classes: keyword, identifier, integer,\n" |
| 99 | "floating, string, character, operator, preprocessor, line_comment,\n" |
| 100 | "and block_comment.\n\n", stderr); |
| 101 | fprintf(stderr, usage_str, basename(argv[0])); |
| 102 | fputs( |
| 103 | "\nCommand line options are:\n" |
| 104 | "-a : append to output file instead of create or overwrite.\n" |
nothing calls this directly
no test coverage detected