Added a LineEnd token type.
This commit is contained in:
+13
-7
@@ -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);
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user