Merge branch 'Dev' into Sprint2-Partho_Symbol_Tabke-FE-t#NoTask

This commit is contained in:
Moroseui
2025-03-10 12:02:54 -04:00
committed by GitHub
2 changed files with 112 additions and 108 deletions

View File

@ -36,6 +36,7 @@ SymbolTable* CreateScope(SymbolTable* ParentScope, int Line, int Column) {
//create entry just for things below top level scope //create entry just for things below top level scope
TableNode* CreateEntry(SymbolTable* table, char* typeOf, char* id) { TableNode* CreateEntry(SymbolTable* table, char* typeOf, char* id) {
if(table ==NULL || table->Parent_Scope == NULL){ if(table ==NULL || table->Parent_Scope == NULL){
printf("Null reference to table given for create entry or given top level scope which is invalid\n"); printf("Null reference to table given for create entry or given top level scope which is invalid\n");
return NULL; return NULL;
@ -90,6 +91,7 @@ if(table_lookup(table,id) != NULL){
newEntry->next = oldEntry; newEntry->next = oldEntry;
return newEntry; return newEntry;
} }
} }
TableNode* table_lookup(SymbolTable* table, char* x) { TableNode* table_lookup(SymbolTable* table, char* x) {
@ -130,7 +132,10 @@ void print_symbol_table(SymbolTable* table, FILE* file_ptr) {
} else { } else {
current_scope = 1001; current_scope = 1001;
} }
if ( entrie == NULL ) {
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: %-28s\n", "",
current_scope, parant_scope, "", "Empty Scope");
}
for (; entrie != NULL; entrie = entrie->next) { for (; entrie != NULL; entrie = entrie->next) {
if (parant_scope == 0) { if (parant_scope == 0) {
fprintf(file_ptr, "%-17s: %06d : : %-21s: %-28s\n", fprintf(file_ptr, "%-17s: %06d : : %-21s: %-28s\n",

View File

@ -7,7 +7,6 @@ typedef struct ListOfTable {
struct SymbolTable* table; struct SymbolTable* table;
// struct ListOfTable* prev; // struct ListOfTable* prev;
struct ListOfTable* next; struct ListOfTable* next;
} ListOfTable; } ListOfTable;
typedef struct TableNode { typedef struct TableNode {