Exit the program if there were errors found

This commit is contained in:
XOR 2023-09-30 18:17:17 +02:00
parent 44beccfd06
commit 12f70b1a88
2 changed files with 9 additions and 3 deletions

View file

@ -43,7 +43,8 @@ unsigned int check_token_errors(char tokens[][MAX_TOKEN_SIZE], shash_hashtable_t
unsigned int *label_addr = shash_get(tokens[i], strlen(tokens[i]), &label_table);
if(label_addr == NULL)
{
printf("ERROR: Label %s has not been defined (Used at token %d)\n", tokens[i], i);
printf("ERROR: Label %s has not been defined (Used at token %d)\n", tokens[i], i);
error_count++;
}
// Check that the next token is a ;

View file

@ -163,8 +163,13 @@ int main(int argc, char **argv)
// Check if the EIPA Assembly contains errors with the no_label_definition_tokens array
shash_hashtable_t instruction_informations = create_instruction_information_hastable();
printf("Found %d errors\n", check_token_errors((char (*)[MAX_TOKEN_SIZE]) no_label_definition_tokens.buffer, instruction_informations, label_table));
unsigned int error_c = check_token_errors((char (*)[MAX_TOKEN_SIZE]) no_label_definition_tokens.buffer, instruction_informations, label_table);
printf("Found %d errors\n", error_c);
if(error_c > 0)
{
return EXIT_FAILURE;
}
// Part II of processing labels
dynamic_buffer_t tokens;
init_dynamic_buffer(&tokens, TABLE_INIT_SIZE * MAX_TOKEN_SIZE, TABLE_GROW_SIZE * MAX_TOKEN_SIZE);