Put the printing of the tokens in seperate function

This commit is contained in:
XOR 2023-01-04 16:00:03 +01:00
parent 5df69eed01
commit a4ad6f629c

20
main.c
View file

@ -80,6 +80,16 @@ void tokenize(FILE *input_file, char tokens[][MAX_TOKEN_SIZE])
tokens[token_index + 2][0] = EOF;
}
void printtokens(char tokens[][MAX_TOKEN_SIZE])
{
int i = 0;
while(tokens[i][0] != EOF)
{
printf("%s\n",tokens[i]);
i++;
}
}
int main(int argc, char const *argv[])
{
printf("-----------------\nEIPA Interpreter\nVersion: %d.%d.%d\n-----------------\n", VER_MAJOR, VER_MINOR, VER_PATCH);
@ -99,14 +109,8 @@ int main(int argc, char const *argv[])
char(*tokens)[MAX_TOKEN_SIZE] = malloc(sizeof(*tokens) * MAX_MEMORY);
tokenize(assembly_file, tokens);
{
int i = 0;
while(tokens[i][0] != EOF)
{
printf("%s\n",tokens[i]);
i++;
}
}
printtokens(tokens);
fclose(assembly_file);
return 0;
}