Got symbol Table largely working (but without certain entries being added like functions or records)

This commit is contained in:
Partho Bhattacharya
2025-03-14 20:48:11 -04:00
parent ead70170c0
commit 78f1cd3fbb
3 changed files with 19 additions and 7 deletions

View File

@ -19,6 +19,8 @@
extern FILE * yyin;
extern TableNode* funprime;
extern TableNode* arrayprim;
extern TableNode* recprime;
extern TableNode* funtypeprime;
extern TableNode* integ;
extern TableNode* addr;
extern TableNode* chara;
@ -33,6 +35,9 @@
}
%type <words> expression
%type <words> constant
%type <words> id_or_types
%type <words> types
%token <words> ID 101
@ -150,7 +155,7 @@ declaration_list:
;
declaration:
id_or_types COLON ID {CreateEntry(cur,$<words>1,$<words>3); }
id_or_types COLON ID {CreateEntry(cur,$<words>1,$<words>3,NULL); }
;
id_or_types:
@ -188,8 +193,7 @@ rec_op :
expression:
constant {printf("constant expression\n");} {$$ = $<words>1;}
| SUB_OR_NEG expression {if(strcmp($2,integer) != 0) {printf("cant negate something not an integer at
line %d and column %d\n",@2.first_line,@2.first_column);}} %prec UMINUS {printf("negative expression\n");}
| SUB_OR_NEG expression {if(strcmp($2,"integer") != 0) {printf("cant negate something not an integer at line %d and column %d\n",@2.first_line,@2.first_column);}} %prec UMINUS {printf("negative expression\n");}
| NOT expression {printf("not expression\n");}
| expression ADD expression {printf("add expression\n");}