|
BFC-Compiler
A C23 Brainfuck compiler
|
Compiler error values and diagnostics. More...
#include "bfc_token.h"Go to the source code of this file.
Data Structures | |
| struct | bfc_error_t |
| Error value propagated through compiler stages. More... | |
Macros | |
| #define | COL_OFF "\033[m" |
| #define | COL_INFO "\033[1;1m" |
| #define | COL_ERROR "\033[1;31m" |
| #define | ERROR_LIST |
| Single source of truth for compiler error codes. | |
| #define | X(name) |
| #define | BFC_ERR_OK ((bfc_error_t) {.code = ERR_OK, .msg = {0}, .token = {0}}) |
| #define | BFC_ERR_ALLOC ((bfc_error_t) {.code = ERR_ALLOC, .msg = "Memory allocation failure!", .token = {0}}) |
Enumerations | |
| enum | bfc_err_code_t { ERROR_LIST } |
Functions | |
| bfc_error_t | bfc_make_errorf (bfc_err_code_t error_code, const char *format,...) |
| Creates an error using printf-style formatting. | |
| 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. | |
| 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. | |
| 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. | |
| char const * | bfc_get_error_code (bfc_err_code_t const error_code) |
| Returns the symbolic name of an error code. | |
| void | bfc_log_error (bfc_error_t err, const struct bfc_program_t *program) |
| Prints a user-facing compiler diagnostic to standard error. | |
Compiler error values and diagnostics.
Defines error codes, formatted error constructors, source-associated errors, and user-facing diagnostic output.
| #define ERROR_LIST |
Single source of truth for compiler error codes.
| #define X | ( | name | ) |
|
nodiscard |
Returns the symbolic name of an error code.
Maps an error enumeration value to its symbolic name.
Returns the symbolic name of an error code.
| void bfc_log_error | ( | bfc_error_t const | err, |
| const struct bfc_program_t *const | program ) |
Prints a user-facing compiler diagnostic to standard error.
Prints a colourized diagnostic and optional source-line context.
| [in] | err | Error to report. |
| [in] | program | Loaded source program, used for source-context diagnostics. |
Prints a user-facing compiler diagnostic to standard error.
| 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.
Builds an error by copying a plain message.
Creates an error by copying an existing message string.
| 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.
Builds a token-associated error by copying a plain message.
Creates a token-associated error by copying an existing message string.
| bfc_error_t bfc_make_errorf | ( | bfc_err_code_t | error_code, |
| const char * | format, | ||
| ... ) |
Creates an error using printf-style formatting.
Builds a formatted error without source-token context.
| [in] | error_code | Error category. |
| [in] | format | Format string followed by matching arguments. |
Creates an error using printf-style formatting.
| 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.
Builds a formatted error associated with a source token.
| [in] | error_code | Error category. |
| [in] | token | Source token associated with the failure. |
| [in] | format | Format string followed by matching arguments. |
Creates a source-associated formatted error.