added more helper functions. still have to update print symbol table function
This commit is contained in:
@ -472,17 +472,38 @@ TableNode *CreateEntry(SymbolTable *table, TableNode *typeOf, char *id,
|
||||
char *getType(TableNode *tn) {
|
||||
if(tn == NULL){
|
||||
printf("passed a NULL table entry to getType\n");
|
||||
return tn;
|
||||
return "";
|
||||
}
|
||||
if(tn->theType == NULL){
|
||||
printf("type of entry is currently NULL, undefined type \n");
|
||||
return tn;
|
||||
return "";
|
||||
}
|
||||
return tn->theType->theName; }
|
||||
char *getName(TableNode *tn) { return tn->theName; }
|
||||
int getLine(SymbolTable *st) { return st->Line_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
|
||||
TableNode* Define(SymbolTable* table, bool typeOf, char* id) {
|
||||
|
Reference in New Issue
Block a user