updated to allow -tc and -debug
This commit is contained in:
4
Makefile
4
Makefile
@ -37,7 +37,7 @@ debug: clean compiler
|
||||
test:
|
||||
chmod +x ./check.sh
|
||||
chmod +x ./test.sh
|
||||
$(foreach test, $(TESTS-S1), (./$(EXE) -tok $(test) -debug || true);)
|
||||
$(foreach test, $(TESTS-S1), (./$(EXE) -tok -debug $(test) || true);)
|
||||
./test.sh sp2
|
||||
./test.sh sp3
|
||||
./test.sh sp4
|
||||
@ -46,7 +46,7 @@ test:
|
||||
test-s1:
|
||||
chmod +x ./check.sh
|
||||
chmod +x ./test.sh
|
||||
$(foreach test, $(TESTS-S1), (./$(EXE) -tok $(test) -debug || true);)
|
||||
$(foreach test, $(TESTS-S1), (./$(EXE) -tok -debug $(test) || true);)
|
||||
./check.sh sp1
|
||||
|
||||
test-s2:
|
||||
|
29
src/runner.c
29
src/runner.c
@ -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
|
||||
}
|
||||
}
|
||||
|
20
test.sh
20
test.sh
@ -48,7 +48,7 @@ if [ $# -eq 0 ]; then
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename -- "$file")
|
||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||
./alpha -st "$file" -debug
|
||||
./alpha -st -debug "$file"
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||
switchfunc
|
||||
fi
|
||||
@ -60,7 +60,7 @@ if [ $# -eq 0 ]; then
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename -- "$file")
|
||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||
./alpha -st "$file" -debug
|
||||
./alpha -st -debug "$file"
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||
switchfunc
|
||||
fi
|
||||
@ -72,7 +72,7 @@ if [ $# -eq 0 ]; then
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename -- "$file")
|
||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||
./alpha -st "$file" -debug
|
||||
./alpha -st -debug "$file"
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||
switchfunc
|
||||
fi
|
||||
@ -84,7 +84,7 @@ if [ $# -eq 0 ]; then
|
||||
if [ -f "$file" ]; then
|
||||
filename=$(basename -- "$file")
|
||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||
./alpha -st "$file" -debug
|
||||
./alpha -st -debug "$file"
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n${WHITE}"
|
||||
switchfunc
|
||||
fi
|
||||
@ -106,7 +106,7 @@ else
|
||||
if [ -f "$1" ]; then
|
||||
filename=$(basename -- "$1")
|
||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||
./alpha -st "$1" -debug
|
||||
./alpha -st -debug "$1"
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}"
|
||||
exit 1
|
||||
else
|
||||
@ -121,7 +121,7 @@ else
|
||||
if [[ "$file" == *"$1"* ]]; then
|
||||
filename=$(basename -- "$file")
|
||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||
./alpha -st "$file" -debug
|
||||
./alpha -st -debug "$file"
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||
switchfunc
|
||||
fi
|
||||
@ -132,7 +132,7 @@ else
|
||||
if [[ "$file" == *"$1"* ]]; then
|
||||
filename=$(basename -- "$file")
|
||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||
./alpha -st "$file" -debug
|
||||
./alpha -st -debug "$file"
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||
switchfunc
|
||||
fi
|
||||
@ -143,7 +143,7 @@ else
|
||||
if [[ "$file" == *"$1"* ]]; then
|
||||
filename=$(basename -- "$file")
|
||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||
./alpha -st "$file" -debug
|
||||
./alpha -st -debug "$file"
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||
switchfunc
|
||||
fi
|
||||
@ -154,7 +154,7 @@ else
|
||||
if [[ "$file" == *"$1"* ]]; then
|
||||
filename=$(basename -- "$file")
|
||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
||||
./alpha -st "$file" -debug
|
||||
./alpha -st -debug "$file"
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||
switchfunc
|
||||
fi
|
||||
@ -163,4 +163,4 @@ else
|
||||
echo -e "${RED}[ERROR] ${YELLOW}Invalid prefix $1!${WHITE}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
Reference in New Issue
Block a user