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:
2022-10-08 16:35:05 -05:00
parent 8b6edc39be
commit 48a77950be
3 changed files with 57 additions and 7 deletions
+17
View File
@@ -40,6 +40,23 @@ Symbol* CreateSymbol(char* name, SymbolType type) {
return symbol;
}
SymbolString* CreateSymbolString(char* string, int terminated) {
if (!string) return NULL;
SymbolString* s = calloc(1, sizeof(SymbolString));
if (!s) {
fprintf(stderr, "Failed to calloc string for symbol. %s.\n", strerror(errno));
return NULL;
}
s->String = string;
s->Terminated = terminated;
return s;
}
Symbol* TryGetSymbol(char* name, SymbolTable* table) {
if (!name || !table) return NULL;