From db2268284bd59a838a7003825d142bc5332a94c8 Mon Sep 17 00:00:00 2001 From: Scarlett Date: Wed, 2 Apr 2025 11:05:45 -0400 Subject: [PATCH] more debug messages, new type check for array and rec --- src/grammar.y | 17 +++++++++++++---- src/symbol_table.c | 9 --------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/grammar.y b/src/grammar.y index 8eff344..e4185c8 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -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 ; diff --git a/src/symbol_table.c b/src/symbol_table.c index 29d34a1..6551c1d 100644 --- a/src/symbol_table.c +++ b/src/symbol_table.c @@ -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");