symbol_table print almost done but have to figure out seg fault
This commit is contained in:
@ -505,6 +505,7 @@ SymbolTable* setLineNumber(SymbolTable *st,int line){
|
|||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
st->Line_Number = line;
|
st->Line_Number = line;
|
||||||
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
SymbolTable* setColumnNumber(SymbolTable *st,int column){
|
SymbolTable* setColumnNumber(SymbolTable *st,int column){
|
||||||
@ -513,6 +514,7 @@ SymbolTable* setColumnNumber(SymbolTable *st,int column){
|
|||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
st->Line_Number = column;
|
st->Line_Number = column;
|
||||||
|
return st;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
//we use false for type defs and true for functions for parameter of typeOf
|
//we use false for type defs and true for functions for parameter of typeOf
|
||||||
@ -606,11 +608,76 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
|||||||
entrie->additionalinfo->ArrayAdInfo->typeofarray->theName,
|
entrie->additionalinfo->ArrayAdInfo->typeofarray->theName,
|
||||||
"Type of Array");
|
"Type of Array");
|
||||||
} else {
|
} else {
|
||||||
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: %-28s\n",
|
fprintf(file_ptr, "%-17s: %06d : %06d : %-21d -> %-21s: %-28s\n",
|
||||||
entrie->theName, current_scope, parant_scope,
|
entrie->theName, current_scope, parant_scope,
|
||||||
entrie->theType->theName, "Extra annotation");
|
entrie->additionalinfo->ArrayAdInfo->numofdimensions,
|
||||||
|
entrie->additionalinfo->ArrayAdInfo->typeofarray->theName,
|
||||||
|
"Type of Array");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (getAdInfoType(entrie) == TYPE_RECORD){
|
||||||
|
if (parant_scope == 0) {
|
||||||
|
|
||||||
|
fprintf(file_ptr,
|
||||||
|
"%-17s: %06d : :%-21s: elements-%-28d\n",
|
||||||
|
entrie->theName, current_scope,
|
||||||
|
"record",
|
||||||
|
entrie->additionalinfo->RecAdInfo->numofelements);
|
||||||
|
} else {
|
||||||
|
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: elements-%-28d\n",
|
||||||
|
entrie->theName, current_scope, parant_scope,
|
||||||
|
"record",
|
||||||
|
entrie->additionalinfo->RecAdInfo->numofelements);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getAdInfoType(entrie) == TYPE_PRIMITIVE){
|
||||||
|
if (parant_scope == 0) {
|
||||||
|
|
||||||
|
fprintf(file_ptr,
|
||||||
|
"%-17s: %06d : :%-21s: size-%-28d bytes\n",
|
||||||
|
entrie->theName, current_scope,
|
||||||
|
"Primitive",
|
||||||
|
entrie->additionalinfo->PrimAdInfo->size);
|
||||||
|
} else {
|
||||||
|
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: size-%-28d bytes\n",
|
||||||
|
entrie->theName, current_scope, parant_scope,
|
||||||
|
"Primitive",
|
||||||
|
entrie->additionalinfo->PrimAdInfo->size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getAdInfoType(entrie) == TYPE_FUNCTION_TYPE){
|
||||||
|
if (parant_scope == 0) {
|
||||||
|
|
||||||
|
fprintf(file_ptr,
|
||||||
|
"%-17s: %06d : : %-21s -> %-21s: %-28s\n",
|
||||||
|
entrie->theName, current_scope,
|
||||||
|
entrie->additionalinfo->FunTypeAdInfo->parameter->theName,
|
||||||
|
entrie->additionalinfo->FunTypeAdInfo->returntype->theName,
|
||||||
|
"Type of Function");
|
||||||
|
} else {
|
||||||
|
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s -> %-21s: %-28s\n",
|
||||||
|
entrie->theName, current_scope, parant_scope,
|
||||||
|
entrie->additionalinfo->FunTypeAdInfo->parameter->theName,
|
||||||
|
entrie->additionalinfo->FunTypeAdInfo->returntype->theName,
|
||||||
|
"Type of Function");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getAdInfoType(entrie) == TYPE_FUNCTION_DECLARATION){
|
||||||
|
if (parant_scope == 0) {
|
||||||
|
|
||||||
|
fprintf(file_ptr,
|
||||||
|
"%-17s: %06d : :%-21s: %-28s\n",
|
||||||
|
entrie->theName, current_scope,
|
||||||
|
getType(entrie),
|
||||||
|
"Function");
|
||||||
|
} else {
|
||||||
|
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: %-28s\n",
|
||||||
|
entrie->theName, current_scope, parant_scope,
|
||||||
|
getType(entrie),
|
||||||
|
"Function");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (table->Children_Scope != NULL) {
|
if (table->Children_Scope != NULL) {
|
||||||
ListOfTable *node = table->Children_Scope;
|
ListOfTable *node = table->Children_Scope;
|
||||||
for (; node != NULL; node = node->next) {
|
for (; node != NULL; node = node->next) {
|
||||||
|
Reference in New Issue
Block a user