From 175138f570120c60702562eb17a9772927836e10 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Mon, 15 Apr 2024 16:29:42 +0630 Subject: Lexical error on char literal being too big or too small This is actually an improvement on the older lexer. --- asm/lexer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/asm/lexer.cpp b/asm/lexer.cpp index 52ee111..361d9ef 100644 --- a/asm/lexer.cpp +++ b/asm/lexer.cpp @@ -266,7 +266,8 @@ pair tokenise_literal_char(string_view &source, size_t &column, size_t &line) { token_t t{}; - if (source.size() < 3) + auto end = source.find('\'', 1); + if (source.size() < 3 || end == 1 || end > 3) return make_pair(t, lerr_t(lerr_type_t::INVALID_CHAR_LITERAL, column, line)); else if (source[1] == '\\') -- cgit v1.2.3-13-gbd6f