Fix error where it would show wrong function in error

This commit is contained in:
Krzosa Karol
2022-09-28 10:49:48 +02:00
parent 1fa5e1a26b
commit 0050abe190
6 changed files with 67 additions and 34 deletions

View File

@@ -30,21 +30,42 @@ print_token_context(Token *token){
print_token_line(token);
}
function void
compiler_error(Token *token1, Token *token2, const char *str, ...){
Scratch scratch;
STRING_FMT(scratch, str, string);
printf("\n%s", string.str);
if(token1){
if(token1->kind == TK_Error){
printf("\nToken Error: %.*s", (int)token1->error_val.len, token1->error_val.str);
}
print_token_context(token1);
}
if(token2){
if(token2->kind == TK_Error){
printf("\nToken Error: %.*s", (int)token2->error_val.len, token2->error_val.str);
}
print_token_context(token2);
}
__debugbreak();
}
function void
compiler_error(Token *token, const char *str, ...){
Scratch scratch;
STRING_FMT(scratch, str, string);
// @Note(Krzosa): Print nice error message
printf("\nError :: %s", string.str);
printf("\n%s", string.str);
if(token){
if(token->kind == TK_Error){
printf("Token Error: %.*s", (int)token->error_val.len, token->error_val.str);
printf("\nToken Error: %.*s", (int)token->error_val.len, token->error_val.str);
}
print_token_context(token);
}
__debugbreak();
}