continued working on table structure
This commit is contained in:
@ -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{
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user