1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 16:49:31 +00:00

Rename checkpoint variable, add reached variable for checkpoints

This commit is contained in:
Étienne Fildadut 2021-04-23 17:39:51 +02:00
parent 0171d92352
commit 17751c5c59
8 changed files with 102 additions and 22 deletions

View file

@ -132,17 +132,34 @@ local function parse_line(line, state, namespace)
state.aliases[alias] = fqm..".👁️"
end
if r.type == "function" then
-- define 🏁 variable
if not state.variables[fqm..".🏁"] then
state.variables[fqm..".🏁"] = {
-- define 🔖 variable
if not state.variables[fqm..".🔖"] then
state.variables[fqm..".🔖"] = {
type = "string",
value = ""
}
end
-- define alias for 🏁
local checkpoint_alias = state.builtin_aliases["🏁"]
-- define alias for 🔖
local checkpoint_alias = state.builtin_aliases["🔖"]
if checkpoint_alias then
local alias = ("%s.%s"):format(fqm, checkpoint_alias)
if state.aliases[alias] ~= nil and state.aliases[alias] then
return nil, ("trying to define alias %q for variable %q, but already exist and refer to different variable %q; at %s"):format(alias, fqm..".🔖", state.aliases[alias], line.source)
end
state.aliases[alias] = fqm..".🔖"
end
elseif r.type == "checkpoint" then
-- define 🏁 variable
if not state.variables[fqm..".🏁"] then
state.variables[fqm..".🏁"] = {
type = "number",
value = 0
}
end
-- define alias for 🏁
local reached_alias = state.builtin_aliases["🏁"]
if reached_alias then
local alias = ("%s.%s"):format(fqm, reached_alias)
if state.aliases[alias] ~= nil and state.aliases[alias] then
return nil, ("trying to define alias %q for variable %q, but already exist and refer to different variable %q; at %s"):format(alias, fqm..".🏁", state.aliases[alias], line.source)
end