verifying grammar
This commit is contained in:
@ -512,7 +512,7 @@ SymbolTable *CreateScope(SymbolTable *ParentScope, int Line, int Column) {
|
||||
SymbolTable *init(SymbolTable *start) {
|
||||
if (start->Parent_Scope != NULL) {
|
||||
printdebug(
|
||||
"Cannot initialize a scope that is not the parent scope");
|
||||
"%s[FATAL] Cannot initialize a scope that is not the parent scope", COLOR_RED);
|
||||
return NULL;
|
||||
}
|
||||
integ = (TableNode *)calloc(1, sizeof(TableNode));
|
||||
@ -979,6 +979,9 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
printdebug("%s[WARNING] passed in a non-top level scope to "
|
||||
"print_symbol_table",
|
||||
COLOR_ORANGE);
|
||||
printdebug("%sParent of's: line %d, column %d",
|
||||
COLOR_ORANGE, table->Parent_Scope->Line_Number, table->Parent_Scope->Column_Number);
|
||||
return;
|
||||
}
|
||||
|
||||
if (table->Parent_Scope == NULL) {
|
||||
@ -1100,13 +1103,13 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : :%-21s: %-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
getType(entrie), "Function");
|
||||
getType(entrie), "User Defined");
|
||||
} else {
|
||||
fprintf(file_ptr,
|
||||
"%-17s: %06d : %06d : %-21s: %-28s\n",
|
||||
entrie->theName, current_scope,
|
||||
parant_scope, getType(entrie),
|
||||
"Function");
|
||||
"User Defined");
|
||||
}
|
||||
}
|
||||
if (getAdInfoType(entrie) == TYPE_UNDEFINED) {
|
||||
@ -1145,6 +1148,12 @@ SymbolTable *getAncestor(SymbolTable *table) {
|
||||
}
|
||||
if (table->Parent_Scope == NULL) {
|
||||
// if table has no parent, return itself
|
||||
printdebug("already at top scope!");
|
||||
if (table == cur) {
|
||||
printdebug("passed in the current scope");
|
||||
} else {
|
||||
printdebug("passed in a different scope");
|
||||
}
|
||||
return table;
|
||||
} else {
|
||||
// call function recursively to grab ancestor
|
||||
|
Reference in New Issue
Block a user