diff --git a/modules/std.cpp b/modules/std.cpp index 1bfce77..0e5025d 100644 --- a/modules/std.cpp +++ b/modules/std.cpp @@ -37,6 +37,18 @@ public: (*env->globalScope)[std::get(args[0].data)] = std::make_shared(args[1]); return args[1]; } + static Variable del(SharedEnvironment env, Cmdargs& args) { + auto& scope = env->currScope(); + auto res = scope.find(std::get(args[0].data)); + if (res == scope.end()) { + throw exceptions::NoSuchVariable(); + } + scope.erase(res); + return Variable({ + Variable::id_null, + 0 + }); + } static Variable concat(SharedEnvironment, Cmdargs& args) { std::ostringstream fres; @@ -61,6 +73,7 @@ public: builtinCmds["="] = builtinCmds["set"] = {set, {Variable::id_string, Variable::id_any}, false}; builtinCmds[":="] = builtinCmds["local"] = {local, {Variable::id_string, Variable::id_any}, false}; builtinCmds["!="] = builtinCmds["global"] = {global, {Variable::id_string, Variable::id_any}, false}; + builtinCmds["delete"] = {del, {Variable::id_string}, false}; builtinCmds["concat"] = {concat, {}, true}; } };