Take output filenames as arguments instead of hard-coding them.
This commit is contained in:
parent
4a7bbcb48c
commit
84521c078e
|
@ -40,32 +40,37 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
grammar *g;
|
grammar *g;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *filename;
|
char *filename, *graminit_h, *graminit_c;
|
||||||
|
|
||||||
#ifdef THINK_C
|
#ifdef THINK_C
|
||||||
filename = askfile();
|
filename = askfile();
|
||||||
|
graminit_h = askfile();
|
||||||
|
graminit_c = askfile();
|
||||||
#else
|
#else
|
||||||
if (argc != 2) {
|
if (argc != 4) {
|
||||||
fprintf(stderr, "usage: %s grammar\n", argv[0]);
|
fprintf(stderr,
|
||||||
|
"usage: %s grammar graminit.h graminit.c\n", argv[0]);
|
||||||
Py_Exit(2);
|
Py_Exit(2);
|
||||||
}
|
}
|
||||||
filename = argv[1];
|
filename = argv[1];
|
||||||
|
graminit_h = argv[2];
|
||||||
|
graminit_c = argv[3];
|
||||||
#endif
|
#endif
|
||||||
g = getgrammar(filename);
|
g = getgrammar(filename);
|
||||||
fp = fopen("graminit.c", "w");
|
fp = fopen(graminit_c, "w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
perror("graminit.c");
|
perror(graminit_c);
|
||||||
Py_Exit(1);
|
Py_Exit(1);
|
||||||
}
|
}
|
||||||
printf("Writing graminit.c ...\n");
|
printf("Writing %s ...\n", graminit_c);
|
||||||
printgrammar(g, fp);
|
printgrammar(g, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
fp = fopen("graminit.h", "w");
|
fp = fopen(graminit_h, "w");
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
perror("graminit.h");
|
perror(graminit_h);
|
||||||
Py_Exit(1);
|
Py_Exit(1);
|
||||||
}
|
}
|
||||||
printf("Writing graminit.h ...\n");
|
printf("Writing %s ...\n", graminit_h);
|
||||||
printnonterminals(g, fp);
|
printnonterminals(g, fp);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
Py_Exit(0);
|
Py_Exit(0);
|
||||||
|
|
Loading…
Reference in New Issue