Add the variable register

This commit is contained in:
Maple Redleaf
2025-11-21 11:09:16 -06:00
parent 6fb821f2f6
commit f88581ad47
3 changed files with 23 additions and 1 deletions
+1
View File
@@ -0,0 +1 @@
A simple programming language written in LUA
+1 -1
View File
@@ -1 +1 @@
print("Hello, World!")
require("varreg.lua")
+21
View File
@@ -0,0 +1,21 @@
local register = {}
function Register_Variable(name, value, scopelevel)
register[name] = { value = value, scopelevel = scopelevel }
end
function Get_Variable(name)
return register[name]
end
function Unregister_Variable(name)
register.remove(name)
end
function Collect_Garbage(scopelevel)
for name, variable in ipairs(register) do
if variable[scopelevel] > scopelevel then
register.remove(name)
end
end
end