diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-14 17:02:45 +0630 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-04-14 17:02:45 +0630 |
commit | 7a9e646d396cf8c4abbadb6e6df208bb96cd070c (patch) | |
tree | d3ee04cf21000b4f431d803113cf6bb28fe298ed /asm | |
parent | 50e9a4eef52a1123fd9eebcb9d0de483b79be061 (diff) | |
download | ovm-7a9e646d396cf8c4abbadb6e6df208bb96cd070c.tar.gz ovm-7a9e646d396cf8c4abbadb6e6df208bb96cd070c.tar.bz2 ovm-7a9e646d396cf8c4abbadb6e6df208bb96cd070c.zip |
Implemented tokenise_literal_string
One thing I've realised is that even methods such as this require
error tracking. I won't implement it in the tokenise method as it's
not related to consuming the string per se but instead in the main method.
Diffstat (limited to 'asm')
-rw-r--r-- | asm/lexer.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/asm/lexer.cpp b/asm/lexer.cpp index 2bf7169..760f8db 100644 --- a/asm/lexer.cpp +++ b/asm/lexer.cpp @@ -296,3 +296,13 @@ pair<token_t, lerr_t> tokenise_literal_char(string_view &source, size_t &column) } return make_pair(t, lerr_t::OK); } + +token_t tokenise_literal_string(string_view &source, size_t &column, size_t end) +{ + source.remove_prefix(1); + token_t token{token_type_t::LITERAL_STRING, string(source.substr(1, end - 1)), + column}; + source.remove_prefix(end); + column += end + 1; + return token; +} |