diff --git a/anselme/state/State.lua b/anselme/state/State.lua index 6c5ebaf..44e44eb 100644 --- a/anselme/state/State.lua +++ b/anselme/state/State.lua @@ -184,7 +184,7 @@ State = class { assert(not self:active(), "a script is already active") self._coroutine = coroutine.create(function() local r = assert0(self:eval_local(code, source)) - event_manager:final_flush(self) + event_manager:complete_flush(self) if Return:is(r) then r = r.expression end return "return", r end) @@ -228,7 +228,7 @@ State = class { if code then self._coroutine = coroutine.create(function() local r = assert0(self:eval_local(code, source)) - event_manager:final_flush(self) + event_manager:complete_flush(self) self.scope:reset() -- scope stack is probably messed up after the switch if Return:is(r) then r = r.expression end return "return", r diff --git a/anselme/state/event_manager.lua b/anselme/state/event_manager.lua index 37af412..394eb72 100644 --- a/anselme/state/event_manager.lua +++ b/anselme/state/event_manager.lua @@ -75,7 +75,7 @@ return class { end end, -- keep flushing until nothing is left (a flush may re-fill the buffer during its execution) - final_flush = function(self, state) + complete_flush = function(self, state) while state.scope:get(last_event_type_identifier):to_lua(state) do self:flush(state) end end } diff --git a/anselme/stdlib/resume.lua b/anselme/stdlib/resume.lua index c16a799..bc0a382 100644 --- a/anselme/stdlib/resume.lua +++ b/anselme/stdlib/resume.lua @@ -2,6 +2,7 @@ local ast = require("anselme.ast") local ArgumentTuple, Boolean, Nil = ast.ArgumentTuple, ast.Boolean, ast.Nil local resume_manager = require("anselme.state.resume_manager") +local event_manager = require("anselme.state.event_manager") local calling_environment_manager = require("anselme.state.calling_environment_manager") return { @@ -34,8 +35,11 @@ return { end }, { - "merge branch", "()", - function(state) + "merge branch", "(complete flush=true)", + function(state, complete_flush) + if complete_flush:truthy() then + event_manager:complete_flush(state) + end state:merge() return Nil:new() end diff --git a/test/results/paragraph run force.ans b/test/results/paragraph run force.ans deleted file mode 100644 index 81fd9b4..0000000 --- a/test/results/paragraph run force.ans +++ /dev/null @@ -1,17 +0,0 @@ ---# run #-- ---- text --- -| {}"Force run checkpoint:" | -| {}"a" | -| {}"b" | ---- text --- -| {}"From checkpoint:" | -| {}"a" | -| {}"b" | ---- text --- -| {}"Force no checkpoint:" | -| {}"x" | -| {}"b" | ---- return --- -() ---# saved #-- -{"f.checkpoint":#p, "f.reached":*{#p:1}, "f.run":3} \ No newline at end of file diff --git a/test/results/paragraph run from.ans b/test/results/paragraph run from.ans index 27e6115..9721052 100644 --- a/test/results/paragraph run from.ans +++ b/test/results/paragraph run from.ans @@ -10,6 +10,7 @@ --- text --- | {}"Force no checkpoint:" | | {}"x" | +--- text --- | {}"b" | --- return --- () diff --git a/test/results/paragraph run.ans b/test/results/paragraph run.ans index a2ab961..055da87 100644 --- a/test/results/paragraph run.ans +++ b/test/results/paragraph run.ans @@ -2,6 +2,7 @@ --- text --- | {}"No checkpoint:" | | {}"x" | +--- text --- | {}"b" | --- text --- | {}"From checkpoint:" | @@ -10,6 +11,7 @@ --- text --- | {}"Force no checkpoint:" | | {}"x" | +--- text --- | {}"b" | --- return --- () diff --git a/test/tests/paragraph run force.ans b/test/tests/paragraph run force.ans deleted file mode 100644 index 971ca03..0000000 --- a/test/tests/paragraph run force.ans +++ /dev/null @@ -1,14 +0,0 @@ -:f = "f"!script($_) - |x - #p!checkpoint($_) - |a - |b - -|Force run checkpoint: -f!from(#p) - -|From checkpoint: -f! - -|Force no checkpoint: -f!from() diff --git a/test/tests/paragraph run.ans b/test/tests/paragraph run.ans index 8542159..edb28df 100644 --- a/test/tests/paragraph run.ans +++ b/test/tests/paragraph run.ans @@ -11,4 +11,4 @@ f! f! |Force no checkpoint: -f!from() +f!from