lang: diag: add some new diag codes and messages

This commit is contained in:
2025-09-08 15:48:38 +01:00
parent ea42f738df
commit 5ea544692b
2 changed files with 6 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
static const struct ivy_diag_class diag_classes[] = {
ERROR_CLASS(IVY_LANG_E_UNRECOGNISED_SYMBOL, "Unrecognised symbol"),
ERROR_CLASS(IVY_LANG_E_UNDEFINED_VARIABLE, "Undefined variable"),
ERROR_CLASS(
IVY_LANG_E_INCORRECT_INLINE_FOR_LOOP,
"Incorrect inline for-loop"),
@@ -17,6 +18,8 @@ static const size_t nr_diag_classes = sizeof diag_classes / sizeof diag_classes[
static const struct ivy_diag_msg diag_msg[] = {
MSG(IVY_LANG_MSG_UNKNOWN_SYMBOL_ENCOUNTERED,
"encountered a symbol that is not part of the Ivy syntax."),
MSG(IVY_LANG_MSG_ASSIGN_TO_UNDEFINED_VARIABLE,
"cannot use modify-and-assign operator on an undefined variable."),
MSG(IVY_LANG_MSG_DO_UNEXPECTED_IN_INLINE_FOR,
"`[yellow]do[reset]` is not used in inline for-loops."),
MSG(IVY_LANG_MSG_PREVIOUS_EXPRESSION_IS_FOR_BODY,

View File

@@ -8,14 +8,17 @@ struct ivy_diag_ctx;
enum ivy_lang_diag_code {
IVY_LANG_E_NONE = 0,
IVY_LANG_E_UNRECOGNISED_SYMBOL,
IVY_LANG_E_UNDEFINED_VARIABLE,
IVY_LANG_E_INCORRECT_INLINE_FOR_LOOP,
};
enum ivy_lang_diag_msg {
IVY_LANG_MSG_NONE = 0,
IVY_LANG_MSG_ASSIGN_TO_UNDEFINED_VARIABLE,
IVY_LANG_MSG_UNKNOWN_SYMBOL_ENCOUNTERED,
IVY_LANG_MSG_DO_UNEXPECTED_IN_INLINE_FOR,
IVY_LANG_MSG_PREVIOUS_EXPRESSION_IS_FOR_BODY,
IVY_LANG_MSG_DECLARE_GLOBAL_FOR_ASSIGNMENT,
};
IVY_API enum ivy_status ivy_lang_diag_ctx_init(struct ivy_diag_ctx *ctx);