frontend: update parser api usage with diagnostic support

This commit is contained in:
2025-05-08 22:33:18 +01:00
parent 8c703199cf
commit 31deaea266

View File

@@ -98,6 +98,8 @@ static int compile_file(const char *path, const b_arglist *args)
return -1;
}
ivy_parser_set_diag_ctx(parser, diag);
struct mie_ctx *ctx = mie_ctx_create();
struct ivy_codegen *codegen;
@@ -135,6 +137,13 @@ static int compile_file(const char *path, const b_arglist *args)
status = ivy_parser_push_token(parser, tok);
if (status == IVY_ERR_BAD_SYNTAX) {
ivy_diag_ctx_write(
diag, IVY_DIAG_FORMAT_PRETTY, &diag_stream);
ivy_token_destroy(tok);
break;
}
if (status != IVY_OK) {
b_err("failed to parse '%s'", path);
b_i("reason: parse error (%s)",