Merge pull request #42 from UB-CSE443/Sprint3-TC_Flag-t#NoTask
Sprint3 tc flag t#no task
This commit is contained in:
4
Makefile
4
Makefile
@ -37,7 +37,7 @@ debug: clean compiler
|
|||||||
test:
|
test:
|
||||||
chmod +x ./check.sh
|
chmod +x ./check.sh
|
||||||
chmod +x ./test.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 sp2
|
||||||
./test.sh sp3
|
./test.sh sp3
|
||||||
./test.sh sp4
|
./test.sh sp4
|
||||||
@ -46,7 +46,7 @@ test:
|
|||||||
test-s1:
|
test-s1:
|
||||||
chmod +x ./check.sh
|
chmod +x ./check.sh
|
||||||
chmod +x ./test.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
|
./check.sh sp1
|
||||||
|
|
||||||
test-s2:
|
test-s2:
|
||||||
|
27
src/runner.c
27
src/runner.c
@ -6,10 +6,10 @@
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
// if last argument is debug then set to true and ignore it for the rest
|
// if last argument is debug then set to true and ignore it for the rest
|
||||||
// of this file
|
// of this file
|
||||||
if (argc > 1 && strcmp(argv[argc - 1], "-debug") == 0) {
|
//if (argc > 1 && strcmp(argv[argc - 1], "-debug") == 0) {
|
||||||
DEBUG = true;
|
// DEBUG = true;
|
||||||
argc--;
|
// argc--;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
fprintf(stderr, INVALID);
|
fprintf(stderr, INVALID);
|
||||||
@ -61,6 +61,14 @@ int check_flag(char *arg, char *alpha) {
|
|||||||
}
|
}
|
||||||
fprintf(stderr, "FLAGS REPEAT\n");
|
fprintf(stderr, "FLAGS REPEAT\n");
|
||||||
return -1;
|
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 {
|
} else {
|
||||||
fprintf(stderr, "INVALID FLAG: Use -help for valid inputs\n");
|
fprintf(stderr, "INVALID FLAG: Use -help for valid inputs\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -151,6 +159,10 @@ int run(FILE *alpha) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tc_flag != NULL) {
|
||||||
|
//SCARLETT NEEDS TO ADD THIS FUNCTIONALITY
|
||||||
|
}
|
||||||
|
|
||||||
yyparse();
|
yyparse();
|
||||||
FILE *f = fdopen(1, "w");
|
FILE *f = fdopen(1, "w");
|
||||||
|
|
||||||
@ -194,7 +206,9 @@ int new_file(char *arg, char *alpha) {
|
|||||||
type_len = TOK_LEN;
|
type_len = TOK_LEN;
|
||||||
} else if (strcmp(arg, "-st") == 0) {
|
} else if (strcmp(arg, "-st") == 0) {
|
||||||
type_len = ST_LEN;
|
type_len = ST_LEN;
|
||||||
} else {
|
} else if (strcmp(arg, "-tc") == 0){
|
||||||
|
type_len = TC_LEN;
|
||||||
|
}else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"INVALID FLAG: Use -help to view valid inputs\n");
|
"INVALID FLAG: Use -help to view valid inputs\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -214,6 +228,9 @@ int new_file(char *arg, char *alpha) {
|
|||||||
tok_flag = fopen(file_name, "w");
|
tok_flag = fopen(file_name, "w");
|
||||||
} else if (strcmp(arg, "-st") == 0) {
|
} else if (strcmp(arg, "-st") == 0) {
|
||||||
st_flag = fopen(file_name, "w");
|
st_flag = fopen(file_name, "w");
|
||||||
|
|
||||||
|
} else if (strcmp(arg, "-tc") == 0) {
|
||||||
|
tc_flag = fopen(file_name, "w");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define ALPHA_OFFSET 6
|
#define ALPHA_OFFSET 6
|
||||||
#define TOK_LEN 3
|
#define TOK_LEN 3
|
||||||
#define ST_LEN 2
|
#define ST_LEN 2
|
||||||
|
#define TC_LEN 2
|
||||||
#define HELP \
|
#define HELP \
|
||||||
"HELP:\nHow to run the alpha compiler:\n./alpha [options] " \
|
"HELP:\nHow to run the alpha compiler:\n./alpha [options] " \
|
||||||
"program\nValid " \
|
"program\nValid " \
|
||||||
@ -13,7 +14,8 @@
|
|||||||
"symbol " \
|
"symbol " \
|
||||||
"table for the program to the .st file\n-help print this message " \
|
"table for the program to the .st file\n-help print this message " \
|
||||||
"and exit " \
|
"and exit " \
|
||||||
"the alpha compiler\n"
|
"the alpha compiler\n-debug print debugging messages in grammar rules \n"
|
||||||
|
|
||||||
#define SET_FLAG 1 // Used to set flags for arg types
|
#define SET_FLAG 1 // Used to set flags for arg types
|
||||||
#define INVALID \
|
#define INVALID \
|
||||||
"INVALID INPUT: Include a .alpha file or use -help for more inputs \n"
|
"INVALID INPUT: Include a .alpha file or use -help for more inputs \n"
|
||||||
@ -39,6 +41,7 @@ SymbolTable *cur;
|
|||||||
FILE *alpha_file;
|
FILE *alpha_file;
|
||||||
FILE *tok_flag = NULL;
|
FILE *tok_flag = NULL;
|
||||||
FILE *st_flag = NULL;
|
FILE *st_flag = NULL;
|
||||||
|
FILE *tc_flag = NULL;
|
||||||
bool DEBUG = false;
|
bool DEBUG = false;
|
||||||
int no_flag = 0;
|
int no_flag = 0;
|
||||||
int arg;
|
int arg;
|
||||||
|
18
test.sh
18
test.sh
@ -48,7 +48,7 @@ if [ $# -eq 0 ]; then
|
|||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
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"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
@ -60,7 +60,7 @@ if [ $# -eq 0 ]; then
|
|||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
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"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
@ -72,7 +72,7 @@ if [ $# -eq 0 ]; then
|
|||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
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"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
@ -84,7 +84,7 @@ if [ $# -eq 0 ]; then
|
|||||||
if [ -f "$file" ]; then
|
if [ -f "$file" ]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
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}"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n${WHITE}"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
@ -106,7 +106,7 @@ else
|
|||||||
if [ -f "$1" ]; then
|
if [ -f "$1" ]; then
|
||||||
filename=$(basename -- "$1")
|
filename=$(basename -- "$1")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
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}"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
@ -121,7 +121,7 @@ else
|
|||||||
if [[ "$file" == *"$1"* ]]; then
|
if [[ "$file" == *"$1"* ]]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
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"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
@ -132,7 +132,7 @@ else
|
|||||||
if [[ "$file" == *"$1"* ]]; then
|
if [[ "$file" == *"$1"* ]]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
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"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
@ -143,7 +143,7 @@ else
|
|||||||
if [[ "$file" == *"$1"* ]]; then
|
if [[ "$file" == *"$1"* ]]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
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"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
@ -154,7 +154,7 @@ else
|
|||||||
if [[ "$file" == *"$1"* ]]; then
|
if [[ "$file" == *"$1"* ]]; then
|
||||||
filename=$(basename -- "$file")
|
filename=$(basename -- "$file")
|
||||||
echo -e "- ${SWITCH}Running test: ${LIGHTBLUE}$filename ${SWITCH}-----${WHITE}"
|
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"
|
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||||
switchfunc
|
switchfunc
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user