runner and parser together add entries ok

This commit is contained in:
Partho Bhattacharya
2025-03-05 15:02:30 -05:00
parent c2f28b6836
commit f819a68ef7
5 changed files with 211 additions and 194 deletions

View File

@ -59,7 +59,7 @@ int check_flag(char *arg, char *alpha) {
int run(FILE *alpha) {
int token;
curr = CreateScope(NULL, 1, 1);
cur = CreateScope(NULL, 1, 1);
// If file is not found
if (alpha == NULL) {
@ -108,7 +108,7 @@ int run(FILE *alpha) {
yyparse();
FILE *f = fdopen(1, "w");
print_symbol_table(getAncestor(curr), f);
print_symbol_table(getAncestor(cur), f);
fclose(f);
if (yyin != NULL) {
@ -179,12 +179,12 @@ int is_alpha_file(char *alpha, int file_len) {
}
void enter_scope(int line, int column) {
curr = CreateScope(curr, line, column);
cur = CreateScope(cur, line, column);
}
void exit_scope() {
if (curr->Parent_Scope == NULL) {
if (cur->Parent_Scope == NULL) {
printf("Can't close top");
return;
}
curr = curr->Parent_Scope;
cur = cur->Parent_Scope;
}