it looks like this should work. t#29

This commit is contained in:
Meyer Simon
2025-02-21 14:30:14 -05:00
parent ad5da96857
commit fcb66c125d
7 changed files with 136 additions and 34 deletions

View File

@ -41,7 +41,6 @@ void print_symbol_table(SymbolTable *table, FILE *file_ptr){
}
/*
*/
int main(void){
char *prim = strdup("primitive");
char *inte = strdup("integer");
@ -51,25 +50,41 @@ int main(void){
char *str = strdup("string");
char *arg = strdup("arg");
// Value* v = calloc(1, sizeof(Value));
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);
CreateEntry(parant, prim, boole);
CreateEntry(parant, prim, chare);
CreateEntry(parant, prim, inte);
CreateEntry(parant, &"1 -> character", str);
CreateEntry(parant, &"integer -> integer", &"int2int");
CreateEntry(parant, &"string -> integer", &"string2int");
CreateEntry(parant, &"int2int", &"square");
CreateEntry(parant, &"string2int", &"entry");
SymbolTable * child = CreateScope(parant, 14,14);
CreateEntry(child, inte, &"x", NULL, 0);
CreateEntry(child, inte, &"x");
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);
CreateEntry(second, str, arg);
CreateEntry(second, inte, &"input");
CreateEntry(second, inte, &"expected");
CreateEntry(second, inte, &"actual");
CreateEntry(second, &"$_undefined_type", &"result");
SymbolTable * third = CreateScope(second, 33,44);
CreateEntry(third, &"BOO", arg, NULL, 0);
CreateEntry(third, &"YAZOO", &"input", NULL, 0);
CreateEntry(third, &"BOO", arg);
CreateEntry(third, &"YAZOO", &"input");
TableNode *ret = table_lookup(third, "arg");
printf("%s == %s\n", ret->theName, "arg");
ret = table_lookup(third, "hello");
printf("This should be nil %p != %s\n", ret, "BOO");
ret = look_up(second, "input");
printf("%s == %s\n", ret->theName, "input");
ret = look_up(second, "square");
printf("%s == %s\n", ret->theName, "square");
ret = look_up(second, "spuare");
printf("This should be nil %p == %s\n", ret, "square");
print_symbol_table(parant, stderr);
free(inte);
free(boole);
@ -79,3 +94,5 @@ int main(void){
free(arg);
return 0;
}
*/