From a2d98142d5c7d8678651692ba34d0f803317fef8 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 15 Apr 2024 16:28:51 +0630 Subject: 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. --- asm/lexer.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'asm/lexer.hpp') diff --git a/asm/lexer.hpp b/asm/lexer.hpp index c74228f..c361f32 100644 --- a/asm/lexer.hpp +++ b/asm/lexer.hpp @@ -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 &); -- cgit v1.2.3-13-gbd6f