Updated
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) || true);)
|
||||
$(foreach test, $(TESTS-S1), (./$(EXE) -tok $(test) -debug || 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) || true);)
|
||||
$(foreach test, $(TESTS-S1), (./$(EXE) -tok $(test) -debug || true);)
|
||||
./check.sh sp1
|
||||
|
||||
test-s2:
|
||||
|
11
src/runner.c
11
src/runner.c
@ -9,8 +9,19 @@ extern TableNode *addr;
|
||||
extern TableNode *chara;
|
||||
extern TableNode *stri;
|
||||
extern TableNode *boo;
|
||||
extern bool DEBUG;
|
||||
extern char * COLOR_YELLOW;
|
||||
extern char * COLOR_BLUE;
|
||||
extern char * COLOR_WHITE;
|
||||
|
||||
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) {
|
||||
fprintf(stderr, INVALID);
|
||||
return -1;
|
||||
|
@ -107,7 +107,8 @@ AdInfo *CreatePrimitiveInfo(int size) {
|
||||
// only gets the size of a primitive type
|
||||
int getPrimSize(TableNode *definition) {
|
||||
if (definition == NULL || definition == undefined) {
|
||||
printf("passed an NULL entry to getPrimSize function. Invalid.\n");
|
||||
printf(
|
||||
"passed an NULL entry to getPrimSize function. Invalid.\n");
|
||||
return -1;
|
||||
}
|
||||
if (definition->additionalinfo == NULL) {
|
||||
@ -135,7 +136,8 @@ int getPrimSize(TableNode *definition) {
|
||||
// calculated at runtime so bounds checking only needs to be done then
|
||||
AdInfo *CreateArrayInfo(int dim, /*int* sizes,*/ TableNode *type) {
|
||||
if (type == NULL || type == undefined) {
|
||||
printf("passed a NULL or undefined type reference to CreateArrayInfo. Invalid.\n");
|
||||
printf("passed a NULL or undefined type reference to "
|
||||
"CreateArrayInfo. Invalid.\n");
|
||||
return NULL;
|
||||
}
|
||||
AdInfo *info = (AdInfo *)malloc(sizeof(AdInfo));
|
||||
@ -149,7 +151,8 @@ AdInfo *CreateArrayInfo(int dim, /*int* sizes,*/ TableNode *type) {
|
||||
// This gets the number of dimensions from array info
|
||||
int getNumArrDim(TableNode *definition) {
|
||||
if (definition == NULL || definition == undefined) {
|
||||
printf("passed an NULL or undefined entry to getNumArrDim function. Invalid.\n");
|
||||
printf("passed an NULL or undefined entry to getNumArrDim "
|
||||
"function. Invalid.\n");
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(getType(definition), "array") != 0) {
|
||||
@ -162,7 +165,8 @@ int getNumArrDim(TableNode *definition) {
|
||||
// the entry of that type
|
||||
TableNode *getArrType(TableNode *definition) {
|
||||
if (definition == NULL || definition == undefined) {
|
||||
printf("passed an NULL or undefined entry to getArrType function. Invalid.\n");
|
||||
printf("passed an NULL or undefined entry to getArrType "
|
||||
"function. Invalid.\n");
|
||||
return NULL;
|
||||
}
|
||||
if (strcmp(getType(definition), "array") != 0) {
|
||||
@ -189,7 +193,8 @@ AdInfo *CreateRecordInfo(int length, SymbolTable *recordScope) {
|
||||
// anyways.
|
||||
int getRecLength(TableNode *definition) {
|
||||
if (definition == NULL || definition == undefined) {
|
||||
printf("passed an NULL or undefined entry to getRecLength function. Invalid.\n");
|
||||
printf("passed an NULL or undefined entry to getRecLength "
|
||||
"function. Invalid.\n");
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(getType(definition), "record") != 0) {
|
||||
@ -201,7 +206,8 @@ int getRecLength(TableNode *definition) {
|
||||
// This gets the array. Needs to up be updated to get the scope instead
|
||||
SymbolTable *getRecList(TableNode *definition) {
|
||||
if (definition == NULL || definition == undefined) {
|
||||
printf("passed an NULL or undefined entry to getRecList function. Invalid.\n");
|
||||
printf("passed an NULL or undefined entry to getRecList "
|
||||
"function. Invalid.\n");
|
||||
return NULL;
|
||||
}
|
||||
if (strcmp(getType(definition), "record") != 0) {
|
||||
@ -255,7 +261,8 @@ AdInfo *CreateFunctionDeclarationInfo(int line, bool asorregular) {
|
||||
// out in table if needed)
|
||||
int getStartLine(TableNode *definition) {
|
||||
if (definition == NULL || definition == undefined) {
|
||||
printf("passed an NULL or undefined entry to getStartLine function. Invalid.\n");
|
||||
printf("passed an NULL or undefined entry to getStartLine "
|
||||
"function. Invalid.\n");
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(getType(definition), "primitive function") != 0) {
|
||||
@ -268,7 +275,8 @@ int getStartLine(TableNode *definition) {
|
||||
|
||||
TableNode *setStartLine(TableNode *tn, int start) {
|
||||
if (tn == NULL || tn == undefined) {
|
||||
printf("passing in a NULL or undefined entry to setStartLine. invalid\n");
|
||||
printf("passing in a NULL or undefined entry to setStartLine. "
|
||||
"invalid\n");
|
||||
return undefined;
|
||||
}
|
||||
tn->additionalinfo->FunDecAdInfo->startlinenumber = start;
|
||||
@ -278,7 +286,8 @@ TableNode* setStartLine(TableNode* tn, int start){
|
||||
// not used or used.
|
||||
bool getAsKeyword(TableNode *definition) {
|
||||
if (definition == NULL || definition == undefined) {
|
||||
printf("passed an NULL or undefined entry to getAsKeyword function. Invalid.\n");
|
||||
printf("passed an NULL or undefined entry to getAsKeyword "
|
||||
"function. Invalid.\n");
|
||||
return false;
|
||||
}
|
||||
if (strcmp(getType(definition), "primitive function") != 0) {
|
||||
@ -291,7 +300,8 @@ bool getAsKeyword(TableNode *definition) {
|
||||
|
||||
TableNode *setAsKeyword(TableNode *tn, bool as) {
|
||||
if (tn == NULL || tn == undefined) {
|
||||
printf("passing in a NULL or undefined entry to setAsKeyword. invalid\n");
|
||||
printf("passing in a NULL or undefined entry to setAsKeyword. "
|
||||
"invalid\n");
|
||||
return undefined;
|
||||
}
|
||||
tn->additionalinfo->FunDecAdInfo->regularoras = as;
|
||||
@ -301,11 +311,13 @@ TableNode* setAsKeyword(TableNode* tn, bool as){
|
||||
// stores the type of a function (parameter type and return type)
|
||||
AdInfo *CreateFunctionTypeInfo(TableNode *parameter, TableNode *returntype) {
|
||||
if (parameter == NULL || parameter == undefined) {
|
||||
printf("passed a NULL or undefined parameter to CreateFunctionTypeInfo. Invalid.\n");
|
||||
printf("passed a NULL or undefined parameter to "
|
||||
"CreateFunctionTypeInfo. Invalid.\n");
|
||||
return NULL;
|
||||
}
|
||||
if (returntype == NULL || returntype == undefined) {
|
||||
printf("passed a NULL or undefined return type to CreateFunctionTypeInfo. Invalid.\n");
|
||||
printf("passed a NULL or undefined return type to "
|
||||
"CreateFunctionTypeInfo. Invalid.\n");
|
||||
return NULL;
|
||||
}
|
||||
AdInfo *info = (AdInfo *)malloc(sizeof(AdInfo));
|
||||
@ -318,7 +330,8 @@ AdInfo *CreateFunctionTypeInfo(TableNode *parameter, TableNode *returntype) {
|
||||
// returns parameter type of a function
|
||||
TableNode *getParameter(TableNode *definition) {
|
||||
if (definition == NULL || definition == undefined) {
|
||||
printf("passed an NULL or undefined entry to getParameter function. Invalid.\n");
|
||||
printf("passed an NULL or undefined entry to getParameter "
|
||||
"function. Invalid.\n");
|
||||
return undefined;
|
||||
}
|
||||
if (strcmp(getType(definition), "primitive function type") != 0) {
|
||||
@ -331,7 +344,8 @@ TableNode *getParameter(TableNode *definition) {
|
||||
// returns return type of a function
|
||||
TableNode *getReturn(TableNode *definition) {
|
||||
if (definition == NULL || definition == undefined) {
|
||||
printf("passed an NULL or undefined entry to getReturn function. Invalid.\n");
|
||||
printf("passed an NULL or undefined entry to getReturn "
|
||||
"function. Invalid.\n");
|
||||
return NULL;
|
||||
}
|
||||
if (strcmp(getType(definition), "primitive function type") != 0) {
|
||||
@ -450,7 +464,8 @@ SymbolTable *init(SymbolTable *start) {
|
||||
undefined->additionalinfo = NULL;
|
||||
undefined->next = NULL;
|
||||
|
||||
//Undefined_function_type_info = CreateFunctionTypeInfo(undefined, undefined);
|
||||
// Undefined_function_type_info = CreateFunctionTypeInfo(undefined,
|
||||
// undefined);
|
||||
|
||||
integ->theType = prime;
|
||||
addr->theType = prime;
|
||||
@ -489,15 +504,18 @@ TableNode* funtypeprime;
|
||||
*/
|
||||
TableNode *populateTypeAndInfo(TableNode *tn, TableNode *type, AdInfo *info) {
|
||||
if (tn == NULL || tn == undefined) {
|
||||
printf("passed in an invalid table node to modify (NULL or undefined).\n");
|
||||
printf("passed in an invalid table node to modify (NULL or "
|
||||
"undefined).\n");
|
||||
return undefined;
|
||||
}
|
||||
if (type == NULL || type == undefined) {
|
||||
printf("passed in a NULL or undefined type reference to populate a table node. Invalid.\n");
|
||||
printf("passed in a NULL or undefined type reference to "
|
||||
"populate a table node. Invalid.\n");
|
||||
return undefined;
|
||||
}
|
||||
if (info == NULL) {
|
||||
printf("passed in a NULL info reference to populate a table node. Invalid.\n");
|
||||
printf("passed in a NULL info reference to populate a table "
|
||||
"node. Invalid.\n");
|
||||
return undefined;
|
||||
}
|
||||
tn->theType = type;
|
||||
@ -512,7 +530,8 @@ int getAdInfoType(TableNode* tn){
|
||||
return -1;
|
||||
}
|
||||
if (tn->theType == NULL || tn->theType == undefined) {
|
||||
printf("Entry being passed in has a null or undefined reference for theType. Invalid.\n");
|
||||
printf("Entry being passed in has a null or undefined "
|
||||
"reference for theType. Invalid.\n");
|
||||
return -1;
|
||||
}
|
||||
if (strcmp(getName(tn), getName(integ)) == 0) {
|
||||
@ -541,13 +560,13 @@ int getAdInfoType(TableNode* tn){
|
||||
}
|
||||
if (strcmp(getName(tn), getName(undefined)) == 0) {
|
||||
return TYPE_UNDEFINED;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
return TYPE_FUNCTION_DECLARATION;
|
||||
}
|
||||
}
|
||||
|
||||
TableNode *CreateEntry(SymbolTable *table, TableNode *typeOf, char *id, AdInfo *ad) {
|
||||
TableNode *CreateEntry(SymbolTable *table, TableNode *typeOf, char *id,
|
||||
AdInfo *ad) {
|
||||
|
||||
if (table == NULL) {
|
||||
printf("Null reference to table");
|
||||
@ -562,7 +581,8 @@ TableNode *CreateEntry(SymbolTable *table, TableNode *typeOf, char *id, AdInfo *
|
||||
}
|
||||
*/
|
||||
if (typeOf == NULL || typeOf == undefined) {
|
||||
printf("This is not pointing to a proper definition (either NULL or undefined)\n");
|
||||
printf("This is not pointing to a proper definition (either "
|
||||
"NULL or undefined)\n");
|
||||
return undefined;
|
||||
}
|
||||
TableNode *newEntry = (TableNode *)calloc(1, sizeof(TableNode));
|
||||
@ -589,11 +609,13 @@ char *getType(TableNode *tn) {
|
||||
printf("type of entry is currently NULL or undefined type \n");
|
||||
return getName(undefined);
|
||||
}
|
||||
return tn->theType->theName; }
|
||||
return tn->theType->theName;
|
||||
}
|
||||
|
||||
char *getName(TableNode *tn) {
|
||||
if (tn == NULL || tn == undefined) {
|
||||
//printf("passed a NULL or undefined table entry to getName\n");
|
||||
// printf("passed a NULL or undefined table entry to
|
||||
// getName\n");
|
||||
return undefined->theName;
|
||||
}
|
||||
if (tn->theName == NULL) {
|
||||
@ -605,27 +627,34 @@ char *getName(TableNode *tn) {
|
||||
|
||||
int getLine(SymbolTable *st) {
|
||||
if (st == NULL) {
|
||||
printf("passed a NULL symbol table to getLine function. Invalid.\n");
|
||||
printf("passed a NULL symbol table to getLine function. "
|
||||
"Invalid.\n");
|
||||
return -1;
|
||||
}
|
||||
return st->Line_Number; }
|
||||
return st->Line_Number;
|
||||
}
|
||||
int getColumn(SymbolTable *st) {
|
||||
if (st == NULL) {
|
||||
printf("passed a NULL symbol table to getColumn function. Invalid.\n");
|
||||
printf("passed a NULL symbol table to getColumn function. "
|
||||
"Invalid.\n");
|
||||
return -1;
|
||||
}
|
||||
return st->Column_Number; }
|
||||
return st->Column_Number;
|
||||
}
|
||||
TableNode *addName(TableNode *tn, char *str) {
|
||||
if (tn == NULL || tn == undefined) {
|
||||
printf("passed a Null or undefined table node to the addName function. Invalid./n");
|
||||
printf("passed a Null or undefined table node to the addName "
|
||||
"function. Invalid./n");
|
||||
return undefined;
|
||||
}
|
||||
if (tn->theName != NULL) {
|
||||
printf("Name doesn't look like it is empty before you change. Are you sure you need to update name?/n");
|
||||
printf("Name doesn't look like it is empty before you change. "
|
||||
"Are you sure you need to update name?/n");
|
||||
return undefined;
|
||||
}
|
||||
if (str == NULL) {
|
||||
printf("passed a NULL string to the addName function. Invalid./n");
|
||||
printf(
|
||||
"passed a NULL string to the addName function. Invalid./n");
|
||||
return undefined;
|
||||
}
|
||||
tn->theName = str;
|
||||
@ -634,7 +663,8 @@ TableNode* addName(TableNode *tn, char* str){
|
||||
|
||||
SymbolTable *setLineNumber(SymbolTable *st, int line) {
|
||||
if (st == NULL) {
|
||||
printf("passed a Null Symbol Table to the setLineNumber function. Invalid./n");
|
||||
printf("passed a Null Symbol Table to the setLineNumber "
|
||||
"function. Invalid./n");
|
||||
return st;
|
||||
}
|
||||
st->Line_Number = line;
|
||||
@ -643,7 +673,8 @@ SymbolTable* setLineNumber(SymbolTable *st,int line){
|
||||
|
||||
SymbolTable *setColumnNumber(SymbolTable *st, int column) {
|
||||
if (st == NULL) {
|
||||
printf("passed a Null Symbol Table to the setColumnNumber function. Invalid./n");
|
||||
printf("passed a Null Symbol Table to the setColumnNumber "
|
||||
"function. Invalid./n");
|
||||
return st;
|
||||
}
|
||||
st->Line_Number = column;
|
||||
@ -708,8 +739,9 @@ TableNode *look_up(SymbolTable *table, char *x) {
|
||||
if (ret != NULL && ret != undefined) {
|
||||
return ret;
|
||||
}
|
||||
printf("could not find %s in scope that started at line %d and column %d so moving up a scope\n"
|
||||
,x,getLine(table),getColumn(table));
|
||||
printf("could not find %s in scope that started at line %d and column "
|
||||
"%d so moving up a scope\n",
|
||||
x, getLine(table), getColumn(table));
|
||||
return look_up(table->Parent_Scope, x);
|
||||
}
|
||||
/*
|
||||
@ -795,16 +827,24 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
if (parant_scope == 0) {
|
||||
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : : %-21d -> %-21s: %-28s\n",
|
||||
"%-17s: %06d : : %-21d -> "
|
||||
"%-21s: %-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
entrie->additionalinfo->ArrayAdInfo->numofdimensions,
|
||||
entrie->additionalinfo->ArrayAdInfo->typeofarray->theName,
|
||||
entrie->additionalinfo->ArrayAdInfo
|
||||
->numofdimensions,
|
||||
entrie->additionalinfo->ArrayAdInfo
|
||||
->typeofarray->theName,
|
||||
"Type of Array");
|
||||
} else {
|
||||
fprintf(file_ptr, "%-17s: %06d : %06d : %-21d -> %-21s: %-28s\n",
|
||||
entrie->theName, current_scope, parant_scope,
|
||||
entrie->additionalinfo->ArrayAdInfo->numofdimensions,
|
||||
entrie->additionalinfo->ArrayAdInfo->typeofarray->theName,
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : %06d : %-21d -> %-21s: "
|
||||
"%-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
parant_scope,
|
||||
entrie->additionalinfo->ArrayAdInfo
|
||||
->numofdimensions,
|
||||
entrie->additionalinfo->ArrayAdInfo
|
||||
->typeofarray->theName,
|
||||
"Type of Array");
|
||||
}
|
||||
}
|
||||
@ -812,29 +852,38 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
if (parant_scope == 0) {
|
||||
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : :%-21s: elements-%-28d\n",
|
||||
"%-17s: %06d : :%-21s: "
|
||||
"elements-%-28d\n",
|
||||
entrie->theName, current_scope,
|
||||
"record",
|
||||
entrie->additionalinfo->RecAdInfo->numofelements);
|
||||
entrie->additionalinfo->RecAdInfo
|
||||
->numofelements);
|
||||
} else {
|
||||
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: elements-%-28d\n",
|
||||
entrie->theName, current_scope, parant_scope,
|
||||
"record",
|
||||
entrie->additionalinfo->RecAdInfo->numofelements);
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : %06d : %-21s: "
|
||||
"elements-%-28d\n",
|
||||
entrie->theName, current_scope,
|
||||
parant_scope, "record",
|
||||
entrie->additionalinfo->RecAdInfo
|
||||
->numofelements);
|
||||
}
|
||||
}
|
||||
if (getAdInfoType(entrie) == TYPE_PRIMITIVE) {
|
||||
if (parant_scope == 0) {
|
||||
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : :%-21s: size-%-28d bytes\n",
|
||||
entrie->theName, current_scope,
|
||||
"Primitive",
|
||||
fprintf(
|
||||
file_ptr,
|
||||
"%-17s: %06d : :%-21s: size-%-28d "
|
||||
"bytes\n",
|
||||
entrie->theName, current_scope, "Primitive",
|
||||
entrie->additionalinfo->PrimAdInfo->size);
|
||||
} else {
|
||||
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: size-%-28d bytes\n",
|
||||
entrie->theName, current_scope, parant_scope,
|
||||
"Primitive",
|
||||
fprintf(
|
||||
file_ptr,
|
||||
"%-17s: %06d : %06d : %-21s: size-%-28d "
|
||||
"bytes\n",
|
||||
entrie->theName, current_scope,
|
||||
parant_scope, "Primitive",
|
||||
entrie->additionalinfo->PrimAdInfo->size);
|
||||
}
|
||||
}
|
||||
@ -842,16 +891,24 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
if (parant_scope == 0) {
|
||||
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : : %-21s -> %-21s: %-28s\n",
|
||||
"%-17s: %06d : : %-21s -> "
|
||||
"%-21s: %-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
entrie->additionalinfo->FunTypeAdInfo->parameter->theName,
|
||||
entrie->additionalinfo->FunTypeAdInfo->returntype->theName,
|
||||
entrie->additionalinfo->FunTypeAdInfo
|
||||
->parameter->theName,
|
||||
entrie->additionalinfo->FunTypeAdInfo
|
||||
->returntype->theName,
|
||||
"Type of Function");
|
||||
} else {
|
||||
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s -> %-21s: %-28s\n",
|
||||
entrie->theName, current_scope, parant_scope,
|
||||
entrie->additionalinfo->FunTypeAdInfo->parameter->theName,
|
||||
entrie->additionalinfo->FunTypeAdInfo->returntype->theName,
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : %06d : %-21s -> %-21s: "
|
||||
"%-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
parant_scope,
|
||||
entrie->additionalinfo->FunTypeAdInfo
|
||||
->parameter->theName,
|
||||
entrie->additionalinfo->FunTypeAdInfo
|
||||
->returntype->theName,
|
||||
"Type of Function");
|
||||
}
|
||||
}
|
||||
@ -861,12 +918,12 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : :%-21s: %-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
getType(entrie),
|
||||
"Function");
|
||||
getType(entrie), "Function");
|
||||
} else {
|
||||
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: %-28s\n",
|
||||
entrie->theName, current_scope, parant_scope,
|
||||
getType(entrie),
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : %06d : %-21s: %-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
parant_scope, getType(entrie),
|
||||
"Function");
|
||||
}
|
||||
}
|
||||
@ -876,12 +933,12 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : :%-21s: %-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
"undefined",
|
||||
"undefined entry");
|
||||
"undefined", "undefined entry");
|
||||
} else {
|
||||
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: %-28s\n",
|
||||
entrie->theName, current_scope, parant_scope,
|
||||
"undefined",
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : %06d : %-21s: %-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
parant_scope, "undefined",
|
||||
"undefined entry");
|
||||
}
|
||||
}
|
||||
@ -941,7 +998,8 @@ SymbolTable *removeEntry(SymbolTable *scope, char *search) {
|
||||
return scope;
|
||||
}
|
||||
|
||||
//almost certainly don't need to use the below function since type checking happens by passing types up the grammar
|
||||
// almost certainly don't need to use the below function since type checking
|
||||
// happens by passing types up the grammar
|
||||
bool typeCheck(char *firstID, char *secondID) {
|
||||
|
||||
TableNode *entry1 = look_up(cur, firstID);
|
||||
@ -1002,3 +1060,28 @@ TableNode *getNextEntry(TableNode *tn) { return tn->next; }
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
char *getLineStr();
|
||||
char *COLOR_RED = "\033[0;31m";
|
||||
char *COLOR_GREEN = "\033[0;32m";
|
||||
char *COLOR_ORANGE = "\033[0;33m";
|
||||
char *COLOR_BLUE = "\033[0;34m";
|
||||
char *COLOR_PURPLE = "\033[0;35m";
|
||||
char *COLOR_CYAN = "\033[0;36m";
|
||||
char *COLOR_LIGHTGRAY = "\033[0;37m";
|
||||
char *COLOR_DARKGRAY = "\033[1;30m";
|
||||
char *COLOR_LIGHTRED = "\033[1;31m";
|
||||
char *COLOR_LIGHTGREEN = "\033[1;32m";
|
||||
char *COLOR_YELLOW = "\033[1;33m";
|
||||
char *COLOR_LIGHTBLUE = "\033[1;34m";
|
||||
char *COLOR_LIGHTPURPLE = "\033[1;35m";
|
||||
char *COLOR_LIGHTCYAN = "\033[1;36m";
|
||||
char *COLOR_WHITE = "\033[1;37m";
|
||||
|
||||
bool DEBUG = false;
|
||||
|
||||
char *getLineStr(int d) {
|
||||
char *new_text = malloc(100);
|
||||
sprintf(new_text, "%s[%d]%s ", COLOR_DARKGRAY, d, COLOR_WHITE);
|
||||
return new_text;
|
||||
}
|
18
test.sh
18
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"
|
||||
./alpha -st "$file" -debug
|
||||
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"
|
||||
./alpha -st "$file" -debug
|
||||
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"
|
||||
./alpha -st "$file" -debug
|
||||
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"
|
||||
./alpha -st "$file" -debug
|
||||
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"
|
||||
./alpha -st "$1" -debug
|
||||
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"
|
||||
./alpha -st "$file" -debug
|
||||
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"
|
||||
./alpha -st "$file" -debug
|
||||
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"
|
||||
./alpha -st "$file" -debug
|
||||
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"
|
||||
./alpha -st "$file" -debug
|
||||
echo -e "${SWITCH}----- End of test: ${LIGHTBLUE}$filename ${SWITCH}-${WHITE}\n"
|
||||
switchfunc
|
||||
fi
|
||||
|
Reference in New Issue
Block a user