From 5f35308361a2f594c0145aa45e5b55633a501170 Mon Sep 17 00:00:00 2001 From: Partho Bhattacharya Date: Thu, 20 Feb 2025 15:19:50 -0500 Subject: [PATCH] continued working on table structure --- symbol_table.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/symbol_table.c b/symbol_table.c index 31d2945..196bf06 100644 --- a/symbol_table.c +++ b/symbol_table.c @@ -8,6 +8,8 @@ typedef struct ListOfTable{ struct SymbolTable* table; struct ListOfTable* prev; struct ListOfTable* next; + int Line_Number; + int Column_Number; }ListOfTable; typedef union Value{ @@ -15,7 +17,6 @@ typedef union Value{ void* value_of_pointer; bool* value_of_bool; char* value_of_char; - int* size_of_char_array; }Value; typedef struct TableNode{ @@ -23,6 +24,8 @@ typedef struct TableNode{ string* theName; Value* value; struct TableNode* next; + //this next value is an int for string types to tell you how far to traverse a buffer for the string + int StrLength; }TableNode; typedef struct SymbolTable{ @@ -31,18 +34,23 @@ typedef struct SymbolTable{ struct ListOfTable* Children_Scope; }SymbolTable; -SymbolTable* CreateScope(SymbolTable* ParentScope){ +SymbolTable* CreateScope(SymbolTable* ParentScope, int Line, int Column){ SymbolTable* table = (SymbolTable*)malloc(sizeof(SymbolTable)); + table.Line_Number = Line; + table.Column_Number = Column; table.Parent_Scope = ParentScope; table.Children_Scope = NULL; table.entries = NULL; return table; } -Entry* CreateEntry(SymbolTable* table, string typeOf, string id, Value value){ - if( - - +TableNode* CreateEntry(SymbolTable* table, string typeOf, string id, Value value, int StringLength){ + if(table.entries == NULL){ + TableNode* newEntry = (TableNode*)malloc(sizeof(SymbolTable)); + newEntry.theType = typeOf; + newEntry.theName = id; + newEntry.StrLength = StringLength; + } else{