add Lua code tokenizer

This commit is contained in:
MihailRis
2024-12-04 16:26:55 +03:00
parent 3e6e897ce8
commit 28f49ac948
5 changed files with 256 additions and 0 deletions
+18
View File
@@ -214,6 +214,24 @@ std::string_view BasicParser::readUntil(char c) {
return source.substr(start, pos - start);
}
std::string_view BasicParser::readUntil(std::string_view s) {
int start = pos;
size_t found = source.find(s, pos);
if (found == std::string::npos) {
throw error(util::quote(std::string(s))+" expected");
}
skip(found - pos);
return source.substr(start, pos - start);
}
std::string_view BasicParser::readUntilWhitespace() {
int start = pos;
while (hasNext() && !is_whitespace(source[pos])) {
pos++;
}
return source.substr(start, pos - start);
}
std::string_view BasicParser::readUntilEOL() {
int start = pos;
while (hasNext() && source[pos] != '\r' && source[pos] != '\n') {