mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add Lua code tokenizer
This commit is contained in:
parent
3e6e897ce8
commit
28f49ac948
5 changed files with 256 additions and 0 deletions
|
|
@ -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') {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue