From d1f7041c31c6c1334cdb7173898d54f850de4d23 Mon Sep 17 00:00:00 2001 From: Partho Bhattacharya Date: Wed, 26 Mar 2025 10:54:04 -0400 Subject: [PATCH] added enum return function --- src/symbol_table.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/symbol_table.c b/src/symbol_table.c index 83901df..a01d467 100644 --- a/src/symbol_table.c +++ b/src/symbol_table.c @@ -40,13 +40,17 @@ typedef enum { //Declaring what type a function is (what the parameters and output are) TYPE_FUNCTION_TYPE, //The Type being pointed to by the first 4 above that only stores the size - TYPE_PRIMITIVE + TYPE_PRIMITIVE, + //All else (NULL case likely) + TYPE_ALL_ELSE } types; /* put in symbol_table.h typedef struct{ - int size; + int size; if(strcmp(getType(tn),getName(integ))==0){ + return + } }primitive_info; typedef struct{ @@ -366,8 +370,46 @@ if(typeOf == NULL){ return newEntry; } } +/* +TableNode* integ; +TableNode* addr; +TableNode* chara; +TableNode* stri; +TableNode* boo; +TableNode* recprime; +TableNode* funtypeprime; +*/ char* getType(TableNode* tn) { return tn->theType->theName; } + int getAdInfoType(TableNode* tn){ + if(strcmp(getType(tn),getName(integ))==0){ + return TYPE_PRIMITIVE; + } + if(strcmp(getType(tn),getName(addr))==0){ + return TYPE_PRIMITIVE; + } + if(strcmp(getType(tn),getName(chara))==0){ + return TYPE_PRIMITIVE; + } + if(strcmp(getType(tn),getName(stri))==0){ + return TYPE_ARRAY; + } + if(strcmp(getType(tn),getName(boo))==0){ + return TYPE_PRIMITIVE; + } + if(strcmp(getType(tn),getName(recprime))==0){ + return TYPE_RECORD; + } + if(strcmp(getType(tn),getName(funtypeprime))==0){ + return TYPE_FUNCTION_TYPE; + } + if(strcmp(getType(tn),getName(arrayprim))==0){ + return TYPE_ARRAY; + } + else{ + return TYPE_FUNCTION_DECLARATION; + } +} char* getName(TableNode* tn) { return tn->theName; } int getLine(SymbolTable* st) { return st->Line_Number; } int getColumn(SymbolTable* st) { return st->Column_Number; }