Fixed a bug with the Scanner adding a blank line via a single NewLine Token when a file starts with a block of comments.

This commit is contained in:
2022-10-01 20:43:55 -05:00
parent 984683bfc5
commit 097eca383b
2 changed files with 16 additions and 4 deletions
+13 -1
View File
@@ -3,7 +3,7 @@
#include <string.h>
const char* SourceCode;
int Line = 0;
int Line = 1;
int Position = 0;
int SourceLength = 0;
int ScannerAtEnd(void);
@@ -45,6 +45,12 @@ List* GenerateTokenList(const char* source) {
break;
case ';':
IgnoreLine();
if (tokens->size == 0) {
//There's nothing here so that means this is some comments block at the start of the file.
AdvanceScanner(); //Consume the actual new line char.
Line++;
}
break;
case '.': //directive like ".org" or ".db"
token = ParseDirective();
@@ -77,6 +83,12 @@ List* GenerateTokenList(const char* source) {
token = NULL;
}
token = CreateToken(Line, PunctuationClass);
token->EndOfFile = 1;
AddListItem(token, sizeof(Token), tokens);
return tokens;
}