Put the printing of the tokens in seperate function
This commit is contained in:
parent
5df69eed01
commit
a4ad6f629c
1 changed files with 12 additions and 8 deletions
20
main.c
20
main.c
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue