13#define COL_OFF "\033[m"
14#define COL_INFO "\033[1;1m"
15#define COL_ERROR "\033[1;31m"
24 X(ERR_MISMATCHED_BRACKET) \
25 X(ERR_MISSING_BRACKET) \
41typedef struct [[nodiscard(
"bfc_error_t result must be checked")]]
48#define BFC_ERR_OK ((bfc_error_t) {.code = ERR_OK, .msg = {0}, .token = {0}})
50#define BFC_ERR_ALLOC \
51 ((bfc_error_t) {.code = ERR_ALLOC, .msg = "Memory allocation failure!", .token = {0}})
63[[gnu::nonnull(2), gnu::format(printf, 2, 3)]]
75[[gnu::nonnull(3), gnu::format(printf, 3, 4)]]
88 bfc_err_code_t
const error_code,
98[[nodiscard, gnu::const, gnu::returns_nonnull]]
bfc_error_t bfc_make_errorf(bfc_err_code_t error_code, const char *format,...)
Creates an error using printf-style formatting.
Definition bfc_error.c:22
bfc_error_t bfc_make_errorf_with_token(bfc_err_code_t error_code, bfc_token_t token, const char *format,...)
Creates a source-associated formatted error.
Definition bfc_error.c:42
#define ERROR_LIST
Single source of truth for compiler error codes.
Definition bfc_error.h:20
bfc_error_t bfc_make_error_with_token(bfc_err_code_t const error_code, char const *msg, bfc_token_t const token)
Creates a token-associated error by copying an existing message string.
Definition bfc_error.c:80
void bfc_log_error(bfc_error_t err, const struct bfc_program_t *program)
Prints a user-facing compiler diagnostic to standard error.
Definition bfc_error.c:120
bfc_error_t bfc_make_error(bfc_err_code_t const error_code, char const *msg)
Creates an error by copying an existing message string.
Definition bfc_error.c:62
char const * bfc_get_error_code(bfc_err_code_t const error_code)
Returns the symbolic name of an error code.
Definition bfc_error.c:98
Brainfuck token definitions and token-stream ownership.
Error value propagated through compiler stages.
Definition bfc_error.h:42
Owning representation of a loaded source file.
Definition bfc_io.h:21
One Brainfuck token and its one-based source location.
Definition bfc_token.h:41