Files
assm-test/includes/symbols_table.h
T

48 lines
904 B
C

#ifndef SYMBOLSTABLE_H
#define SYMBOLSTABLE_H
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#define SYMBOLSTABLE_DEFAULT_CAPACITY 128
typedef enum {
ValueAt,
Address
} SymbolType;
typedef struct {
char* String;
uint8_t TerminatorByte;
int HasTerminatorByte;
} SymbolString;
typedef struct {
char* Name;
int Length;
int Resolved;
union {
SymbolString String;
int Number;
//Instruction Instruction;
} Value;
} Symbol;
typedef struct {
Symbol** Symbols;
int Size;
int Capacity;
} SymbolTable;
SymbolTable* CreateSymbolTable(void);
Symbol* TryGetSymbol(char* name, SymbolTable* table);
Symbol* AddSymbolToTable(char* name, SymbolTable* table);
SymbolString* CreateSymbolString(char* text);
void FreeSymbolTable(SymbolTable* table);
void FreeSymbol(Symbol* symbol);
#endif