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:
@@ -266,7 +266,8 @@ pair<token_t, lerr_t> tokenise_literal_char(string_view &source, size_t &column,
|
|||||||
size_t &line)
|
size_t &line)
|
||||||
{
|
{
|
||||||
token_t t{};
|
token_t t{};
|
||||||
if (source.size() < 3)
|
auto end = source.find('\'', 1);
|
||||||
|
if (source.size() < 3 || end == 1 || end > 3)
|
||||||
return make_pair(t,
|
return make_pair(t,
|
||||||
lerr_t(lerr_type_t::INVALID_CHAR_LITERAL, column, line));
|
lerr_t(lerr_type_t::INVALID_CHAR_LITERAL, column, line));
|
||||||
else if (source[1] == '\\')
|
else if (source[1] == '\\')
|
||||||
|
|||||||
Reference in New Issue
Block a user