more debug messages, new type check for array and rec
This commit is contained in:
@ -259,10 +259,19 @@ compound_statement:
|
||||
;
|
||||
|
||||
simple_statement:
|
||||
assignable ASSIGN expression {if(strcmp($1, $3) == 0){
|
||||
} else {
|
||||
printdebug("Mismatch at line %d and column%d", @2.first_line, @2.first_column);
|
||||
}}
|
||||
assignable ASSIGN expression
|
||||
{
|
||||
if(strcmp($1, $3) == 0) {
|
||||
printdebug("Passed standard type check; assignable = expression");
|
||||
} else if((strcmp($1, "rec") == 0) && (strcmp($3, "address") == 0)) {
|
||||
printdebug("Passed rec type check; rec = address");
|
||||
} else if((strcmp($1, "array") == 0) && (strcmp($3, "address") == 0)) {
|
||||
printdebug("Passed array type check; array = address");
|
||||
} else {
|
||||
printdebug("%s[TYPE ERROR] %sMismatch at %sline %d and column %d%s", COLOR_ORANGE, COLOR_WHITE, COLOR_YELLOW, @2.first_line, @2.first_column, COLOR_WHITE);
|
||||
printdebug(" - Invalid types %s$1: %s and $3: %s%s", COLOR_YELLOW, $1, $3, COLOR_WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
| RETURN expression
|
||||
;
|
||||
|
@ -975,15 +975,6 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (table->Parent_Scope != NULL) {
|
||||
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) {
|
||||
fprintf(file_ptr, "%-17s: %-6s : %-6s : %-21s: %-28s\n", "NAME",
|
||||
"SCOPE", "PARENT", "TYPE", "Extra annotation");
|
||||
|
Reference in New Issue
Block a user