added more helper functions. still have to update print symbol table function

This commit is contained in:
Partho Bhattacharya
2025-03-26 18:42:09 -04:00
parent 27fb88f866
commit 22c1a79e03

View File

@ -472,17 +472,38 @@ TableNode *CreateEntry(SymbolTable *table, TableNode *typeOf, char *id,
char *getType(TableNode *tn) { char *getType(TableNode *tn) {
if(tn == NULL){ if(tn == NULL){
printf("passed a NULL table entry to getType\n"); printf("passed a NULL table entry to getType\n");
return tn; return "";
} }
if(tn->theType == NULL){ if(tn->theType == NULL){
printf("type of entry is currently NULL, undefined type \n"); printf("type of entry is currently NULL, undefined type \n");
return tn; return "";
} }
return tn->theType->theName; } return tn->theType->theName; }
char *getName(TableNode *tn) { return tn->theName; } char *getName(TableNode *tn) { return tn->theName; }
int getLine(SymbolTable *st) { return st->Line_Number; } int getLine(SymbolTable *st) { return st->Line_Number; }
int getColumn(SymbolTable *st) { return st->Column_Number; } int getColumn(SymbolTable *st) { return st->Column_Number; }
TableNode* addName(TableNode *tn, char* str){
if(tn == NULL){
printf("passed a Null table node to the addName function. Invalid./n");
return tn;
}
}
SymbolTable* setLineNumber(SymbolTable *st,int line){
if(st == NULL){
printf("passed a Null Symbol Table to the setLineNumber function. Invalid./n");
return st;
}
st->Line_Number = line;
}
SymbolTable* setColumnNumber(SymbolTable *st,int column){
if(st == NULL){
printf("passed a Null Symbol Table to the setColumnNumber function. Invalid./n");
return st;
}
st->Line_Number = column;
}
/* /*
//we use false for type defs and true for functions for parameter of typeOf //we use false for type defs and true for functions for parameter of typeOf
TableNode* Define(SymbolTable* table, bool typeOf, char* id) { TableNode* Define(SymbolTable* table, bool typeOf, char* id) {