diff --git a/src/main.c b/src/main.c index db5afcb..b65d46f 100644 --- a/src/main.c +++ b/src/main.c @@ -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); diff --git a/src/scanner.c b/src/scanner.c index b28202f..93a0164 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -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);