tweaking statement options

This commit is contained in:
Partho
2025-05-06 04:38:35 -04:00
parent e3081f35a4
commit 8b177b2807
5 changed files with 71 additions and 91 deletions

View File

@ -4,6 +4,8 @@
#include "symbol_table.h"
Constant_Stack *head = NULL;
Context_stack *context_head = NULL;
TableNode* comparator = NULL;
int temp2_count = 0;
int temp3_count = 0;
@ -53,6 +55,35 @@ Constant_Stack *Push(TableNode *type, void *value, bool isConst) {
return cs;
}
Context_stack *PushContext(int context) {
if (context != 1 && context != 2 && context != 3 && context != 0) {
printdebug(
"invalid context passed in");
return NULL;
}
Context_stack *cs = (Context_stack *)malloc(sizeof(Context_stack));
cs->con = context;
if (context_head == NULL) {
context_head = cs;
cs->next = NULL;
} else {
cs->next = context_head;
context_head = cs;
}
return cs;
}
int PopContext() {
if (context_head == NULL) {
printf("cannot pop from an empty stack. Invalid.\n");
return -1;
}
Context_stack *cs = context_head;
context_head = context_head->next;
printf("Popped context off stack: number %d\n", cs->con);
return cs->con;
}
Constant_Stack *Pop() {
if (head == NULL) {
printf("cannot pop from an empty stack. Invalid.\n");