Merge branch 'Dev' into Sprint2-SymbolTableOperations-FE-t#29

This commit is contained in:
maxsimongt3
2025-02-21 14:53:25 -05:00
committed by GitHub
7 changed files with 155 additions and 119 deletions

View File

@ -1,45 +1,10 @@
//Defining a symbol table
//Using a Linked List Structure. Head of linked List points to parent scope (if one exists)
//Tail of Linked List points to a Linked List of all the child scopes
//T
//*#include "symbol_table.h"
/*
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
typedef struct ListOfTable{
struct SymbolTable* table;
//struct ListOfTable* prev;
struct ListOfTable* next;
//Tail of Linked List points to a List of child scopes
}ListOfTable;
typedef union Value{
int* value_of_int;
void* value_of_pointer;
bool* value_of_bool;
char* value_of_char;
}Value;
typedef struct TableNode{
char* theType;
char* theName;
Value* value;
struct TableNode* next;
//this next value is an int for string types to tell you how far to traverse a buffer for the string
int StrLength;
}TableNode;
typedef struct SymbolTable{
TableNode* entries;
struct SymbolTable* Parent_Scope;
struct ListOfTable* Children_Scope;
int Line_Number;
int Column_Number;
}SymbolTable;
*/
#include "symbol_table.h"
SymbolTable* CreateScope(SymbolTable* ParentScope, int Line, int Column){
SymbolTable* table = (SymbolTable*)malloc(sizeof(SymbolTable));
@ -103,14 +68,14 @@ TableNode * look_up(SymbolTable * table, char * x){
}
//uncomment the below main function along with the headers above for a simple standalone test of table and entry creation
/*
int main(){
char* String = "STRING";
char* X = "X";
SymbolTable* Second = CreateScope(NULL, 2,2);
printf("Line number is %d, Column number of scope is %d\n",Second->Line_Number,Second->Column_Number);
TableNode* First_Entry = CreateEntry(Second,String,X);
printf("The value of the first entry is %s\n",First_Entry->theType);
printf("The type of the first entry is %s\n",First_Entry->theType);
return 0;
}
*/