Exit the program if there were errors found
This commit is contained in:
parent
44beccfd06
commit
12f70b1a88
2 changed files with 9 additions and 3 deletions
|
@ -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);
|
unsigned int *label_addr = shash_get(tokens[i], strlen(tokens[i]), &label_table);
|
||||||
if(label_addr == NULL)
|
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 ;
|
// Check that the next token is a ;
|
||||||
|
|
|
@ -163,8 +163,13 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
// Check if the EIPA Assembly contains errors with the no_label_definition_tokens array
|
// Check if the EIPA Assembly contains errors with the no_label_definition_tokens array
|
||||||
shash_hashtable_t instruction_informations = create_instruction_information_hastable();
|
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
|
// Part II of processing labels
|
||||||
dynamic_buffer_t tokens;
|
dynamic_buffer_t tokens;
|
||||||
init_dynamic_buffer(&tokens, TABLE_INIT_SIZE * MAX_TOKEN_SIZE, TABLE_GROW_SIZE * MAX_TOKEN_SIZE);
|
init_dynamic_buffer(&tokens, TABLE_INIT_SIZE * MAX_TOKEN_SIZE, TABLE_GROW_SIZE * MAX_TOKEN_SIZE);
|
||||||
|
|
Loading…
Reference in a new issue