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:
+13
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user