diff options
author | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2001-02-16 03:57:53 (GMT) |
---|---|---|
committer | Neil Schemenauer <nascheme@enme.ucalgary.ca> | 2001-02-16 03:57:53 (GMT) |
commit | 84521c078e7809b38daf292a552ba519e0d3c3ac (patch) | |
tree | 5bd7351962b073af0120c34dd2f16d561ff89740 /Parser/pgenmain.c | |
parent | 4a7bbcb48c1fb96fb244f89fb31de5bae7afbeb6 (diff) | |
download | cpython-84521c078e7809b38daf292a552ba519e0d3c3ac.zip cpython-84521c078e7809b38daf292a552ba519e0d3c3ac.tar.gz cpython-84521c078e7809b38daf292a552ba519e0d3c3ac.tar.bz2 |
Take output filenames as arguments instead of hard-coding them.
Diffstat (limited to 'Parser/pgenmain.c')
-rw-r--r-- | Parser/pgenmain.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/Parser/pgenmain.c b/Parser/pgenmain.c index 0c155de..32fb956 100644 --- a/Parser/pgenmain.c +++ b/Parser/pgenmain.c @@ -40,32 +40,37 @@ main(int argc, char **argv) { grammar *g; FILE *fp; - char *filename; + char *filename, *graminit_h, *graminit_c; #ifdef THINK_C filename = askfile(); + graminit_h = askfile(); + graminit_c = askfile(); #else - if (argc != 2) { - fprintf(stderr, "usage: %s grammar\n", argv[0]); + if (argc != 4) { + fprintf(stderr, + "usage: %s grammar graminit.h graminit.c\n", argv[0]); Py_Exit(2); } filename = argv[1]; + graminit_h = argv[2]; + graminit_c = argv[3]; #endif g = getgrammar(filename); - fp = fopen("graminit.c", "w"); + fp = fopen(graminit_c, "w"); if (fp == NULL) { - perror("graminit.c"); + perror(graminit_c); Py_Exit(1); } - printf("Writing graminit.c ...\n"); + printf("Writing %s ...\n", graminit_c); printgrammar(g, fp); fclose(fp); - fp = fopen("graminit.h", "w"); + fp = fopen(graminit_h, "w"); if (fp == NULL) { - perror("graminit.h"); + perror(graminit_h); Py_Exit(1); } - printf("Writing graminit.h ...\n"); + printf("Writing %s ...\n", graminit_h); printnonterminals(g, fp); fclose(fp); Py_Exit(0); |