Files
ivy/lang/diag.c

27 lines
919 B
C
Raw Normal View History

2025-05-08 20:31:28 +01:00
#include <ivy/diag.h>
#include <ivy/lang/diag.h>
#define ERROR_CLASS(id, title) \
[id] = {.c_type = IVY_DIAG_ERROR, .c_title = (title)}
#define MSG(id, content) [id] = {.msg_content = (content)}
static const struct ivy_diag_class diag_classes[] = {
ERROR_CLASS(IVY_LANG_E_UNRECOGNISED_SYMBOL, "Unrecognised symbol"),
};
static const size_t nr_diag_classes = sizeof diag_classes / sizeof diag_classes[0];
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."),
};
static const size_t nr_diag_msg = sizeof diag_msg / sizeof diag_msg[0];
enum ivy_status ivy_lang_diag_ctx_init(struct ivy_diag_ctx *ctx)
{
ivy_diag_ctx_set_class_definitions(ctx, diag_classes, nr_diag_msg);
ivy_diag_ctx_set_msg_definitions(ctx, diag_msg, nr_diag_msg);
return IVY_OK;
}