|
Reduct
v4.0.5-1-g4851deb
A functional and immutable language.
|
Data Structures | |
| struct | reduct_error_frame_t |
| Backtrace frame structure. More... | |
| struct | reduct_error_t |
| Error structure. More... | |
Macros | |
| #define | REDUCT_ERROR_MAX_LEN 128 |
| Maximum length of an error string. | |
| #define | REDUCT_ERROR_BACKTRACE_MAX 8 |
| Maximum number of backtrace frames. | |
| #define | REDUCT_ERROR() ((reduct_error_t){0}) |
| Create a Reduct error structure. | |
| #define | REDUCT_ERROR_GENERIC(_reduct, _error, _item, _type, ...) |
| Throw an error using the jump buffer in the error structure. | |
| #define | REDUCT_ERROR_SUCCESS(_error) ((_error)->type == REDUCT_ERROR_TYPE_NONE) |
| Check if an error structure indicates a successful operation. | |
| #define | REDUCT_ERROR_CATCH(_error) (setjmp((_error)->jmp)) |
| Catch an error using the jump buffer in the error structure. | |
| #define | REDUCT_ERROR_TRY(_reduct, _error) |
| Execute a block of code safely, catching any Reduct errors. | |
| #define | REDUCT_ERROR_THROW(_reduct, ...) reduct_error_throw_runtime((_reduct), __VA_ARGS__) |
| Throw a runtime error using the jump buffer in the error structure. | |
| #define | REDUCT_ERROR_RETHROW(_reduct, _error) REDUCT_ERROR_THROW(_reduct, "%s", (_error)->message); |
| Rethrow an existing error. | |
| #define | REDUCT_ERROR_ASSERT(_reduct, _expr, ...) |
| Throw a runtime error if the expression is false. | |
| #define | REDUCT_ERROR_SYNTAX(_error, _input, _ptr, ...) |
| Throw a syntax error using the jump buffer in the error structure. | |
| #define | REDUCT_ERROR_COMPILE(_compiler, _handle, ...) |
| Throw a compile error using the jump buffer in the error structure. | |
| #define | REDUCT_ERROR_COMPILE_LAST(_compiler, ...) |
| Throw a compile error using the jump buffer in the error structure using the last item process by the compiler. | |
| #define | REDUCT_ERROR_COMPILE_ASSERT(_compiler, _expr, ...) |
| Throw a compile error if the expression is false. | |
| #define | REDUCT_ERROR_INTERNAL(_reduct, ...) REDUCT_ERROR_GENERIC(_reduct, (_reduct)->error, NULL, INTERNAL, __VA_ARGS__) |
| Throw an internal error using the jump buffer in the error structure. | |
Enumerations | |
| enum | reduct_error_type_t { REDUCT_ERROR_TYPE_NONE , REDUCT_ERROR_TYPE_SYNTAX , REDUCT_ERROR_TYPE_COMPILE , REDUCT_ERROR_TYPE_RUNTIME , REDUCT_ERROR_TYPE_INTERNAL } |
| Error type enumeration. More... | |
Functions | |
| REDUCT_API void | reduct_error_print (reduct_error_t *error, FILE *file) |
| Format and print the error to a file. | |
| REDUCT_API void | reduct_error_get_row_column (reduct_error_t *error, size_t *row, size_t *column) |
| Get the row and column by traversing the input buffer. | |
| REDUCT_API void | reduct_error_set (reduct_error_t *error, const char *path, const char *input, size_t inputLength, size_t regionLength, size_t position, reduct_error_type_t type, const char *message,...) |
| Set the error information in the error structure. | |
| REDUCT_API void | reduct_error_get_item_params (struct reduct *reduct, struct reduct_item *item, const char **path, const char **input, size_t *inputLength, size_t *regionLength, size_t *position) |
| Get the error parameters from a Reduct item. | |
| REDUCT_API REDUCT_NORETURN void | reduct_error_throw_runtime (struct reduct *reduct, const char *message,...) |
| Throw a runtime error utilizing the evaluation state to determine the context. | |
| REDUCT_API void | reduct_error_push (struct reduct *reduct, reduct_error_t *error) |
| Push a new error handler onto the stack. | |
| REDUCT_API void | reduct_error_pop (struct reduct *reduct) |
| Pop the current error handler from the stack. | |
| #define REDUCT_ERROR_MAX_LEN 128 |
| #define REDUCT_ERROR_BACKTRACE_MAX 8 |
| #define REDUCT_ERROR | ( | ) | ((reduct_error_t){0}) |
| #define REDUCT_ERROR_GENERIC | ( | _reduct, | |
| _error, | |||
| _item, | |||
| _type, | |||
| ... | |||
| ) |
Throw an error using the jump buffer in the error structure.
| _reduct | Pointer to the Reduct structure. |
| _error | Pointer to the error structure. |
| _item | Pointer to the item that caused the error. |
| _type | The suffix of the error type (e.g., INTERNAL, RUNTIME, etc.). |
| ... | The error message format string and any optional arguments. |
| #define REDUCT_ERROR_SUCCESS | ( | _error | ) | ((_error)->type == REDUCT_ERROR_TYPE_NONE) |
| #define REDUCT_ERROR_CATCH | ( | _error | ) | (setjmp((_error)->jmp)) |
| #define REDUCT_ERROR_TRY | ( | _reduct, | |
| _error | |||
| ) |
Execute a block of code safely, catching any Reduct errors.
return, break, continue, or goto to exit the block, as it will skip the necessary error stack cleanup. Use a status variable instead.| _reduct | Pointer to the Reduct structure. |
| _error | Pointer to the error structure. |
| #define REDUCT_ERROR_THROW | ( | _reduct, | |
| ... | |||
| ) | reduct_error_throw_runtime((_reduct), __VA_ARGS__) |
| #define REDUCT_ERROR_RETHROW | ( | _reduct, | |
| _error | |||
| ) | REDUCT_ERROR_THROW(_reduct, "%s", (_error)->message); |
| #define REDUCT_ERROR_ASSERT | ( | _reduct, | |
| _expr, | |||
| ... | |||
| ) |
Throw a runtime error if the expression is false.
| _reduct | Pointer to the Reduct structure. |
| _expr | The expression to check. |
| ... | The error message format string and any optional arguments. |
| #define REDUCT_ERROR_SYNTAX | ( | _error, | |
| _input, | |||
| _ptr, | |||
| ... | |||
| ) |
Throw a syntax error using the jump buffer in the error structure.
| _error | Pointer to the error structure. |
| _input | Pointer to the input structure being parsed. |
| _ptr | Pointer to the current position in the input buffer. |
| ... | The error message format string and any optional arguments. |
| #define REDUCT_ERROR_COMPILE | ( | _compiler, | |
| _handle, | |||
| ... | |||
| ) |
Throw a compile error using the jump buffer in the error structure.
| _compiler | The compiler instance. |
| _handle | Pointer to the handle that caused the error. |
| ... | The error message format string and any optional arguments. |
| #define REDUCT_ERROR_COMPILE_LAST | ( | _compiler, | |
| ... | |||
| ) |
Throw a compile error using the jump buffer in the error structure using the last item process by the compiler.
| _compiler | The compiler instance. |
| ... | The error message format string and any optional arguments. |
| #define REDUCT_ERROR_COMPILE_ASSERT | ( | _compiler, | |
| _expr, | |||
| ... | |||
| ) |
Throw a compile error if the expression is false.
| _compiler | The compiler instance. |
| _handle | Pointer to the handle that caused the error. |
| _expr | The expression to check. |
| ... | The error message format string and any optional arguments. |
| #define REDUCT_ERROR_INTERNAL | ( | _reduct, | |
| ... | |||
| ) | REDUCT_ERROR_GENERIC(_reduct, (_reduct)->error, NULL, INTERNAL, __VA_ARGS__) |
| enum reduct_error_type_t |
| REDUCT_API void reduct_error_print | ( | reduct_error_t * | error, |
| FILE * | file | ||
| ) |
Format and print the error to a file.
| error | Pointer to the error structure. |
| file | The file to print to. |
| REDUCT_API void reduct_error_get_row_column | ( | reduct_error_t * | error, |
| size_t * | row, | ||
| size_t * | column | ||
| ) |
Get the row and column by traversing the input buffer.
| error | Pointer to the error structure. |
| row | Pointer to the row variable. |
| column | Pointer to the column variable. |
| REDUCT_API void reduct_error_set | ( | reduct_error_t * | error, |
| const char * | path, | ||
| const char * | input, | ||
| size_t | inputLength, | ||
| size_t | regionLength, | ||
| size_t | position, | ||
| reduct_error_type_t | type, | ||
| const char * | message, | ||
| ... | |||
| ) |
Set the error information in the error structure.
| error | Pointer to the error structure. |
| path | The path to the file where the error occurred. |
| input | The input buffer where the error occurred. |
| inputLength | The total length of the input buffer. |
| regionLength | The length of the token/region that caused the error. |
| position | The position in the input buffer where the error occurred. |
| type | The type of the error. |
| message | The error message format string. |
| ... | The arguments for the format string. |
| REDUCT_API void reduct_error_get_item_params | ( | struct reduct * | reduct, |
| struct reduct_item * | item, | ||
| const char ** | path, | ||
| const char ** | input, | ||
| size_t * | inputLength, | ||
| size_t * | regionLength, | ||
| size_t * | position | ||
| ) |
Get the error parameters from a Reduct item.
| reduct | Pointer to the Reduct structure. |
| item | Pointer to the item. |
| path | Pointer to the path variable. |
| input | Pointer to the input variable. |
| inputLength | Pointer to the input length variable. |
| regionLength | Pointer to the region length variable. |
| position | Pointer to the position variable. |
| REDUCT_API REDUCT_NORETURN void reduct_error_throw_runtime | ( | struct reduct * | reduct, |
| const char * | message, | ||
| ... | |||
| ) |
Throw a runtime error utilizing the evaluation state to determine the context.
| reduct | Pointer to the Reduct structure. |
| message | The error message format string. |
| ... | Additional arguments. |
| REDUCT_API void reduct_error_push | ( | struct reduct * | reduct, |
| reduct_error_t * | error | ||
| ) |
Push a new error handler onto the stack.
This will cause the provided error handler to be called when an error occurs instead of the previous one.
| reduct | Pointer to the Reduct structure. |
| error | Pointer to the error structure to push. |
| REDUCT_API void reduct_error_pop | ( | struct reduct * | reduct | ) |
Pop the current error handler from the stack.
| reduct | Pointer to the Reduct structure. |