Lots of work on the lua read-eval-print loop

This commit is contained in:
2026-05-21 18:41:09 -04:00
parent f7983b1f02
commit 2bfa3024f1
15 changed files with 70 additions and 120 deletions

View File

@@ -200,6 +200,24 @@ bool is_lua_comment(string_view s) {
return s.substr(start, 2) == "--";
}
bool is_possible_long_lua_expression(string_view s) {
read_space(s);
string_view id = read_lua_identifier(s);
if (id.empty()) return false;
if ((id == "function") || (id == "if") || (id == "while") || (id == "for") || (id == "repeat") || (id == "do")) return true;
if (id == "local")
{
read_space(s);
id = read_lua_identifier(s);
}
read_space(s);
read_prefix(s, "="); // If not present, returns false but we continue anyway.
read_space(s);
if (has_prefix(s, "[")) return true;
if (has_prefix(s, "(")) return true;
return false;
}
bool is_whitespace(string_view s) {
for (int i = 0; i < int(s.size()); i++) {
if (!ascii_isspace(s[i])) {