mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 16:49:31 +00:00
Previous system linked the variable name with the saved value, meaning the variable could not be renamed or moved outside the global scope. Instead we propose to store all persistent values in a global table, identifying each by a key. To still allow nice manipulation with identifiers, the alias syntax replace the persistent syntax for symbols - an aliases symbol will act as if a function call was used in place of the identifier when it appear.
37 lines
639 B
Lua
37 lines
639 B
Lua
local parser = require("parser")
|
|
|
|
local function define_lua(state, list)
|
|
for _, fn in ipairs(list) do
|
|
state.scope:define_lua(fn[1], fn[2], fn[3], true)
|
|
end
|
|
end
|
|
local function load(state, l)
|
|
for _, m in ipairs(l) do
|
|
define_lua(state, require("stdlib."..m))
|
|
end
|
|
end
|
|
|
|
return function(main_state)
|
|
load(main_state, {
|
|
"boolean",
|
|
"tag",
|
|
"conditionals",
|
|
"base",
|
|
"type_check"
|
|
})
|
|
|
|
local f = assert(io.open("stdlib/boot.ans"))
|
|
local boot = parser(f:read("*a"), "boot.ans")
|
|
f:close()
|
|
boot:eval(main_state)
|
|
|
|
load(main_state, {
|
|
"number",
|
|
"string",
|
|
"text",
|
|
"structures",
|
|
"closure",
|
|
"checkpoint",
|
|
"persist",
|
|
})
|
|
end
|