Updated the parser to be able to correctly sync via a longjmp. Fixed a few bugs in the tokenizer, like not allowing underscores in symbol / label names and taught it how to detect a label declaration. Fixed the code that gets the register name.

This commit is contained in:
2025-06-26 23:24:03 -05:00
parent 3a5788f4ab
commit 428556a7a1
9 changed files with 141 additions and 63 deletions
+13 -2
View File
@@ -30,10 +30,20 @@ char* TokenStringify(const struct _token* token) {
return str;
}
else if (token->Type == Symbol) {
bufferSize = strlen(token->Value.String) + 1;
// Add three for 2 backticks and a NUL byte.
bufferSize = strlen(token->Value.String) + 3;
str = calloc(bufferSize, sizeof(char));
strncpy(str, token->Value.String, bufferSize);
snprintf(str, bufferSize, "`%s`", token->Value.String);
return str;
}
else if (token->Type == Label) {
// Add 2 for the colon and Nul byte.
bufferSize = strlen(token->Value.String) + 2;
str = calloc(bufferSize, sizeof(char));
snprintf(str, bufferSize, "%s:", token->Value.String);
return str;
}
@@ -63,6 +73,7 @@ char* TokenStringify(const struct _token* token) {
strcpy(str, "(LineEnd)");
break;
case FileEnd:
strcpy(str, "(FileEnd)");
break;
default:
sprintf(str, "%s", token->Value.Operator);