Lexical error on char literal being too big or too small

This is actually an improvement on the older lexer.
This commit is contained in:
2024-04-15 16:29:42 +06:30
parent a2d98142d5
commit 175138f570

View File

@@ -266,7 +266,8 @@ pair<token_t, lerr_t> 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] == '\\')