Made spelling errors t#29

This commit is contained in:
Meyer Simon
2025-02-21 11:47:20 -05:00
parent dbcdafb1a0
commit ad5da96857

View File

@ -1,10 +1,11 @@
#include <stdlib.h>
#include "symbol_table.h"
#include "symbol_table.c"
#include <string.h>
void print_symbol_table(SymbolTable *table, FILE *file_ptr){
if(table->Parent_Scope == NULL){
fprintf(file_ptr, "%-17s: %-6s : %-6s : %-21s: %-28s\n", "NAME", "SCOPE", "PARANT", "TYPE", "Extra annotation");
fprintf(file_ptr, "%-17s: %-6s : %-6s : %-21s: %-28s\n", "NAME", "SCOPE", "PARENT", "TYPE", "Extra annotation");
}
TableNode * entrie = table->entries;
fprintf(file_ptr, "-----------------:--------:--------:----------------------:-----------------------------\n");
@ -18,10 +19,16 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr){
}
for(; entrie != NULL; entrie = entrie->next){
if (parant_scope == 0){
fprintf(file_ptr, "%-17s: %06d : : %-21s: %-28s\n",
entrie->theName, current_scope,
entrie->theType, "Extra annotation");
} else {
fprintf(file_ptr, "%-17s: %06d : %06d : %-21s: %-28s\n",
entrie->theName, current_scope, parant_scope,
entrie->theType, "Extra annotation");
}
}
if (table->Children_Scope != NULL){
ListOfTable* node = table->Children_Scope;
for(; node != NULL; node = node->next){
@ -36,27 +43,39 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr){
*/
int main(void){
char *prim = strdup("primitive");
char *inte = strdup("integer");
SymbolTable * parant = CreateScope(NULL, 1,1);
char *boole = strdup("Boolean");
char *chare = strdup("character");
char *str = strdup("string");
char *arg = strdup("arg");
// Value* v = calloc(1, sizeof(Value));
CreateEntry(parant, &"primitive", &"Boolean", NULL, 0);
CreateEntry(parant, &"primitive", &"character", NULL, 0);
CreateEntry(parant, &"primitive", &"integer", NULL, 0);
CreateEntry(parant, &"1 -> character", &"string", NULL, 0);
CreateEntry(parant, prim, boole, NULL, 0);
CreateEntry(parant, prim, chare, NULL, 0);
CreateEntry(parant, prim, inte, NULL, 0);
CreateEntry(parant, &"1 -> character", str, NULL, 0);
CreateEntry(parant, &"integer -> integer", &"int2int", NULL, 0);
CreateEntry(parant, &"string -> integer", &"string2int", NULL, 0);
CreateEntry(parant, &"int2int", &"square", NULL, 0);
CreateEntry(parant, &"string2int", &"entry", NULL, 0);
SymbolTable * child = CreateScope(parant, 14,14);
CreateEntry(child, &"integer", &"x", NULL, 0);
SymbolTable * second = CreateScope(parant, 14,14);
CreateEntry(second, &"string", &"arg", NULL, 0);
CreateEntry(second, &"integer", &"input", NULL, 0);
CreateEntry(second, &"integer", &"expected", NULL, 0);
CreateEntry(second, &"integer", &"actual", NULL, 0);
CreateEntry(child, inte, &"x", NULL, 0);
SymbolTable * second = CreateScope(parant, 21,15);
CreateEntry(second, str, arg, NULL, 0);
CreateEntry(second, inte, &"input", NULL, 0);
CreateEntry(second, inte, &"expected", NULL, 0);
CreateEntry(second, inte, &"actual", NULL, 0);
CreateEntry(second, &"$_undefined_type", &"result", NULL, 0);
SymbolTable * third = CreateScope(second, 33,44);
CreateEntry(third, &"BOO", &"arg", NULL, 0);
CreateEntry(third, &"BOO", arg, NULL, 0);
CreateEntry(third, &"YAZOO", &"input", NULL, 0);
print_symbol_table(parant, stderr);
free(inte);
free(boole);
free(prim);
free(str);
free(chare);
free(arg);
return 0;
}