fixed symbol_table entries not working
This commit is contained in:
@ -37,17 +37,18 @@ 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;
|
||||||
}
|
}
|
||||||
TableNode* topDef = (table_lookup(getAncestor(table),typeOf));
|
/*TableNode* topDef = (table_lookup(getAncestor(table),typeOf));
|
||||||
if(topDef == NULL){
|
if(topDef == NULL){
|
||||||
printf("This type is not defined at the top level\n");
|
printf("This type is not defined at the top level\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}*/
|
||||||
TableNode* newEntry = (TableNode*)malloc(sizeof(TableNode));
|
TableNode* newEntry = (TableNode*)malloc(sizeof(TableNode));
|
||||||
newEntry->theType = topDef->theName;
|
//newEntry->theType = topDef->theName;
|
||||||
|
newEntry->theType=typeOf;
|
||||||
newEntry->theName = id;
|
newEntry->theName = id;
|
||||||
if (table->entries == NULL) {
|
if (table->entries == NULL) {
|
||||||
table->entries = newEntry;
|
table->entries = newEntry;
|
||||||
|
Reference in New Issue
Block a user