Added a LineEnd token type.

This commit is contained in:
2022-08-25 18:37:25 +00:00
parent 89ab951c6a
commit 64326937b1
3 changed files with 16 additions and 7 deletions
+1
View File
@@ -21,6 +21,7 @@ typedef enum {
IDENTIFIER, IDENTIFIER,
LABEL, LABEL,
NUMBER, NUMBER,
LineEnd,
//Keywords //Keywords
DB, ORG, DB, ORG,
//Opcodes //Opcodes
+13 -7
View File
@@ -20,15 +20,21 @@ int main(int argc, char* args[]) {
List* list = GenerateTokenList(source_code); List* list = GenerateTokenList(source_code);
// for(int i = 0; i < list->size; i++) { for(int i = 0; i < list->size; i++) {
// Token* t = (Token*) list->content[i]; Token* t = (Token*) list->content[i];
// printf("[%i] '%s' [%i]", t->type, t->lexeme, t->token_class); if (t->type == LineEnd) {
// if (t->type == LABEL) printf("*"); if (i - 1 >= 0 && ((Token*) list->content[i - 1])->type != LineEnd)
// printf("\n"); 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); free(source_code);
} }
+2
View File
@@ -37,6 +37,8 @@ List* GenerateTokenList(const char* source) {
AdvanceScanner(); AdvanceScanner();
break; //Ignore whitespace break; //Ignore whitespace
case '\n': case '\n':
token = CreateToken("^", NULL, Line, LineEnd);
AddListItem(token, sizeof(Token), tokens);
AdvanceScanner(); AdvanceScanner();
Line++; Line++;
break; break;