#ifndef SYMBOLSTABLE_H #define SYMBOLSTABLE_H #include #include #include #include #include #include #include "opcodes.h" #include "token.h" #define SYMBOLSTABLE_DEFAULT_CAPACITY 128 typedef struct __token_node { const Token* Token; struct __token_node* Left; struct __token_node* Right; } TokenNode; typedef struct _symbol { const char* Name; int Address; int Length; const Token* Token; TokenNode* ValueExpression; } Symbol; typedef struct { Symbol** Symbols; int Size; int Capacity; } SymbolTable; SymbolTable* CreateSymbolTable(void); TokenNode* CreateTokenNode(const Token* token); int TryGetSymbol(const char* name, const SymbolTable* table, Symbol** outSymbol); Symbol* AddSymbolToTable(const char* name, int address, SymbolTable* table); void FreeSymbolTable(SymbolTable* table); void FreeSymbol(Symbol* symbol); int SymbolResolved(const Symbol* symbol, const SymbolTable* table); int TryGetSymbolValue(const Symbol* symbol, const SymbolTable* table, unsigned short* value); #endif