lerr_t is now a struct with constructors

Similar principle to pp_err_t in that a structure provides the
opportunity for more information about the error such as location.
This commit is contained in:
2024-04-15 16:28:51 +06:30
parent ae3794c33e
commit a2d98142d5
2 changed files with 67 additions and 33 deletions

View File

@@ -80,7 +80,7 @@ struct token_t
std::ostream &operator<<(std::ostream &, token_t &);
enum class lerr_t
enum class lerr_type_t
{
OK = 0,
INVALID_CHAR_LITERAL,
@@ -88,8 +88,18 @@ enum class lerr_t
INVALID_STRING_LITERAL,
INVALID_NUMBER_LITERAL,
INVALID_PREPROCESSOR_DIRECTIVE,
UNKNOWN_CHAR,
};
const char *lerr_as_cstr(lerr_t);
struct lerr_t
{
size_t col, line;
lerr_type_t type;
lerr_t(lerr_type_t type = lerr_type_t::OK, size_t col = 0, size_t line = 0);
};
std::ostream &operator<<(std::ostream &, lerr_t &);
lerr_t tokenise_buffer(std::string_view, std::vector<token_t *> &);