started symbol table file
This commit is contained in:
50
symbol_table.c
Normal file
50
symbol_table.c
Normal file
@ -0,0 +1,50 @@
|
||||
//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"
|
||||
|
||||
typedef struct ListOfTable{
|
||||
struct SymbolTable* table;
|
||||
struct ListOfTable* prev;
|
||||
struct ListOfTable* next;
|
||||
}ListOfTable;
|
||||
|
||||
typedef union Value{
|
||||
int* value_of_int;
|
||||
void* value_of_pointer;
|
||||
bool* value_of_bool;
|
||||
char* value_of_char;
|
||||
int* size_of_char_array;
|
||||
}Value;
|
||||
|
||||
typedef struct TableNode{
|
||||
string* theType;
|
||||
string* theName;
|
||||
Value* value;
|
||||
struct TableNode* next;
|
||||
}TableNode;
|
||||
|
||||
typedef struct SymbolTable{
|
||||
TableNode* entries;
|
||||
struct SymbolTable* Parent_Scope;
|
||||
struct ListOfTable* Children_Scope;
|
||||
}SymbolTable;
|
||||
|
||||
SymbolTable* CreateScope(SymbolTable* ParentScope){
|
||||
SymbolTable* table = (SymbolTable*)malloc(sizeof(SymbolTable));
|
||||
table.Parent_Scope = ParentScope;
|
||||
table.Children_Scope = NULL;
|
||||
table.entries = NULL;
|
||||
return table;
|
||||
}
|
||||
|
||||
Entry* CreateEntry(SymbolTable* table, string typeOf, string id, Value value){
|
||||
if(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
0
symbol_table.h
Normal file
0
symbol_table.h
Normal file
0
test_comment_issues.tok
Normal file
0
test_comment_issues.tok
Normal file
0
tests/test_comment_issues.tok
Normal file
0
tests/test_comment_issues.tok
Normal file
Reference in New Issue
Block a user