Lots of changes and too much dragging my feet on this. But I think this is going in the right direction now.

This commit is contained in:
2025-06-24 23:48:26 -05:00
parent ebfd7cf94c
commit b759589e84
16 changed files with 320 additions and 51 deletions
+34
View File
@@ -14,9 +14,34 @@ struct _token* TokenCreate(TokenType type, int lineNumber, int columnNumber, boo
char* TokenStringify(const struct _token* token) {
if (!token) return false;
char word[32];
char* buffer = NULL;
switch(token->Type) {
case Register:
GetRegisterText(token->Value.Register, word);
buffer = calloc(sizeof(word), sizeof(char));
strncpy(buffer, word, sizeof(word));
break;
case Mnemonic:
GetMnemonicText(token->Value.Mnemonic, word);
buffer = calloc(sizeof(word), sizeof(char));
strncpy(buffer, word, sizeof(word));
break;
case Keyword:
GetKeywordText(token->Value.Keyword, word);
buffer = calloc(sizeof(word), sizeof(char));
strncpy(buffer, word, sizeof(word));
break;
case String:
case Symbol:
buffer = calloc(strlen(token->Value.String) + 1, sizeof(char));
@@ -64,6 +89,15 @@ int StringifyTokenType(TokenType type, char buffer[32]) {
case Empty:
strncpy(buffer, "<empty >", 8);
break;
case Register:
strncpy(buffer, "<Reg >", 8);
break;
case Mnemonic:
strncpy(buffer, "<Mnemon>", 8);
break;
case Keyword:
strncpy(buffer, "<Key >", 8);
break;
case String:
strncpy(buffer, "<string>", 8);
break;