Updated the way string symbols are handled, allowing the programmer to terminate a string with any byte or none at all.
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
#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"
|
||||
|
||||
#define SYMBOLSTABLE_DEFAULT_CAPACITY 128
|
||||
@@ -16,12 +18,18 @@ typedef enum {
|
||||
UnresolvedSymbol
|
||||
} SymbolType;
|
||||
|
||||
typedef struct {
|
||||
char* String;
|
||||
int Terminated;
|
||||
u_int8_t TerminatingByte;
|
||||
} SymbolString;
|
||||
|
||||
typedef struct {
|
||||
char* Name;
|
||||
SymbolType Type;
|
||||
|
||||
union {
|
||||
char* Text;
|
||||
SymbolString* String;
|
||||
int Number;
|
||||
Instruction* Instruction;
|
||||
} Value;
|
||||
@@ -36,6 +44,7 @@ typedef struct {
|
||||
SymbolTable* CreateSymbolTable(void);
|
||||
Symbol* TryGetSymbol(char* name, SymbolTable* table);
|
||||
Symbol* AddSymbolToTable(char* name, SymbolType type, SymbolTable* table);
|
||||
SymbolString* CreateSymbolString(char* string, int terminated);
|
||||
void FreeSymbolTable(SymbolTable* table);
|
||||
void FreeSymbol(Symbol* symbol);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user