updated to allow -tc and -debug

This commit is contained in:
Annie
2025-04-04 18:43:53 -04:00
parent 1c805cbe3f
commit e566069418
3 changed files with 35 additions and 18 deletions

View File

@ -6,10 +6,10 @@
int main(int argc, char *argv[]) {
// if last argument is debug then set to true and ignore it for the rest
// of this file
if (argc > 1 && strcmp(argv[argc - 1], "-debug") == 0) {
DEBUG = true;
argc--;
}
//if (argc > 1 && strcmp(argv[argc - 1], "-debug") == 0) {
// DEBUG = true;
// argc--;
// }
if (argc == 1) {
fprintf(stderr, INVALID);
@ -61,6 +61,14 @@ int check_flag(char *arg, char *alpha) {
}
fprintf(stderr, "FLAGS REPEAT\n");
return -1;
} else if (strcmp("-tc", arg) == 0) {
if (tc_flag == NULL) {
return new_file(arg, alpha);
}
} else if (strcmp("-debug", arg) == 0) {
DEBUG = true;
return 0;
} else {
fprintf(stderr, "INVALID FLAG: Use -help for valid inputs\n");
return -1;
@ -151,6 +159,10 @@ int run(FILE *alpha) {
return 0;
}
if (tc_flag != NULL) {
//SCARLETT NEEDS TO ADD THIS FUNCTIONALITY
}
yyparse();
FILE *f = fdopen(1, "w");
@ -194,7 +206,9 @@ int new_file(char *arg, char *alpha) {
type_len = TOK_LEN;
} else if (strcmp(arg, "-st") == 0) {
type_len = ST_LEN;
} else {
} else if (strcmp(arg, "-tc") == 0){
type_len = TC_LEN;
}else {
fprintf(stderr,
"INVALID FLAG: Use -help to view valid inputs\n");
return -1;
@ -214,6 +228,9 @@ int new_file(char *arg, char *alpha) {
tok_flag = fopen(file_name, "w");
} else if (strcmp(arg, "-st") == 0) {
st_flag = fopen(file_name, "w");
} else if (strcmp(arg, "-tc") == 0) {
tc_flag = fopen(file_name, "w");
}
return 0;
}
@ -224,4 +241,4 @@ int is_alpha_file(char *alpha, int file_len) {
return -1; // not alpha file
}
return 0; // is alpha file
}
}