diff --git a/src/symbol_table.c b/src/symbol_table.c index 6551c1d..b896306 100644 --- a/src/symbol_table.c +++ b/src/symbol_table.c @@ -66,10 +66,10 @@ typedef enum { // TYPE_ADDRESS, // Type String is an array of char enclosed in double quotes per lexer TYPE_STRING = 1, - // Array can be multidimensional. Information should be stored here - TYPE_ARRAY = 2, + // Array can be multidimensional. Information should be stored here. This is the type of the array + TYPE_ARRAY_TYPE = 2, // Record is user defined types - TYPE_RECORD = 3, + TYPE_RECORD_TYPE = 3, // Declaring what type a particular function is without as TYPE_FUNCTION_DECLARATION = 4, // Declaring what type a particular function is with as @@ -82,7 +82,9 @@ typedef enum { TYPE_PRIMITIVE = 6, // likely NULL TYPE_ALL_ELSE = 7, - TYPE_UNDEFINED = 8 + TYPE_UNDEFINED = 8, + TYPE_RECORD = 9, + TYPE_ARRAY = 10 } types; @@ -688,13 +690,13 @@ int getAdInfoType(TableNode *tn) { return TYPE_PRIMITIVE; } if (strcmp(getName(tn), getName(stri)) == 0) { - return TYPE_ARRAY; + return TYPE_ARRAY_TYPE; } if (strcmp(getName(tn), getName(boo)) == 0) { return TYPE_PRIMITIVE; } if (strcmp(getName(tn), getName(recprime)) == 0) { - return TYPE_RECORD; + return TYPE_RECORD_TYPE; } if (strcmp(getName(tn), getName(funtypeprime)) == 0) { return TYPE_FUNCTION_TYPE; @@ -705,6 +707,21 @@ int getAdInfoType(TableNode *tn) { if (strcmp(getName(tn), getName(undefined)) == 0) { return TYPE_UNDEFINED; } else { + if(strcmp(getType(tn), getName(funtypeprime))==0){ + printdebug("passed in a function to getAdInfoType"); + return TYPE_FUNCTION_DECLARATION; + } + if(strcmp(getType(tn), getName(arrayprim))==0){ + printdebug("passed in an array to getAdInfoType"); + return TYPE_ARRAY; + } + if(strcmp(getType(tn), getName(recprime))==0){ + printdebug("passed in a record to getAdInfoType"); + return TYPE_RECORD; + } + printdebug( + "passed in an entry that is not a primitive type, array, " + "or record. Invalid."); return TYPE_FUNCTION_DECLARATION; } }