Reworked the tokens to include a broad class to make parameter matching a bit easier, and removed the hexadecimal distinction.

This commit is contained in:
2022-05-12 20:26:14 +00:00
parent 72abf6c4ab
commit 72525959f6
6 changed files with 94 additions and 34 deletions
+3 -7
View File
@@ -79,13 +79,11 @@ List* GenerateTokenList(const char* source) {
Token* ParseNumber(void) {
int start = Position;
int base = 10;
while(!ScannerAtEnd() && isdigit(PeekScanner()))
AdvanceScanner();
if (PeekScanner() == 'x' && isdigit(PeekAheadScanner())) {
base = 16;
AdvanceScanner(); //Consume the 'x'
while(!ScannerAtEnd() && isdigit(PeekScanner())) AdvanceScanner();
}
@@ -109,12 +107,10 @@ Token* ParseNumber(void) {
}
memcpy(lexeme, &SourceCode[start], length);
*value = strtol(lexeme, NULL, base);
// Setting the base to zero means the function will pick the base.
*value = strtol(lexeme, NULL, 0);
if (base == 10) return CreateToken(lexeme, value, Line, NUMBER);
return CreateToken(lexeme, value, Line, HEX);
return CreateToken(lexeme, value, Line, NUMBER);
}
Token* ParseDirective(void) {