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
+3 -3
View File
@@ -78,8 +78,8 @@
\section{STOW (Store Machine Word)}
\OpcodeTable{0x20}{stow}{Register}{Address}\\[6pt]
Stores a machine word from a register to a memory address.
\section{LA (Load Address)}
\OpcodeTable{0x00}{la}{Register}{Address}\\[6pt]
\section{LAA (Load Absolute Address)}
\OpcodeTable{0x00}{laa}{Register}{Address}\\[6pt]
Loads an address (2 bytes) into the register.
\section{LODB (Load Byte)}
\OpcodeTable{0x20}{lodb}{Register}{Register}\\[6pt]
@@ -140,5 +140,5 @@
Decrements the contents of the register by one. Under-flows will not be reported.
\section{NOP (No Operation)}
\OpcodeTable{0x00}{nop}{None}{None}\\[6pt]
Skips a clock cycle, incrementing the program counter by one.
Skips a clock cycle, incrementing the program counter.
\end{document}
+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;
}