Add EOF at end of tokens
This commit is contained in:
parent
b60b9a4200
commit
5df69eed01
1 changed files with 7 additions and 16 deletions
23
main.c
23
main.c
|
@ -23,20 +23,6 @@
|
|||
|
||||
#define PREFGETC(file) *file->_IO_read_ptr
|
||||
|
||||
int saveinstructionpart(unsigned short int part, char content[])
|
||||
{
|
||||
// strcat(content,"\0"); //REMOVE
|
||||
if (part == INSTRUCTION_OPERATION)
|
||||
{
|
||||
printf("Operation: %s\n", content);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Adress: %s\n", content);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tokenize(FILE *input_file, char tokens[][MAX_TOKEN_SIZE])
|
||||
{
|
||||
char current_char = 0;
|
||||
|
@ -91,6 +77,7 @@ void tokenize(FILE *input_file, char tokens[][MAX_TOKEN_SIZE])
|
|||
}
|
||||
}
|
||||
tokens[token_index + 1][0] = ';';
|
||||
tokens[token_index + 2][0] = EOF;
|
||||
}
|
||||
|
||||
int main(int argc, char const *argv[])
|
||||
|
@ -112,9 +99,13 @@ int main(int argc, char const *argv[])
|
|||
|
||||
char(*tokens)[MAX_TOKEN_SIZE] = malloc(sizeof(*tokens) * MAX_MEMORY);
|
||||
tokenize(assembly_file, tokens);
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
printf("%s\n", tokens[i]);
|
||||
int i = 0;
|
||||
while(tokens[i][0] != EOF)
|
||||
{
|
||||
printf("%s\n",tokens[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
fclose(assembly_file);
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue