The Scanner will now check for empty lines (is the previous token and the current token a new line?) and simply not emit a NewLine Token.

This commit is contained in:
2022-10-03 19:40:00 +00:00
parent a949007c75
commit 706f480e31
2 changed files with 17 additions and 2 deletions
+10
View File
@@ -42,6 +42,16 @@ List* GenerateTokenList(const char* source) {
AdvanceScanner();
break; //Ignore whitespace
case '\n':
if (tokens->size > 0) {
token = tokens->content[tokens->size - 1];
if (token->Class == PunctuationClass && token->Value.Punctuation == NewLine) {
AdvanceScanner();
Line++;
continue;
}
}
token = CreateToken(Line, PunctuationClass);
token->Value.Punctuation = NewLine;
AddListItem(token, sizeof(Token), tokens);