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