Cleaned up the Symbol struct and updated code accordingly.

This commit is contained in:
2022-10-08 14:43:00 -05:00
parent 4b08707e67
commit c142d2c6d0
3 changed files with 37 additions and 20 deletions
+4 -5
View File
@@ -25,7 +25,7 @@ SymbolTable* CreateSymbolTable(void){
return table;
}
Symbol* CreateSymbol(char* name, void* value, int length) {
Symbol* CreateSymbol(char* name, SymbolType type) {
Symbol* symbol = calloc(1, sizeof(Symbol));
if (!symbol) {
@@ -34,9 +34,8 @@ Symbol* CreateSymbol(char* name, void* value, int length) {
return NULL;
}
symbol->Length = length;
symbol->Type = type;
symbol->Name = name;
//symbol->Value = value;
return symbol;
}
@@ -51,7 +50,7 @@ Symbol* TryGetSymbol(char* name, SymbolTable* table) {
return NULL;
}
Symbol* AddSymbolToTable(char* name, void* value, int length, SymbolTable* table) {
Symbol* AddSymbolToTable(char* name, SymbolType type, SymbolTable* table) {
//if (!name || !value || !table || length == 0) return NULL;
for(int i = 0; i < table->Size; i++) {
@@ -75,7 +74,7 @@ Symbol* AddSymbolToTable(char* name, void* value, int length, SymbolTable* table
table->Symbols = newBlock;
}
Symbol* symbol = CreateSymbol(name, value, length);
Symbol* symbol = CreateSymbol(name, type);
table->Symbols[table->Size] = symbol;
table->Size++;