the hito embeddable programming language
at main 46 lines 868 B view raw
1#ifndef error_h 2#define error_h 3#include "source.h" 4typedef enum { 5 ERROR_UNRECOGNISED_TOKEN, 6 ERROR_UNTERMINATED_STRING_LITERAL, 7 ERROR_PARSE_ERROR, 8 ERROR_EXPECTED_RPAREN, 9 ERROR_EXPECTED_RBRACE, 10 ERROR_EXPECTED_EXPRESSION, 11 ERROR_INVALID_PATTERN, 12 ERROR_EXPECTED_SEMI, 13 ERROR_UNKNOWN_VARIABLE, 14 WARNING 15} error_tag; 16 17typedef struct { 18 error_tag tag; 19 source_t *source; 20 pos_t position; 21 int highlight_len; 22} error_t; 23 24static inline error_t error(error_tag tag, source_t *source, pos_t position, 25 int highlight_len) { 26 error_t it = { 27 .tag = tag, 28 .source = source, 29 .position = position, 30 .highlight_len = highlight_len 31 }; 32 return it; 33} 34char* error_tag_human_readable(error_tag err_tag); 35 36void error_set_handler(void (*eh)(error_t err)); 37void error_default_handler(error_t err); 38 39void error_report(error_t error); 40 41 42 43 44#endif 45 46