diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-15 16:29:42 +0630 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-15 16:29:42 +0630 |
commit | 175138f570120c60702562eb17a9772927836e10 (patch) | |
tree | 233031585017259667b46218246c0d9ece674f3f /asm/lexer.cpp | |
parent | a2d98142d5c7d8678651692ba34d0f803317fef8 (diff) | |
download | ovm-175138f570120c60702562eb17a9772927836e10.tar.gz ovm-175138f570120c60702562eb17a9772927836e10.tar.bz2 ovm-175138f570120c60702562eb17a9772927836e10.zip |
Lexical error on char literal being too big or too small
This is actually an improvement on the older lexer.
Diffstat (limited to 'asm/lexer.cpp')
-rw-r--r-- | asm/lexer.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
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<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] == '\\') |