Files
assm-test/includes/symbols_table.h
T

44 lines
1.1 KiB
C

#ifndef SYMBOLSTABLE_H
#define SYMBOLSTABLE_H
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#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);
int TryGetSymbolValue(const Symbol* symbol, const SymbolTable* table, unsigned short* value);
#endif