mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 00:59:31 +00:00
🔖 is now a function reference
This commit is contained in:
parent
fd07db83f2
commit
5a61573cdb
5 changed files with 11 additions and 12 deletions
|
|
@ -248,7 +248,7 @@ Functions can return a value using a [return line](#lines-that-can-t-have-childr
|
||||||
Functions always have the following variables defined in its namespace by default:
|
Functions always have the following variables defined in its namespace by default:
|
||||||
|
|
||||||
`👁️`: number, number of times the function was executed before
|
`👁️`: number, number of times the function was executed before
|
||||||
`🔖`: string, name of last reached checkpoint
|
`🔖`: funcion reference, last reached checkpoint. `nil` if no checkpoint reached.
|
||||||
|
|
||||||
* `§`: checkpoint. Followed by an [identifier](#identifiers), then eventually an [alias](#aliases). Define a checkpoint. Also define a new namespace for its children.
|
* `§`: checkpoint. Followed by an [identifier](#identifiers), then eventually an [alias](#aliases). Define a checkpoint. Also define a new namespace for its children.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -437,11 +437,11 @@ local function eval(state, exp)
|
||||||
else
|
else
|
||||||
local e
|
local e
|
||||||
-- eval function from start
|
-- eval function from start
|
||||||
if paren_call or checkpoint.value == "" then
|
if paren_call or checkpoint.type == "nil" then
|
||||||
ret, e = run(state, fn.child)
|
ret, e = run(state, fn.child)
|
||||||
-- resume at last checkpoint
|
-- resume at last checkpoint
|
||||||
else
|
else
|
||||||
local expr, err = expression(checkpoint.value, state, fn.namespace)
|
local expr, err = expression(checkpoint.value[1], state, fn.namespace)
|
||||||
if not expr then return expr, err end
|
if not expr then return expr, err end
|
||||||
ret, e = eval(state, expr)
|
ret, e = eval(state, expr)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -116,8 +116,8 @@ run_line = function(state, line)
|
||||||
value = reached.value + 1
|
value = reached.value + 1
|
||||||
})
|
})
|
||||||
set_variable(state, line.parent_function.namespace.."🔖", {
|
set_variable(state, line.parent_function.namespace.."🔖", {
|
||||||
type = "string",
|
type = "function reference",
|
||||||
value = line.name
|
value = { line.name }
|
||||||
})
|
})
|
||||||
merge_state(state)
|
merge_state(state)
|
||||||
else
|
else
|
||||||
|
|
@ -167,11 +167,10 @@ run_block = function(state, block, resume_from_there, i, j)
|
||||||
})
|
})
|
||||||
-- don't update checkpoint if an already more precise checkpoint is set
|
-- don't update checkpoint if an already more precise checkpoint is set
|
||||||
-- (since we will go up the whole checkpoint hierarchy when resuming from a nested checkpoint)
|
-- (since we will go up the whole checkpoint hierarchy when resuming from a nested checkpoint)
|
||||||
local current_checkpoint = checkpoint.value
|
if checkpoint.type == "nil" or not checkpoint.value[1]:match("^"..escape(parent_line.name)) then
|
||||||
if not current_checkpoint:match("^"..escape(parent_line.name)) then
|
|
||||||
set_variable(state, parent_line.parent_function.namespace.."🔖", {
|
set_variable(state, parent_line.parent_function.namespace.."🔖", {
|
||||||
type = "string",
|
type = "function reference",
|
||||||
value = parent_line.name
|
value = { parent_line.name }
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
merge_state(state)
|
merge_state(state)
|
||||||
|
|
|
||||||
|
|
@ -191,9 +191,9 @@ local function parse_line(line, state, namespace)
|
||||||
-- define 🔖 variable
|
-- define 🔖 variable
|
||||||
local checkpoint_alias = state.global_state.builtin_aliases["🔖"]
|
local checkpoint_alias = state.global_state.builtin_aliases["🔖"]
|
||||||
if checkpoint_alias then
|
if checkpoint_alias then
|
||||||
table.insert(line.children, 1, { content = (":🔖:%s=\"\""):format(checkpoint_alias), source = line.source })
|
table.insert(line.children, 1, { content = (":🔖:%s=()"):format(checkpoint_alias), source = line.source })
|
||||||
else
|
else
|
||||||
table.insert(line.children, 1, { content = ":🔖=\"\"", source = line.source })
|
table.insert(line.children, 1, { content = ":🔖=()", source = line.source })
|
||||||
end
|
end
|
||||||
elseif r.type == "checkpoint" then
|
elseif r.type == "checkpoint" then
|
||||||
-- define 🏁 variable
|
-- define 🏁 variable
|
||||||
|
|
|
||||||
|
|
@ -29,5 +29,5 @@ From q again:
|
||||||
~ f
|
~ f
|
||||||
|
|
||||||
Go to p again by setting checkpoint manually:
|
Go to p again by setting checkpoint manually:
|
||||||
~ f.checkpoint := "p"
|
~ f.checkpoint := &f.p
|
||||||
~ f
|
~ f
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue