diff --git a/includes/token.h b/includes/token.h index 44e6efe..6c0e261 100644 --- a/includes/token.h +++ b/includes/token.h @@ -21,6 +21,7 @@ typedef enum { IDENTIFIER, LABEL, NUMBER, + LineEnd, //Keywords DB, ORG, //Opcodes diff --git a/src/main.c b/src/main.c index 536d731..f9c145e 100644 --- a/src/main.c +++ b/src/main.c @@ -20,15 +20,21 @@ int main(int argc, char* args[]) { List* list = GenerateTokenList(source_code); - // for(int i = 0; i < list->size; i++) { - // Token* t = (Token*) list->content[i]; + for(int i = 0; i < list->size; i++) { + Token* t = (Token*) list->content[i]; - // printf("[%i] '%s' [%i]", t->type, t->lexeme, t->token_class); - // if (t->type == LABEL) printf("*"); - // printf("\n"); - // } + if (t->type == LineEnd) { + if (i - 1 >= 0 && ((Token*) list->content[i - 1])->type != LineEnd) + printf("\n"); + + continue; + } - ParseTokens(list); + printf("[%i] '%s' [%i] ", t->type, t->lexeme, t->token_class); + if (t->type == LABEL) printf("* "); + } + + //ParseTokens(list); free(source_code); } \ No newline at end of file diff --git a/src/scanner.c b/src/scanner.c index f21370f..c65ceff 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -37,6 +37,8 @@ List* GenerateTokenList(const char* source) { AdvanceScanner(); break; //Ignore whitespace case '\n': + token = CreateToken("^", NULL, Line, LineEnd); + AddListItem(token, sizeof(Token), tokens); AdvanceScanner(); Line++; break;