diff --git a/dlang.sqlite/dlang/libs/regex.hpp b/dlang.sqlite/dlang/libs/regex.hpp index fbdb7a5..ee14f90 100644 --- a/dlang.sqlite/dlang/libs/regex.hpp +++ b/dlang.sqlite/dlang/libs/regex.hpp @@ -14,10 +14,10 @@ static void NativeRegexMatch(DlangVM* vm) try { std::regex rx(pattern); bool matched = std::regex_match(text, rx); - dlang_pushnumber(vm, matched ? 1.0 : 0.0); + dlang_pushboolean(vm, matched); } catch (...) { - dlang_pushnumber(vm, 0.0); + dlang_pushboolean(vm, false); } } @@ -29,10 +29,10 @@ static void NativeRegexSearch(DlangVM* vm) try { std::regex rx(pattern); bool found = std::regex_search(text, rx); - dlang_pushnumber(vm, found ? 1.0 : 0.0); + dlang_pushboolean(vm, found); } catch (...) { - dlang_pushnumber(vm, 0.0); + dlang_pushboolean(vm, false); } } @@ -45,6 +45,7 @@ static void NativeRegexReplace(DlangVM* vm) try { std::regex rx(pattern); std::string result = std::regex_replace(text, rx, fmt); + dlang_pushstring(vm, result); dlang_pushindex(vm); } diff --git a/dlang.sqlite/dlang/libs/string.hpp b/dlang.sqlite/dlang/libs/string.hpp index 7e15e0b..6961878 100644 --- a/dlang.sqlite/dlang/libs/string.hpp +++ b/dlang.sqlite/dlang/libs/string.hpp @@ -143,4 +143,4 @@ inline void openlib_string(DlangVM* vm) dlang_setglobal(vm, "string"); } -#endif \ No newline at end of file +#endif diff --git a/dlang.sqlite/dlang/src/parser.cpp b/dlang.sqlite/dlang/src/parser.cpp index e9146f9..813978c 100644 --- a/dlang.sqlite/dlang/src/parser.cpp +++ b/dlang.sqlite/dlang/src/parser.cpp @@ -46,10 +46,13 @@ Token& Parser::ShouldBe(TokenType type, const std::string& value) const auto& current = Current(); if (current.type != type) - throw std::runtime_error("Unexpected type '" + std::string(TokenTypeToString(current.type)) + "' where '" + std::string(TokenTypeToString(type)) + "' should be " + LocationText(current)); + throw std::runtime_error("Syntax Error: Expected token type '" + std::string(TokenTypeToString(type)) + + "' but got '" + std::string(TokenTypeToString(current.type)) + + "' (value: '" + current.value + "') " + LocationText(current)); - if(!value.empty() && value != current.value) - throw std::runtime_error("Unexpected value '" + current.value + "' where '" + value + "' should be " + LocationText(current)); + if (!value.empty() && value != current.value) + throw std::runtime_error("Syntax Error: Expected specific value '" + value + + "' but got '" + current.value + "' " + LocationText(current)); return Consume(); } @@ -481,7 +484,11 @@ std::unique_ptr Parser::ParsePrimary() return left; } - throw std::runtime_error("Expected expression " + LocationText(current)); + std::string tokenDesc = std::string(TokenTypeToString(current.type)); + if (!current.value.empty()) { + tokenDesc += " ('" + current.value + "')"; + } + throw std::runtime_error("Expected expression, but found unexpected token type " + tokenDesc + " " + LocationText(current)); } std::unique_ptr Parser::ParseMultiplicative() diff --git a/dlang.sqlite/dlang/src/vm.cpp b/dlang.sqlite/dlang/src/vm.cpp index 24c845b..6e223c2 100644 --- a/dlang.sqlite/dlang/src/vm.cpp +++ b/dlang.sqlite/dlang/src/vm.cpp @@ -545,6 +545,9 @@ StackValue DlangVM::GetField(const std::string& key, bool popTable) return it->second; } + + printf("Cant get field on non table type %s!\n", StackValueTypeToString(stackTable.type).c_str()); + return StackValue(); } StackValue DlangVM::GetTableKeys() diff --git a/dlang.sqlite/dlang/vm.hpp b/dlang.sqlite/dlang/vm.hpp index 6cc2980..0986f6b 100644 --- a/dlang.sqlite/dlang/vm.hpp +++ b/dlang.sqlite/dlang/vm.hpp @@ -12,7 +12,7 @@ inline ModuleManager* pluginManager = nullptr; #define DEBUG_MODE 1 -#define VERSION "{DEVBUILD}" +#define VERSION "v1.0.29" using ByteCodeArray = std::vector;