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:
+7
-2
@@ -32,16 +32,20 @@ int main(int argc, char* args[]) {
|
||||
|
||||
if (t->Class == PunctuationClass){
|
||||
if(t->Value.Punctuation == NewLine) {
|
||||
if(i - 1 >= 0 && (((Token*)list->content[i - 1])->Class == PunctuationClass && ((Token*)list->content[i - 1])->Value.Punctuation == NewLine)) continue;
|
||||
//if(i - 1 >= 0 && (((Token*)list->content[i - 1])->Class == PunctuationClass && ((Token*)list->content[i - 1])->Value.Punctuation == NewLine)) continue;
|
||||
|
||||
printf("\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("<%d>", t->LineNumber);
|
||||
|
||||
printf("%c ", t->Value.Punctuation);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("<%d>", t->LineNumber);
|
||||
|
||||
if (t->Class == LabelClass) {
|
||||
printf("[L]%s* ", t->Lemexe);
|
||||
continue;
|
||||
@@ -78,7 +82,8 @@ int main(int argc, char* args[]) {
|
||||
}
|
||||
}
|
||||
|
||||
//IRState* image = ParseTokens(list);
|
||||
IRState* image = ParseTokens(list);
|
||||
//free(image);
|
||||
//Disassemble(image);
|
||||
//for(int i = 0; i < image->Opcodes->size; i++) {
|
||||
// printf("%d\n", ((IROpcode*) image->Opcodes->content[i])->Mnemonic);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user