Build a quick draft of how the symbol value should be computed.

This commit is contained in:
2023-08-25 01:27:22 -05:00
parent 82b2136a69
commit 9e178ca3da
3 changed files with 48 additions and 20 deletions
+8 -8
View File
@@ -13,16 +13,16 @@
#define SYMBOLSTABLE_DEFAULT_CAPACITY 128
typedef struct __token_node {
Token* Token;
const Token* Token;
struct __token_node* Left;
struct __token_node* Right;
} TokenNode;
typedef struct _symbol {
char* Name;
const char* Name;
int Address;
int Length;
Token* Token;
const Token* Token;
TokenNode* ValueExpression;
} Symbol;
@@ -33,12 +33,12 @@ typedef struct {
} SymbolTable;
SymbolTable* CreateSymbolTable(void);
TokenNode* CreateTokenNode(Token* token);
int TryGetSymbol(char* name, SymbolTable* table, Symbol** outSymbol);
Symbol* AddSymbolToTable(char* name, int address, SymbolTable* table);
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(Symbol* symbol);
int TryGetSymbolValue(const Symbol* symbol, const SymbolTable* table, unsigned short** value);
int SymbolResolved(const Symbol* symbol);
int TryGetSymbolValue(const Symbol* symbol, const SymbolTable* table, unsigned short* value);
#endif
+1 -1
View File
@@ -50,7 +50,7 @@ typedef struct __token {
Registers Register;
Mnemonic Mnemonic;
Directive Directive;
int Number;
unsigned short Number;
} Value;
struct __token* Prev;