| 798 | } |
| 799 | |
| 800 | int main(int argc, char *argv[]) |
| 801 | { |
| 802 | extern char *optarg; |
| 803 | extern int opterr; |
| 804 | extern int optind; |
| 805 | int option; |
| 806 | char const *opt_str = "1dhlm:o:svw"; |
| 807 | char usage_str[80]; |
| 808 | |
| 809 | char token[MAX_TOKEN+1]; |
| 810 | const char *type; |
| 811 | unsigned line; |
| 812 | unsigned col; |
| 813 | |
| 814 | char *outfile = 0; |
| 815 | |
| 816 | sprintf(usage_str, "usage: %%s [ -%s ] [ FILES ]\n", opt_str); |
| 817 | |
| 818 | /* Process arguments: */ |
| 819 | while ((option = getopt(argc, argv, opt_str)) != EOF) { |
| 820 | switch (option) { |
| 821 | |
| 822 | case '1': |
| 823 | continuous_files = 1; |
| 824 | break; |
| 825 | |
| 826 | case 'd': |
| 827 | debug = verbose = 1; |
| 828 | break; |
| 829 | |
| 830 | case 'h': |
| 831 | fputs( |
| 832 | "A tokenizer for Python (3) source code with output in 6 formats.\n" |
| 833 | "Recognizes the following token classes: keyword, identifier, integer,\n" |
| 834 | "floating, imaginary, string, and operator.\n\n", stderr); |
| 835 | fprintf(stderr, usage_str, basename(argv[0])); |
| 836 | fputs( |
| 837 | "\nCommand line options are:\n" |
| 838 | "-d : print debug info to stderr; implies -v.\n" |
| 839 | "-h : print just this text to stderr and stop.\n" |
| 840 | "-l : output layout pseudo tokens (default don't).\n" |
| 841 | "-m<mode> : output mode either plain (default), csv, json, jsonl, xml, or raw.\n" |
| 842 | "-o<file> : name for output file (instead of stdout).\n" |
| 843 | "-s : enable a special start token specifying the filename.\n" |
| 844 | "-1 : treat all filename arguments as a continuous single input.\n" |
| 845 | "-v : print action summary to stderr.\n" |
| 846 | "-w : suppress all warning messages.\n", |
| 847 | stderr); |
| 848 | return 0; |
| 849 | |
| 850 | case 'l': |
| 851 | output_layout = 1; |
| 852 | break; |
| 853 | |
| 854 | case 'm': |
| 855 | if (!strcmp(optarg, "plain")) |
| 856 | mode = PLAIN; |
| 857 | else if (!strcmp(optarg, "csv")) |
nothing calls this directly
no test coverage detected