From 31deaea2668e29c4ac23a10b2c83ea07cc9afc1d Mon Sep 17 00:00:00 2001 From: Max Wash Date: Thu, 8 May 2025 22:33:18 +0100 Subject: [PATCH] frontend: update parser api usage with diagnostic support --- frontend/cmd/compile.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/cmd/compile.c b/frontend/cmd/compile.c index dc2db36..8347607 100644 --- a/frontend/cmd/compile.c +++ b/frontend/cmd/compile.c @@ -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)",